@@ -10,12 +10,41 @@ import {
10
10
import type { InitialData } from '../../api/initialDataTypes' ;
11
11
import type { UserSettings } from '../../api/modelTypes' ;
12
12
import { EventTypes } from '../../api/eventTypes' ;
13
- import settingsReducer from '../settingsReducer' ;
13
+ import settingsReducer , { initialPerAccountSettingsState } from '../settingsReducer' ;
14
14
import * as eg from '../../__tests__/lib/exampleData' ;
15
15
16
16
describe ( 'settingsReducer' , ( ) => {
17
17
const baseState = eg . baseReduxState . settings ;
18
18
19
+ describe ( 'RESET_ACCOUNT_DATA' , ( ) => {
20
+ test ( 'resets per-account state without touching global state' , ( ) => {
21
+ const prevState = [
22
+ // per-account
23
+ eg . mkActionRegisterComplete ( {
24
+ user_settings : {
25
+ /* $FlowIgnore[incompatible-cast] - testing modern servers, which
26
+ send user_settings. */
27
+ ...( eg . action . register_complete . data . user_settings : $NonMaybeType <
28
+ InitialData [ 'user_settings' ] ,
29
+ > ) ,
30
+ enable_offline_push_notifications : false ,
31
+ enable_online_push_notifications : false ,
32
+ enable_stream_push_notifications : true ,
33
+ display_emoji_reaction_users : true ,
34
+ } ,
35
+ } ) ,
36
+
37
+ // global
38
+ { type : SET_GLOBAL_SETTINGS , update : { theme : 'night' } } ,
39
+ { type : SET_GLOBAL_SETTINGS , update : { language : 'fr' } } ,
40
+ ] . reduce ( settingsReducer , eg . baseReduxState . settings ) ;
41
+ expect ( settingsReducer ( prevState , eg . action . reset_account_data ) ) . toEqual ( {
42
+ ...prevState ,
43
+ ...initialPerAccountSettingsState ,
44
+ } ) ;
45
+ } ) ;
46
+ } ) ;
47
+
19
48
describe ( 'REGISTER_COMPLETE' , ( ) => {
20
49
test ( 'changes value of all notification settings (legacy, without user_settings)' , ( ) => {
21
50
const prevState = deepFreeze ( {
0 commit comments