Skip to content

Commit 8f5df97

Browse files
committed
settings test [nfc]: Use globalSettings as variable
This aligns these tests more closely with how we expect most app code to interact with these settings (using GlobalStoreWidget.settingsOf).
1 parent 2e054bf commit 8f5df97

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

test/model/settings_test.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,39 @@ void main() {
1515

1616
group('getUrlLaunchMode', () {
1717
testAndroidIos('globalSettings.browserPreference is null; use our per-platform defaults for HTTP links', () {
18-
final globalStore = eg.globalStore(globalSettings: GlobalSettingsData(
19-
browserPreference: null));
20-
check(globalStore).settings.getUrlLaunchMode(httpLink).equals(
18+
final globalSettings = eg.globalStore(globalSettings: GlobalSettingsData(
19+
browserPreference: null)).settings;
20+
check(globalSettings).getUrlLaunchMode(httpLink).equals(
2121
defaultTargetPlatform == TargetPlatform.android
2222
? UrlLaunchMode.inAppBrowserView : UrlLaunchMode.externalApplication);
2323
});
2424

2525
testAndroidIos('globalSettings.browserPreference is null; use our per-platform defaults for non-HTTP links', () {
26-
final globalStore = eg.globalStore(globalSettings: GlobalSettingsData(
27-
browserPreference: null));
28-
check(globalStore).settings.getUrlLaunchMode(nonHttpLink).equals(
26+
final globalSettings = eg.globalStore(globalSettings: GlobalSettingsData(
27+
browserPreference: null)).settings;
28+
check(globalSettings).getUrlLaunchMode(nonHttpLink).equals(
2929
defaultTargetPlatform == TargetPlatform.android
3030
? UrlLaunchMode.platformDefault : UrlLaunchMode.externalApplication);
3131
});
3232

3333
testAndroidIos('globalSettings.browserPreference is inApp; follow the user preference for http links', () {
34-
final globalStore = eg.globalStore(globalSettings: GlobalSettingsData(
35-
browserPreference: BrowserPreference.inApp));
36-
check(globalStore).settings.getUrlLaunchMode(httpLink).equals(
34+
final globalSettings = eg.globalStore(globalSettings: GlobalSettingsData(
35+
browserPreference: BrowserPreference.inApp)).settings;
36+
check(globalSettings).getUrlLaunchMode(httpLink).equals(
3737
UrlLaunchMode.inAppBrowserView);
3838
});
3939

4040
testAndroidIos('globalSettings.browserPreference is inApp; use platform default for non-http links', () {
41-
final globalStore = eg.globalStore(globalSettings: GlobalSettingsData(
42-
browserPreference: BrowserPreference.inApp));
43-
check(globalStore).settings.getUrlLaunchMode(nonHttpLink).equals(
41+
final globalSettings = eg.globalStore(globalSettings: GlobalSettingsData(
42+
browserPreference: BrowserPreference.inApp)).settings;
43+
check(globalSettings).getUrlLaunchMode(nonHttpLink).equals(
4444
UrlLaunchMode.platformDefault);
4545
});
4646

4747
testAndroidIos('globalSettings.browserPreference is external; follow the user preference', () {
48-
final globalStore = eg.globalStore(globalSettings: GlobalSettingsData(
49-
browserPreference: BrowserPreference.external));
50-
check(globalStore).settings.getUrlLaunchMode(httpLink).equals(
48+
final globalSettings = eg.globalStore(globalSettings: GlobalSettingsData(
49+
browserPreference: BrowserPreference.external)).settings;
50+
check(globalSettings).getUrlLaunchMode(httpLink).equals(
5151
UrlLaunchMode.externalApplication);
5252
});
5353
});

test/model/store_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ void main() {
3333

3434
group('GlobalStore.updateGlobalSettings', () {
3535
test('smoke', () async {
36-
final globalStore = eg.globalStore();
37-
check(globalStore).settings.themeSetting.equals(null);
36+
final globalSettings = eg.globalStore().settings;
37+
check(globalSettings).themeSetting.equals(null);
3838

39-
await globalStore.settings.setThemeSetting(ThemeSetting.dark);
40-
check(globalStore).settings.themeSetting.equals(ThemeSetting.dark);
39+
await globalSettings.setThemeSetting(ThemeSetting.dark);
40+
check(globalSettings).themeSetting.equals(ThemeSetting.dark);
4141
});
4242

4343
test('should notify listeners', () async {
4444
int notifyCount = 0;
45-
final globalStore = eg.globalStore();
46-
globalStore.settings.addListener(() => notifyCount++);
45+
final globalSettings = eg.globalStore().settings;
46+
globalSettings.addListener(() => notifyCount++);
4747
check(notifyCount).equals(0);
4848

49-
await globalStore.settings.setThemeSetting(ThemeSetting.light);
49+
await globalSettings.setThemeSetting(ThemeSetting.light);
5050
check(notifyCount).equals(1);
5151
});
5252

0 commit comments

Comments
 (0)