1

嗨,这是我想要存根的方法: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 条件返回的数据应该是什么?谢谢

4

0 回答 0