尝试模拟玩笑功能以期望传递falseReturn,但会引发此错误
{"balanceAccount": "4120.28", "lob": "Retail", "payment": {"achAuthRequiredInd": "false", "recentPaymentAmount": "", "recentPaymentIndicator": "false"}}
as argument 1, but it was called with "Cannot read property 'StatusDescription' of undefined".
甚至没有在fakeResponse中声明。这里有什么帮助吗?
main.spec.ts
const fakeReturnResponse = {
header: {
"statusCode": "9999",
"statusDesc": "partial failure",
"IndexOfRequestThatFailed": [
1
]
},
details: [
{
"lob": "Retail",
"balanceAccount": "4120.28",
"payment": {
"recentPaymentIndicator": "false",
"recentPaymentAmount": "",
"achAuthRequiredInd": "false"
}
}
]
};
const controller = GetAccountBalanceController;
const reqSPL: any = {
body: {
// Request body
}
};
makeRequest.mockImplementation(() => Promise.resolve(fakeReturnResponse));
const res: any = {};
res.send = jest.fn();
res.status = jest.fn();
describe('getBalance for Retail Response', function() {
beforeEach(function(done) {
controller.process(reqSPL, res).then(function() {
done();
});
});
describe('Retail', function() {
it('res.send should be called once', function() {
expect(res.send.mock.calls.length).toEqual(1);
});
it('res.send ', function() {
// The first argument of the first call to the function
expect(res.send).details[0](fakeReturnResponse);
});
});
});