Skip to content

Commit

Permalink
Merge pull request #99 from roughike/update-to-latest-beta
Browse files Browse the repository at this point in the history
Update to latest Flutter beta
  • Loading branch information
roughike committed Sep 15, 2018
2 parents 6e1752f + 2f51b67 commit 2165759
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 137 deletions.
3 changes: 2 additions & 1 deletion pubspec.yaml
Expand Up @@ -14,7 +14,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^2.2.3
mockito: ^3.0.0
image_test_utils: ^1.0.0

flutter:
uses-material-design: true
Expand Down
8 changes: 4 additions & 4 deletions test/redux/actor/actor_middleware_test.dart
Expand Up @@ -48,12 +48,12 @@ void main() {
});

test('FetchActorAvatarsAction - successful API request', () async {
when(mockTMDBApi.findAvatarsForActors(typed(any), typed(any)))
when(mockTMDBApi.findAvatarsForActors(any, any))
.thenAnswer((_) => Future.value(actorsWithAvatars));
await middleware.call(null, FetchActorAvatarsAction(event), next);

expect(actionLog.length, 4);
expect(actionLog[0], const isInstanceOf<FetchActorAvatarsAction>());
expect(actionLog[0], const TypeMatcher<FetchActorAvatarsAction>());

ActorsUpdatedAction actorsUpdated = actionLog[1];
expect(actorsUpdated.actors, event.actors);
Expand All @@ -67,8 +67,8 @@ void main() {
});

test('FetchActorAvatarsAction - handles errors silently', () async {
when(mockTMDBApi.findAvatarsForActors(typed(any), typed(any)))
.thenAnswer((_) => Future.value(Error()));
when(mockTMDBApi.findAvatarsForActors(any, any))
.thenAnswer((_) => Future.error(Error()));

await middleware.call(null, FetchActorAvatarsAction(event), next);
});
Expand Down
22 changes: 11 additions & 11 deletions test/redux/event/event_middleware_test.dart
Expand Up @@ -43,7 +43,7 @@ void main() {
test(
'when called with InitCompleteAction, should dispatch a ReceivedEventsAction with now playing and upcoming events',
() async {
when(mockFinnkinoApi.getNowInTheatersEvents(typed(any)))
when(mockFinnkinoApi.getNowInTheatersEvents(any))
.thenAnswer((_) => Future.value(nowInTheatersEvents));
when(mockFinnkinoApi.getUpcomingEvents())
.thenAnswer((_) => Future.value(upcomingEvents));
Expand All @@ -52,8 +52,8 @@ void main() {
null, InitCompleteAction(null, theater), next);

expect(actionLog.length, 3);
expect(actionLog[0], const isInstanceOf<InitCompleteAction>());
expect(actionLog[1], const isInstanceOf<RequestingEventsAction>());
expect(actionLog[0], const TypeMatcher<InitCompleteAction>());
expect(actionLog[1], const TypeMatcher<RequestingEventsAction>());

final ReceivedEventsAction action = actionLog[2];
expect(action.nowInTheatersEvents, nowInTheatersEvents);
Expand All @@ -64,7 +64,7 @@ void main() {
test(
'when called with ChangeCurrentTheaterAction, should request events for the theater',
() async {
when(mockFinnkinoApi.getNowInTheatersEvents(typed(any)))
when(mockFinnkinoApi.getNowInTheatersEvents(any))
.thenAnswer((_) => Future.value(nowInTheatersEvents));
when(mockFinnkinoApi.getUpcomingEvents())
.thenAnswer((_) => Future.value(upcomingEvents));
Expand All @@ -81,7 +81,7 @@ void main() {
);

Theater captured =
verify(mockFinnkinoApi.getNowInTheatersEvents(typed(captureAny)))
verify(mockFinnkinoApi.getNowInTheatersEvents(captureAny))
.captured
.first;
expect(captured.id, 'changed');
Expand All @@ -92,18 +92,18 @@ void main() {
test(
'when InitCompleteAction results in an error, should dispatch an ErrorLoadingEventsAction',
() async {
when(mockFinnkinoApi.getNowInTheatersEvents(typed(any)))
.thenAnswer((_) => Future.value(Error()));
when(mockFinnkinoApi.getNowInTheatersEvents(any))
.thenAnswer((_) => Future.error(Error()));
when(mockFinnkinoApi.getUpcomingEvents())
.thenAnswer((_) => Future.value(Error()));
.thenAnswer((_) => Future.error(Error()));

await middleware.call(
null, InitCompleteAction(null, theater), next);

expect(actionLog.length, 3);
expect(actionLog[0], const isInstanceOf<InitCompleteAction>());
expect(actionLog[1], const isInstanceOf<RequestingEventsAction>());
expect(actionLog[2], const isInstanceOf<ErrorLoadingEventsAction>());
expect(actionLog[0], const TypeMatcher<InitCompleteAction>());
expect(actionLog[1], const TypeMatcher<RequestingEventsAction>());
expect(actionLog[2], const TypeMatcher<ErrorLoadingEventsAction>());
},
);
});
Expand Down
30 changes: 15 additions & 15 deletions test/redux/show/show_middleware_test.dart
Expand Up @@ -53,7 +53,7 @@ void main() {
// passed. As DateTime(2018) will mean the very first hour and minute
// in January, all the show times in test assets will be after this date.
Clock.getCurrentTime = () => startOf2018;
when(mockFinnkinoApi.getSchedule(theater, typed(any)))
when(mockFinnkinoApi.getSchedule(theater, any))
.thenAnswer((_) => Future.value(<Show>[
Show(start: DateTime(2018, 02, 21)),
Show(start: DateTime(2018, 02, 21)),
Expand All @@ -68,9 +68,9 @@ void main() {
verify(mockFinnkinoApi.getSchedule(theater, null));

expect(actionLog.length, 4);
expect(actionLog[0], const isInstanceOf<InitCompleteAction>());
expect(actionLog[1], const isInstanceOf<ShowDatesUpdatedAction>());
expect(actionLog[2], const isInstanceOf<RequestingShowsAction>());
expect(actionLog[0], const TypeMatcher<InitCompleteAction>());
expect(actionLog[1], const TypeMatcher<ShowDatesUpdatedAction>());
expect(actionLog[2], const TypeMatcher<RequestingShowsAction>());

final ReceivedShowsAction receivedShowsAction = actionLog[3];
expect(receivedShowsAction.shows.length, 3);
Expand All @@ -82,7 +82,7 @@ void main() {
() async {
// Given
Clock.getCurrentTime = () => DateTime(2018, 3);
when(mockFinnkinoApi.getSchedule(theater, typed(any)))
when(mockFinnkinoApi.getSchedule(theater, any))
.thenAnswer((_) => Future.value(
<Show>[
Show(start: DateTime(2018, 02, 21)),
Expand All @@ -99,8 +99,8 @@ void main() {
verify(mockFinnkinoApi.getSchedule(theater, startOf2018));

expect(actionLog.length, 3);
expect(actionLog[0], const isInstanceOf<ChangeCurrentDateAction>());
expect(actionLog[1], const isInstanceOf<RequestingShowsAction>());
expect(actionLog[0], const TypeMatcher<ChangeCurrentDateAction>());
expect(actionLog[1], const TypeMatcher<RequestingShowsAction>());

final ReceivedShowsAction receivedShowsAction = actionLog[2];
expect(receivedShowsAction.shows.length, 1);
Expand All @@ -111,19 +111,19 @@ void main() {
'when InitCompleteAction results in an error, should dispatch an ErrorLoadingShowsAction',
() async {
// Given
when(mockFinnkinoApi.getSchedule(typed(any), typed(any)))
.thenAnswer((_) => Future.value(Error()));
when(mockFinnkinoApi.getSchedule(any, any))
.thenAnswer((_) => Future.error(Error()));

// When
await middleware.call(
mockStore, InitCompleteAction(null, theater), next);

// Then
expect(actionLog.length, 4);
expect(actionLog[0], const isInstanceOf<InitCompleteAction>());
expect(actionLog[1], const isInstanceOf<ShowDatesUpdatedAction>());
expect(actionLog[2], const isInstanceOf<RequestingShowsAction>());
expect(actionLog[3], const isInstanceOf<ErrorLoadingShowsAction>());
expect(actionLog[0], const TypeMatcher<InitCompleteAction>());
expect(actionLog[1], const TypeMatcher<ShowDatesUpdatedAction>());
expect(actionLog[2], const TypeMatcher<RequestingShowsAction>());
expect(actionLog[3], const TypeMatcher<ErrorLoadingShowsAction>());
},
);

Expand All @@ -135,8 +135,8 @@ void main() {
await middleware.call(mockStore, UpdateShowDatesAction(), next);

expect(actionLog.length, 2);
expect(actionLog[0], const isInstanceOf<UpdateShowDatesAction>());
expect(actionLog[1], const isInstanceOf<ShowDatesUpdatedAction>());
expect(actionLog[0], const TypeMatcher<UpdateShowDatesAction>());
expect(actionLog[1], const TypeMatcher<ShowDatesUpdatedAction>());

ShowDatesUpdatedAction action = actionLog[1];
expect(
Expand Down
6 changes: 3 additions & 3 deletions test/redux/theater/theater_middleware_test.dart
Expand Up @@ -30,7 +30,7 @@ void main() {
group('called with InitAction', () {
test('loads the preloaded theaters', () async {
// Given
when(mockAssetBundle.loadString(typed(any)))
when(mockAssetBundle.loadString(any))
.thenAnswer((_) => theatersXml());

// When
Expand All @@ -43,7 +43,7 @@ void main() {

test('when a persisted theater id exists, uses that as a default',
() async {
when(mockAssetBundle.loadString(typed(any)))
when(mockAssetBundle.loadString(any))
.thenAnswer((_) => theatersXml());
when(mockPreferences.getString(TheaterMiddleware.kDefaultTheaterId))
.thenReturn('001');
Expand All @@ -59,7 +59,7 @@ void main() {
test(
'when no persisted theater id, uses the first theater as a default',
() async {
when(mockAssetBundle.loadString(typed(any)))
when(mockAssetBundle.loadString(any))
.thenAnswer((_) => theatersXml());
when(mockPreferences.getString(TheaterMiddleware.kDefaultTheaterId))
.thenReturn(null);
Expand Down
58 changes: 0 additions & 58 deletions test/test_utils.dart

This file was deleted.

35 changes: 16 additions & 19 deletions test/ui/event_details/event_details_page_test.dart
@@ -1,7 +1,6 @@
import 'dart:io' as io;

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_test_utils/image_test_utils.dart';
import 'package:inkino/models/actor.dart';
import 'package:inkino/models/event.dart';
import 'package:inkino/models/show.dart';
Expand All @@ -14,16 +13,12 @@ import 'package:inkino/ui/events/event_poster.dart';
import 'package:inkino/ui/events/event_poster.dart' as eventPoster;
import 'package:meta/meta.dart';

import '../../test_utils.dart';

void main() {
group('EventDetailsPage', () {
String lastLaunchedTicketsUrl;
String lastLaunchedTrailerUrl;

setUp(() {
io.HttpOverrides.global = TestHttpOverrides();

showtimeInfo.launchTicketsUrl = (url) => lastLaunchedTicketsUrl = url;
eventPoster.launchTrailerVideo = (url) => lastLaunchedTrailerUrl = url;
});
Expand All @@ -38,20 +33,22 @@ void main() {
@required List<String> trailers,
@required Show show,
}) {
return tester.pumpWidget(MaterialApp(
home: eventDetails.EventDetailsPage(
Event(
id: '1',
title: 'Test Title',
genres: 'Test Genres',
directors: <String>[],
actors: <Actor>[],
images: EventImageData.empty(),
youtubeTrailers: trailers,
return provideMockedNetworkImages(() async {
return tester.pumpWidget(MaterialApp(
home: eventDetails.EventDetailsPage(
Event(
id: '1',
title: 'Test Title',
genres: 'Test Genres',
directors: <String>[],
actors: <Actor>[],
images: EventImageData.empty(),
youtubeTrailers: trailers,
),
show: show,
),
show: show,
),
));
));
});
}

testWidgets(
Expand Down
24 changes: 12 additions & 12 deletions test/ui/events/events_page_test.dart
@@ -1,7 +1,6 @@
import 'dart:io' as io;

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_test_utils/image_test_utils.dart';
import 'package:inkino/models/actor.dart';
import 'package:inkino/models/event.dart';
import 'package:inkino/models/loading_status.dart';
Expand All @@ -13,9 +12,8 @@ import 'package:inkino/ui/events/events_page.dart';
import 'package:inkino/ui/events/events_page_view_model.dart';
import 'package:mockito/mockito.dart';

import '../../test_utils.dart';

class MockEventsPageViewModel extends Mock implements EventsPageViewModel {}

class MockNavigatorObserver extends Mock implements NavigatorObserver {}

void main() {
Expand All @@ -36,18 +34,20 @@ void main() {
EventsPageViewModel mockViewModel;

setUp(() {
io.HttpOverrides.global = TestHttpOverrides();

observer = MockNavigatorObserver();
mockViewModel = MockEventsPageViewModel();
when(mockViewModel.refreshEvents).thenReturn(() {});
});

Future<Null> _buildEventsPage(WidgetTester tester) {
return tester.pumpWidget(MaterialApp(
home: EventsPageContent(mockViewModel),
navigatorObservers: <NavigatorObserver>[observer],
));
return provideMockedNetworkImages(() {
return tester.pumpWidget(
MaterialApp(
home: EventsPageContent(mockViewModel),
navigatorObservers: <NavigatorObserver>[observer],
),
);
});
}

testWidgets(
Expand Down Expand Up @@ -93,12 +93,12 @@ void main() {

// Building the events page should trigger the navigator observer
// once.
verify(observer.didPush(typed(any), typed(any)));
verify(observer.didPush(any, any));

await tester.tap(find.text('Test Title'));
await tester.pumpAndSettle();

verify(observer.didPush(typed(any), typed(any)));
verify(observer.didPush(any, any));
expect(find.byType(EventDetailsPage), findsOneWidget);
},
);
Expand Down

0 comments on commit 2165759

Please sign in to comment.