@@ -10,12 +10,41 @@ import {
1010import type { InitialData } from '../../api/initialDataTypes' ;
1111import type { UserSettings } from '../../api/modelTypes' ;
1212import { EventTypes } from '../../api/eventTypes' ;
13- import settingsReducer from '../settingsReducer' ;
13+ import settingsReducer , { initialPerAccountSettingsState } from '../settingsReducer' ;
1414import * as eg from '../../__tests__/lib/exampleData' ;
1515
1616describe ( 'settingsReducer' , ( ) => {
1717 const baseState = eg . baseReduxState . settings ;
1818
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+
1948 describe ( 'REGISTER_COMPLETE' , ( ) => {
2049 test ( 'changes value of all notification settings (legacy, without user_settings)' , ( ) => {
2150 const prevState = deepFreeze ( {
0 commit comments