Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
Clean settings model tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitletondor committed Oct 14, 2018
1 parent bb9375f commit 689ac3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/page/settings/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class SettingsState extends Union2Impl<SettingsStateLoading, SettingsStateLoad>
static final Doublet<SettingsStateLoading, SettingsStateLoad> factory
= const Doublet<SettingsStateLoading, SettingsStateLoad>();

final Union2<SettingsStateLoading, SettingsStateLoad> _union;

SettingsState._(this._union) : super(_union);
SettingsState._(Union2<SettingsStateLoading, SettingsStateLoad> union) : super(union);

factory SettingsState.loading() => SettingsState._(factory.first(SettingsStateLoading()));
factory SettingsState.load(String email, bool hapticFeedbackEnabled, bool analyticsEnabled) => SettingsState._(factory.second(SettingsStateLoad(email, hapticFeedbackEnabled, analyticsEnabled)));
Expand Down
4 changes: 4 additions & 0 deletions test/page/settings/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ void main() {

items.analyticsSettingStream.add(false);
expect(await items.stateStream.next, SettingsState.load(email, true, false));
verify(items.authService.setAnalyticsEnabled(false));

items.analyticsSettingStream.add(true);
expect(await items.stateStream.next, SettingsState.load(email, true, true));
verify(items.authService.setAnalyticsEnabled(true));
});

test('test haptic feedback enabled change is sent to the UI', () async {
Expand All @@ -74,9 +76,11 @@ void main() {

items.hapticFeedbackSettingStream.add(false);
expect(await items.stateStream.next, SettingsState.load(email, false, true));
verify(items.authService.setHapticFeedbackEnabled(false));

items.hapticFeedbackSettingStream.add(true);
expect(await items.stateStream.next, SettingsState.load(email, true, true));
verify(items.authService.setHapticFeedbackEnabled(true));
});

test('clicking on ToS button push the ToS page', () async {
Expand Down

0 comments on commit 689ac3c

Please sign in to comment.