-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more tests #49
Add more tests #49
Conversation
ArturAssisComp
commented
Jul 1, 2024
- Fix double emission for _second/_minute streams
- Implement tests for some of the remaining methods and function
lib/stop_watch_timer.dart
Outdated
@@ -44,6 +44,8 @@ class StopWatchTimer { | |||
|
|||
if (mode == StopWatchMode.countDown) { | |||
final value = presetMillisecond; | |||
_second = getRawSecond(value); | |||
_minute = getRawMinute(value); | |||
_rawTimeController = BehaviorSubject<int>.seeded(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, _second and _minute is initialized for coundDown, given that the initial value of 0 is not necessarily correct.
int? _second; | ||
int? _minute; | ||
int _second = 0; | ||
int _minute = 0; | ||
List<StopWatchRecord> _records = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_second and _minute changed from int? to int to avoid double emission of the initial value. Otherwise, if they start with null, the initial value will be emitted when BehaviorSubject.seeded is called and when it is first compared against latestSecond or latestMinute.
test/stop_watch_timer_test.dart
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test cases for second and minute change were updated to express assertion clearer. Instead of checking the length and the last element of second/minute value, it explicitly checks for list equality. Other than that, a test case was added for count down timer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.