Skip to content

Commit

Permalink
fix: tests or something
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkerH27 authored and lishaduck committed Nov 22, 2023
1 parent 6c3fe24 commit 31d93eb
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "package:flutter_test/flutter_test.dart";
import "package:mocktail/mocktail.dart";
import "package:pirate_code/features/auth/data/auth_repository.dart";
import "package:pirate_code/features/pirate_coins/presentation/pirate_coins_page/pirate_coins_page.dart";
import "package:pirate_code/features/pirate_coins/presentation/pirate_coins_page/pirate_coins_teacher_page.dart";

import "../../../../helpers/pump_app.dart";

Expand All @@ -16,7 +16,7 @@ void main() {
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsPage(),
const PirateCoinsTeacherPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
Expand All @@ -34,7 +34,7 @@ void main() {
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsPage(),
const PirateCoinsTeacherPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
Expand All @@ -52,7 +52,7 @@ void main() {
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsPage(),
const PirateCoinsTeacherPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
Expand All @@ -70,7 +70,7 @@ void main() {
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsPage(),
const PirateCoinsTeacherPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import "package:flutter_test/flutter_test.dart";
import "package:mocktail/mocktail.dart";
import "package:pirate_code/features/auth/data/auth_repository.dart";
import "package:pirate_code/features/pirate_coins/presentation/pirate_coins_page/pirate_coins_student_page.dart";

import "../../../../helpers/pump_app.dart";

void main() {
group("Pirate Coins page is accessible...", () {
group("is accessible...", () {
testWidgets("on Android.", (tester) async {
final mockAuthRepository = _MockAuthRepository();
verifyZeroInteractions(mockAuthRepository);

await tester.pumpApp(
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsStudentPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
.called(1);

final handle = tester.ensureSemantics();
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets("on iOS.", (tester) async {
final mockAuthRepository = _MockAuthRepository();
verifyZeroInteractions(mockAuthRepository);

await tester.pumpApp(
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsStudentPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
.called(1);

final handle = tester.ensureSemantics();
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));
handle.dispose();
});
testWidgets("according to the WCAG.", (tester) async {
final mockAuthRepository = _MockAuthRepository();
verifyZeroInteractions(mockAuthRepository);

await tester.pumpApp(
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsStudentPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
.called(1);

final handle = tester.ensureSemantics();
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
testWidgets("with regard to labeling buttons.", (tester) async {
final mockAuthRepository = _MockAuthRepository();
verifyZeroInteractions(mockAuthRepository);

await tester.pumpApp(
overrides: [
authProvider.overrideWithValue(mockAuthRepository),
],
const PirateCoinsStudentPage(),
);

verify(() => mockAuthRepository.authenticate(anonymous: true))
.called(1);

final handle = tester.ensureSemantics();
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
});
});
}

class _MockAuthRepository extends Mock implements AuthRepository {}

0 comments on commit 31d93eb

Please sign in to comment.