Skip to content
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

Merged
merged 25 commits into from
Jul 30, 2024
Merged

Add more tests #49

merged 25 commits into from
Jul 30, 2024

Conversation

ArturAssisComp
Copy link
Contributor

  • Fix double emission for _second/_minute streams
  • Implement tests for some of the remaining methods and function

@@ -44,6 +44,8 @@ class StopWatchTimer {

if (mode == StopWatchMode.countDown) {
final value = presetMillisecond;
_second = getRawSecond(value);
_minute = getRawMinute(value);
_rawTimeController = BehaviorSubject<int>.seeded(value);
Copy link
Contributor Author

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 = [];
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@ArturAssisComp ArturAssisComp marked this pull request as ready for review July 29, 2024 02:14
Copy link
Owner

@hukusuke1007 hukusuke1007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hukusuke1007 hukusuke1007 merged commit 43c8576 into hukusuke1007:master Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants