Skip to content

Commit 2b1dd5c

Browse files
committed
test(app_bloc): AppError & AppLoaded
1 parent 60a9d46 commit 2b1dd5c

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

test/src/blocs/app_bloc_test.dart

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,48 @@ main() {
2323
test('close does not emit new app state', () {
2424
appBloc.close();
2525

26-
//TODO: 1- Must implement and check emitsDone
27-
throw UnimplementedError();
26+
expectLater(
27+
appBloc,
28+
emitsInOrder([AppEmpty(), emitsDone]),
29+
);
2830
});
2931

3032
group('AppState', () {
3133
test('AppEmpty : initialState', () {
3234
expect(appBloc.initialState, AppEmpty());
3335
});
36+
37+
test('AppError', () {
38+
when(serviceMock.loadMovies()).thenThrow(Error);
39+
40+
final expectedResponse = [
41+
AppEmpty(),
42+
AppLoading(),
43+
AppError(),
44+
];
45+
46+
appBloc.add(FetchEvent());
47+
48+
expectLater(
49+
appBloc,
50+
emitsInOrder(expectedResponse),
51+
);
52+
});
53+
54+
test('AppLoaded', () {
55+
when(serviceMock.loadMovies()).thenAnswer((_) => Future.value(response));
56+
final expectedResponse = [
57+
AppEmpty(),
58+
AppLoading(),
59+
AppLoaded(response: response),
60+
];
61+
62+
appBloc.add(FetchEvent());
63+
64+
expectLater(
65+
appBloc,
66+
emitsInOrder(expectedResponse),
67+
);
68+
});
3469
});
3570
}

0 commit comments

Comments
 (0)