嗨,这是我想添加的方法:checkLimit方法。
class MyClass {
final ResponseBase isAvailable =
await sampleRepository.checkLimit(data: _data);
if (isAvailable.status == ResponseStatus.notOk) {
yield NotAvailable(
ErrorType.limit,
data: _data,
errorResponse: isAvailable?.responseError,
);
return;
}
}
这是我的测试
test('test when event is ScanQRCode checklimit not ok', () {
final List<ScanState> expectedStates = <CodeScanState>[
ScanReady(),
ScanAvailableFetching(),
ScanNotAvailable(
ScanErrorType.Limit,
redeemData: mockRedeemData,
),
];
when(mockPromosRepository.checkLimit(
redeemData: mockRedeemData))
.thenAnswer(
(_) => Future<ResponseBase>.value(mockResponseBase.status));
expectLater(scanBloc.state, emitsInAnyOrder(expectedStates));
scanBloc.dispatch(ScanQRCode(mockRedeemData));
});
通过if条件返回的数据应该是什么?谢谢