Skip to content

Commit

Permalink
refactor(flutter_shopping_cart): use setUp in blocTest
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Oct 6, 2021
1 parent e76d986 commit ba8e137
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ void main() {
blocTest<CatalogBloc, CatalogState>(
'emits [CatalogLoading, CatalogLoaded] '
'when catalog is loaded successfully',
build: () {
setUp: () {
when(shoppingRepository.loadCatalog).thenAnswer(
(_) async => mockItemNames,
);
return CatalogBloc(shoppingRepository: shoppingRepository);
},
build: () => CatalogBloc(shoppingRepository: shoppingRepository),
act: (bloc) => bloc.add(CatalogStarted()),
expect: () => <CatalogState>[
CatalogLoading(),
Expand All @@ -43,10 +43,10 @@ void main() {
blocTest<CatalogBloc, CatalogState>(
'emits [CatalogLoading, CatalogError] '
'when loading the catalog throws an exception',
build: () {
setUp: () {
when(shoppingRepository.loadCatalog).thenThrow(Exception('Error'));
return CatalogBloc(shoppingRepository: shoppingRepository);
},
build: () => CatalogBloc(shoppingRepository: shoppingRepository),
act: (bloc) => bloc.add(CatalogStarted()),
expect: () => <CatalogState>[
CatalogLoading(),
Expand Down

0 comments on commit ba8e137

Please sign in to comment.