-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:kubrs_app/timer/bloc/timer_bloc.dart'; | ||
|
||
void main() { | ||
group('TimerBloc', () { | ||
blocTest<TimerBloc, TimerState>( | ||
'emits reset state when timer is reseted', | ||
build: TimerBloc.new, | ||
act: (bloc) => bloc.add(const ResetTimer()), | ||
expect: () => const <TimerState>[TimerReseted()], | ||
); | ||
|
||
blocTest<TimerBloc, TimerState>( | ||
'emits running state when timer is started', | ||
setUp: WidgetsFlutterBinding.ensureInitialized, | ||
build: TimerBloc.new, | ||
seed: TimerReseted.new, | ||
act: (bloc) => bloc.add(const StartTimer()), | ||
expect: () => const <TimerState>[TimerRunning(Duration.zero)], | ||
); | ||
|
||
blocTest<TimerBloc, TimerState>( | ||
'emits running states when timer ticks', | ||
build: TimerBloc.new, | ||
seed: () => const TimerRunning(Duration.zero), | ||
act: (bloc) => bloc | ||
..add(const TickTimer(duration: Duration(seconds: 1))) | ||
..add(const TickTimer(duration: Duration(seconds: 2))), | ||
expect: () => const <TimerState>[ | ||
TimerRunning(Duration(seconds: 1)), | ||
TimerRunning(Duration(seconds: 2)), | ||
], | ||
); | ||
|
||
blocTest<TimerBloc, TimerState>( | ||
'emits stop state when timer is stopped', | ||
build: TimerBloc.new, | ||
seed: () => const TimerRunning(Duration(seconds: 10)), | ||
act: (bloc) => bloc.add(const StopTimer(duration: Duration(seconds: 10))), | ||
expect: () => const <TimerState>[TimerStopped(Duration(seconds: 10))], | ||
); | ||
|
||
blocTest<TimerBloc, TimerState>( | ||
'emits done state when timer is ended', | ||
build: TimerBloc.new, | ||
seed: () => const TimerStopped(Duration(seconds: 10)), | ||
act: (bloc) => bloc.add(const EndTimer(duration: Duration(seconds: 10))), | ||
expect: () => const <TimerState>[TimerDone(Duration(seconds: 10))], | ||
); | ||
}); | ||
} |