AgileVentures / AgileVentures/WebsiteOne-FE

action unit test problem - always show success.

未關閉
#223 0 則留言 0 個 reaction 已指派 1 人 已被 @chris110408 認領 在 GitHub 檢視
主要語言
JavaScript
星號
3
分支
22
PR 合併指標
30 天內沒有已合併 PR

描述

!--- Provide a general summary of the issue in the Title above -->

the action contains side affection (use axios to retrieve the data from API ) .

the current unit test use moxios to mock data request from the API. However, the unit test did not write correctly.

I am using https://github.com/AgileVentures/WebsiteOne-FE/blob/develop/src/tests/actions/createProjectAction.test.js as an example. unit test (posts project info to Rails backend and returns without error ) -line 28

the purpose of the unit test is compare " the data in store after the dispatch action contains props data" to "the expectedActions "

## Expected Behavior

create a helper function to helper moxios use the right data when the user give the correct props and dispatch the action correctly the unit test should show success and if the "props" contains the wrong data the unit test should fail.

## Current Behavior

always success no matter what props data pass to the dispatch action. because we are using the expectedActions to compare with expectedActions.

## Possible Solution

correct the unit test

I will also create a separate ticket to separate the axios request from the action. try to isolate the side effect in a different ticket

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。