Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marfavi committed Jan 22, 2024
1 parent fec6939 commit 196dc47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
25 changes: 16 additions & 9 deletions test/core/widgets/components/tickets/tickets_card_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ void main() {
expect(find.text('Small drink'), findsOneWidget);
});

testWidgets('Coffee card matches golden file', (tester) async {
await tester.pumpWidget(
MaterialApp(home: Scaffold(body: TicketsCard(testTicket))),
);
await expectLater(
find.byType(TicketsCard),
matchesGoldenFile('goldens/tickets_card.png'),
);
});
// TODO(marfavi): Due to the use of OS-specific rendering of golden files,
// this test will fail on Windows and Mac. We should find a way to make
// golden tests platform-independent.
testWidgets(
'Tickets card matches golden file',
(tester) async {
await tester.pumpWidget(
MaterialApp(home: Scaffold(body: TicketsCard(testTicket))),
);
await expectLater(
find.byType(TicketsCard),
matchesGoldenFile('goldens/tickets_card.png'),
);
},
skip: true,
);
}
14 changes: 4 additions & 10 deletions test/features/product/presentation/cubit/product_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,21 @@ void main() {

group('getProducts', () {
blocTest(
'should emit [Loading, Loaded] use case succeeds',
'should emit [Loaded] use case succeeds',
build: () => cubit,
setUp: () => when(productRepository.getProducts())
.thenAnswer((_) => TaskEither.fromEither(Right(allProducts))),
act: (cubit) => cubit.getProducts(),
expect: () => [
isA<ProductsLoading>(),
isA<ProductsLoaded>(),
],
expect: () => [isA<ProductsLoaded>()],
);

blocTest(
'should emit [Loading, Error] when use case fails',
'should emit [Error] when use case fails',
build: () => cubit,
setUp: () => when(productRepository.getProducts())
.thenAnswer((_) => TaskEither.fromEither(testFailure)),
act: (cubit) => cubit.getProducts(),
expect: () => [
isA<ProductsLoading>(),
isA<ProductsError>(),
],
expect: () => [isA<ProductsError>()],
);
});
}

0 comments on commit 196dc47

Please sign in to comment.