当我执行Sagas文件测试时,无论测试内容如何,我都会得到以下结果,始终是正确的。
我觉得这很奇怪,那么我的问题是什么,缺失的是什么?
您可以在所附图片中找到测试结果
4Gsetup.test.js
import { expectSaga } from 'redux-saga-test-plan';
import {showParameters4GAction} from "../../../src/appRedux/actions/Setup4G.js"
import { select } from "redux-saga/effects";
import getParameters4G from "../../../src/appRedux/sagas/Setup4G.js"
describe('SAGAS', () => {
const states ={
status4G: 1,
country: "Zimbabwe",
operator: "Telco",
apn: "apn.telco.art",
username: "teleco_52369874",
password: "Cx8Dbth&zbN6",
codepin: "1234"
}
it('Test Saga function getParameters4G', () => {
expectSaga(getParameters4G, showParameters4GAction())
.withState(states)
.provide([
[select(states => states),'']
])
.put(showParameters4GAction())
.run()
})
Setup4G.js [操作文件]
export function getParameteres4GAction() {
return {
type: GET_PARAMETERS_4G,
};
};
export function showParameters4GAction(params4GInfo) {
console.log("ssssssssssssss",params4GInfo)
return {
type: SHOW_PARAMETERS_4G,
params4GInfo
};
}
Setup4G.js [Saga文件]
function* getParameters4G() {
try {
const parameters4GData = yield call(getParameters4GRequest);
if (parameters4GData) {
yield put(showParameters4GAction(parameters4GData));
}
} catch (error) {
}
}
export function* getParameters4GFork() {
yield takeEvery(GET_PARAMETERS_4G, getParameters4G);
}