@@ -3,14 +3,18 @@ import { SettingsState } from 'types/reducers';
3
3
4
4
import * as actions from 'actions/settings' ;
5
5
import reducer from 'reducers/settings' ;
6
- import { DARK_MODE , LIGHT_MODE } from 'types/settings' ;
6
+ import {
7
+ DARK_COLOR_SCHEME_PREFERENCE ,
8
+ LIGHT_COLOR_SCHEME_PREFERENCE ,
9
+ SYSTEM_COLOR_SCHEME_PREFERENCE ,
10
+ } from 'types/settings' ;
7
11
import { initAction , rehydrateAction } from 'test-utils/redux' ;
8
12
import config , { RegPeriod } from 'config' ;
9
13
10
14
const initialState : SettingsState = {
11
15
newStudent : false ,
12
16
faculty : '' ,
13
- mode : LIGHT_MODE ,
17
+ colorScheme : SYSTEM_COLOR_SCHEME_PREFERENCE ,
14
18
hiddenInTimetable : [ ] ,
15
19
modRegNotification : {
16
20
enabled : true ,
@@ -25,7 +29,14 @@ const initialState: SettingsState = {
25
29
const settingsWithNewStudent : SettingsState = { ...initialState , newStudent : true } ;
26
30
const faculty = 'School of Computing' ;
27
31
const settingsWithFaculty : SettingsState = { ...initialState , faculty } ;
28
- const settingsWithDarkMode : SettingsState = { ...initialState , mode : DARK_MODE } ;
32
+ const settingsWithLightMode : SettingsState = {
33
+ ...initialState ,
34
+ colorScheme : LIGHT_COLOR_SCHEME_PREFERENCE ,
35
+ } ;
36
+ const settingsWithDarkMode : SettingsState = {
37
+ ...initialState ,
38
+ colorScheme : DARK_COLOR_SCHEME_PREFERENCE ,
39
+ } ;
29
40
const settingsWithDismissedNotifications : SettingsState = produce ( initialState , ( draft ) => {
30
41
draft . modRegNotification . dismissed = [
31
42
{ type : 'Select Courses' , name : '1' } ,
@@ -52,23 +63,18 @@ describe('settings', () => {
52
63
expect ( nextState ) . toEqual ( settingsWithFaculty ) ;
53
64
} ) ;
54
65
55
- test ( 'can select mode ' , ( ) => {
56
- const action = actions . selectMode ( DARK_MODE ) ;
66
+ test ( 'can select color scheme ' , ( ) => {
67
+ const action = actions . selectColorScheme ( DARK_COLOR_SCHEME_PREFERENCE ) ;
57
68
const nextState : SettingsState = reducer ( initialState , action ) ;
58
69
expect ( nextState ) . toEqual ( settingsWithDarkMode ) ;
59
70
60
- const action2 = actions . selectMode ( LIGHT_MODE ) ;
61
- const nextState2 : SettingsState = reducer ( nextState , action2 ) ;
62
- expect ( nextState2 ) . toEqual ( initialState ) ;
63
- } ) ;
64
-
65
- test ( 'can toggle mode' , ( ) => {
66
- const action = actions . toggleMode ( ) ;
67
- const nextState : SettingsState = reducer ( initialState , action ) ;
68
- expect ( nextState ) . toEqual ( settingsWithDarkMode ) ;
71
+ const action2 = actions . selectColorScheme ( LIGHT_COLOR_SCHEME_PREFERENCE ) ;
72
+ const nextState2 : SettingsState = reducer ( initialState , action2 ) ;
73
+ expect ( nextState2 ) . toEqual ( settingsWithLightMode ) ;
69
74
70
- const nextState2 : SettingsState = reducer ( nextState , action ) ;
71
- expect ( nextState2 ) . toEqual ( initialState ) ;
75
+ const action3 = actions . selectColorScheme ( SYSTEM_COLOR_SCHEME_PREFERENCE ) ;
76
+ const nextState3 : SettingsState = reducer ( nextState , action3 ) ;
77
+ expect ( nextState3 ) . toEqual ( initialState ) ;
72
78
} ) ;
73
79
74
80
test ( 'set module table order' , ( ) => {
0 commit comments