Fixes even more async test issues

pull/505/head
Alvaro Almeida Freire Stivi 1 year ago
parent 3ae8a0c36b
commit d157d81e91
No known key found for this signature in database

@ -300,6 +300,7 @@ void main() {
flameTester.testGameWidget(
'adds PlayerInitialsSubmitted when initials are submitted',
setUp: (game, _) async {
await game.onLoad();
final state = InitialsFormState(
score: 10,
character: game.character,
@ -336,6 +337,7 @@ void main() {
flameTester.testGameWidget(
'adds GameOverInfoDisplay when InitialsSuccessState',
setUp: (game, _) async {
await game.onLoad();
final state = InitialsSuccessState(score: 100);
whenListen(
bloc,
@ -350,6 +352,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
expect(
@ -363,6 +366,7 @@ void main() {
'adds the mobile controls overlay '
'when platform is mobile at InitialsFormState',
setUp: (game, _) async {
await game.onLoad();
final platformHelper = _MockPlatformHelper();
final state = InitialsFormState(
score: 10,
@ -382,6 +386,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
expect(
@ -395,6 +400,7 @@ void main() {
'remove the mobile controls overlay '
'when InitialsSuccessState',
setUp: (game, _) async {
await game.onLoad();
final platformHelper = _MockPlatformHelper();
final state = InitialsSuccessState(score: 10);
whenListen(
@ -411,6 +417,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
expect(
@ -423,6 +430,7 @@ void main() {
flameTester.testGameWidget(
'adds InitialsSubmissionSuccessDisplay on InitialsSuccessState',
setUp: (game, _) async {
await game.onLoad();
final state = InitialsSuccessState(score: 100);
whenListen(
bloc,
@ -437,6 +445,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
expect(
@ -449,6 +458,7 @@ void main() {
flameTester.testGameWidget(
'adds ShareScoreRequested event when sharing',
setUp: (game, _) async {
await game.onLoad();
final state = InitialsSuccessState(score: 100);
whenListen(
bloc,
@ -484,6 +494,7 @@ void main() {
flameTester.testGameWidget(
'adds InitialsSubmissionFailureDisplay on InitialsFailureState',
setUp: (game, _) async {
await game.onLoad();
whenListen(
bloc,
Stream<BackboxState>.empty(),
@ -500,6 +511,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
expect(
@ -521,6 +533,7 @@ void main() {
flameTester.testGameWidget(
'adds ShareDisplay on ShareState',
setUp: (game, _) async {
await game.onLoad();
final state = ShareState(score: 100);
whenListen(
bloc,
@ -535,6 +548,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
expect(
@ -547,6 +561,7 @@ void main() {
flameTester.testGameWidget(
'opens Facebook link when sharing with Facebook',
setUp: (game, _) async {
await game.onLoad();
when(() => urlLauncher.canLaunch(any()))
.thenAnswer((_) async => true);
when(
@ -711,6 +726,7 @@ void main() {
flameTester.testGameWidget(
'closes the subscription when it is removed',
setUp: (game, _) async {
await game.onLoad();
final streamController = StreamController<BackboxState>();
whenListen(
bloc,
@ -751,6 +767,7 @@ void main() {
flameTester.testGameWidget(
'adds PlayerInitialsSubmitted when the timer is finished',
setUp: (game, _) async {
await game.onLoad();
final initialState = InitialsFailureState(
score: 10,
character: theme.DashTheme(),
@ -769,6 +786,7 @@ void main() {
backbox,
platformHelper: platformHelper,
);
await game.ready();
},
verify: (game, _) async {
game.update(4);

@ -77,6 +77,7 @@ void main() {
'adds GameBonus.dashNest to the game '
'when signpost becomes fully activated',
setUp: (game, tester) async {
await game.onLoad();
final behavior = FlutterForestBonusBehavior();
final parent = FlutterForest.test();
final signpostBloc = _MockSignpostCubit();
@ -94,6 +95,7 @@ void main() {
signpostBloc: signpostBloc,
);
await parent.ensureAdd(behavior);
await game.ready();
streamController.add(SignpostState.active3);
await tester.pump();
@ -108,6 +110,7 @@ void main() {
'calls onProgressed and onReset '
'when signpost becomes fully activated',
setUp: (game, tester) async {
await game.onLoad();
final behavior = FlutterForestBonusBehavior();
final parent = FlutterForest.test();
final dashBumpersBloc = _MockDashBumpersCubit();
@ -127,6 +130,7 @@ void main() {
dashBumpersBloc: dashBumpersBloc,
);
await parent.ensureAdd(behavior);
await game.ready();
streamController.add(SignpostState.active3);
await tester.pump();
@ -140,6 +144,7 @@ void main() {
'adds BonusBallSpawningBehavior to the game '
'when signpost becomes fully activated',
setUp: (game, tester) async {
await game.onLoad();
final behavior = FlutterForestBonusBehavior();
final parent = FlutterForest.test();
final signpostBloc = _MockSignpostCubit();
@ -157,10 +162,9 @@ void main() {
signpostBloc: signpostBloc,
);
await parent.ensureAdd(behavior);
streamController.add(SignpostState.active3);
await tester.pump();
await game.ready();
await tester.pump();
expect(
game.descendants().whereType<BonusBallSpawningBehavior>().length,

Loading…
Cancel
Save