The unit test I write below doesn't work when there are 3 expect, how can I rewrite the unit test below:
test('400 bad response', () async {
when(
() => sampleClient.getTransaction(
'1'),
).thenThrow(DioError(
response: Response(
statusCode: 400,
data: badRepsonseJson,
requestOptions: RequestOptions(path: '')),
requestOptions: RequestOptions(path: '')));
final call = sampleService.getTransactionByHash(
'1');
expect(() => call, throwsA(TypeMatcher<SampleException>())); // Expect 1
try {
await sampleService.getTransactionByHash(
'1');
} on SampleException catch (e) {
expect(e.errorCode, badResponse.statusCode); // Expect 2
expect(e.message, badResponse.message); // Expect 3
}
});