Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joecks committed Jul 20, 2022
1 parent 1367220 commit 8d6f0a4
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ void main() async {
.cards)
.toSet());
when(surveyCardInjectionUseCase.toCards(any)).thenAnswer((realInvocation) =>
(realInvocation.positionalArguments.first as Set<Document>? ?? const {})
.map(item_renderer.Card.document));
(realInvocation.positionalArguments.first as Set<item_renderer.Card>? ??
const {}));

di.reset();

Expand All @@ -160,6 +160,7 @@ void main() async {
await eventsController.close();
await engine.dispose();
await manager.close();
await tearDownWidgetTest();
});

blocTest<DiscoveryFeedManager, DiscoveryState>(
Expand All @@ -182,7 +183,6 @@ void main() async {
verifyNoMoreInteractions(mockDiscoveryEngine);
},
);

blocTest<DiscoveryFeedManager, DiscoveryState>(
'WHEN feed card index changes THEN store the new index in the repository ',
build: () => manager,
Expand All @@ -193,20 +193,20 @@ void main() async {
await manager.stream.firstWhere((it) => it.cards.isNotEmpty);
},
act: (manager) async => manager.handleIndexChanged(1),
expect: () => [
DiscoveryState(
cards: {
item_renderer.Card.document(fakeDocumentA),
item_renderer.Card.document(fakeDocumentB),
},
cardIndex: 1,
isComplete: true,
isFullScreen: false,
didReachEnd: false,
subscriptionStatus: null,
),
],
verify: (manager) {
expect(
manager.state,
DiscoveryState(
cards: {
item_renderer.Card.document(fakeDocumentA),
item_renderer.Card.document(fakeDocumentB),
},
cardIndex: 1,
isComplete: true,
isFullScreen: false,
didReachEnd: false,
subscriptionStatus: null,
));
verifyInOrder([
// when manager inits
feedRepository.get(),
Expand Down Expand Up @@ -305,6 +305,7 @@ void main() async {
.thenAnswer((_) async => Session.withFeedRequested()),
act: (manager) async {
manager.handleNavigateIntoCard(fakeDocumentA);
await manager.stream.firstWhere((it) => it.isComplete);
},
verify: (manager) {
expect(
Expand All @@ -314,8 +315,8 @@ void main() async {
item_renderer.Card.document(fakeDocumentA),
item_renderer.Card.document(fakeDocumentB),
},
cardIndex: 0,
isComplete: false,
cardIndex: 1,
isComplete: true,
isFullScreen: true,
shouldUpdateNavBar: false,
didReachEnd: false,
Expand Down

0 comments on commit 8d6f0a4

Please sign in to comment.