Skip to content

Commit

Permalink
updated leaderboard_page_test.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
AyadLaouissi committed Apr 15, 2024
1 parent 27734cd commit e4493af
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions test/leaderboard/view/leaderboard_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:io_crossword/l10n/l10n.dart';
import 'package:io_crossword/leaderboard/bloc/leaderboard_bloc.dart';
import 'package:io_crossword/leaderboard/view/leaderboard_page.dart';
import 'package:io_crossword/player/bloc/player_bloc.dart';
import 'package:io_crossword_ui/io_crossword_ui.dart';
import 'package:mockingjay/mockingjay.dart';

Expand All @@ -15,6 +16,9 @@ import '../../helpers/helpers.dart';
class _MockLeaderboardBloc extends MockBloc<LeaderboardEvent, LeaderboardState>
implements LeaderboardBloc {}

class _MockPlayerBloc extends MockBloc<PlayerEvent, PlayerState>
implements PlayerBloc {}

void main() {
group('LeaderboardPage', () {
testWidgets(
Expand All @@ -29,6 +33,7 @@ void main() {

group('LeaderboardView', () {
late LeaderboardBloc leaderboardBloc;
late PlayerBloc playerBloc;
late Widget widget;

late AppLocalizations l10n;
Expand All @@ -39,9 +44,17 @@ void main() {

setUp(() {
leaderboardBloc = _MockLeaderboardBloc();

widget = BlocProvider<LeaderboardBloc>(
create: (_) => leaderboardBloc,
playerBloc = _MockPlayerBloc();

widget = MultiBlocProvider(
providers: [
BlocProvider<LeaderboardBloc>(
create: (_) => leaderboardBloc,
),
BlocProvider<PlayerBloc>(
create: (context) => playerBloc,
),
],
child: LeaderboardView(),
);
});
Expand Down Expand Up @@ -86,6 +99,7 @@ void main() {
(tester) async {
when(() => leaderboardBloc.state)
.thenReturn(LeaderboardState(status: LeaderboardStatus.success));
when(() => playerBloc.state).thenReturn(PlayerState());

await tester.pumpApp(widget);

Expand Down

0 comments on commit e4493af

Please sign in to comment.