@@ -3,7 +3,6 @@ import deepFreeze from 'deep-freeze';
3
3
4
4
import {
5
5
DEAD_QUEUE ,
6
- LOGOUT ,
7
6
APP_ONLINE ,
8
7
REGISTER_ABORT ,
9
8
APP_ORIENTATION ,
@@ -19,18 +18,22 @@ import * as eg from '../../__tests__/lib/exampleData';
19
18
describe ( 'sessionReducer' , ( ) => {
20
19
const baseState = eg . baseReduxState . session ;
21
20
22
- test ( 'ACCOUNT_SWITCH' , ( ) => {
23
- const state = deepFreeze ( {
24
- ...baseState ,
25
- loading : true ,
26
- } ) ;
27
- const newState = sessionReducer ( state , eg . action . account_switch ) ;
28
- expect ( newState ) . toEqual ( { ...baseState , ...initialPerAccountSessionState } ) ;
29
- } ) ;
21
+ describe ( 'RESET_ACCOUNT_DATA' , ( ) => {
22
+ test ( 'resets per-account state without touching global state' , ( ) => {
23
+ const prevState = [
24
+ // per-account
25
+ eg . action . register_complete ,
26
+ { type : DISMISS_SERVER_COMPAT_NOTICE } ,
30
27
31
- test ( 'LOGIN_SUCCESS' , ( ) => {
32
- const newState = sessionReducer ( baseState , eg . action . login_success ) ;
33
- expect ( newState ) . toEqual ( { ...baseState , ...initialPerAccountSessionState } ) ;
28
+ // global
29
+ { type : GOT_PUSH_TOKEN , pushToken : '456' } ,
30
+ { type : APP_ORIENTATION , orientation : 'LANDSCAPE' } ,
31
+ ] . reduce ( sessionReducer , eg . baseReduxState . session ) ;
32
+ expect ( sessionReducer ( prevState , eg . action . reset_account_data ) ) . toEqual ( {
33
+ ...prevState ,
34
+ ...initialPerAccountSessionState ,
35
+ } ) ;
36
+ } ) ;
34
37
} ) ;
35
38
36
39
test ( 'DEAD_QUEUE' , ( ) => {
@@ -39,18 +42,6 @@ describe('sessionReducer', () => {
39
42
expect ( newState ) . toEqual ( { ...baseState , loading : false } ) ;
40
43
} ) ;
41
44
42
- test ( 'LOGOUT' , ( ) => {
43
- const state = deepFreeze ( {
44
- ...baseState ,
45
- loading : true ,
46
- } ) ;
47
- const newState = sessionReducer ( state , deepFreeze ( { type : LOGOUT } ) ) ;
48
- expect ( newState ) . toEqual ( {
49
- ...baseState ,
50
- ...initialPerAccountSessionState ,
51
- } ) ;
52
- } ) ;
53
-
54
45
test ( 'REGISTER_COMPLETE' , ( ) => {
55
46
const state = deepFreeze ( { ...baseState , loading : true } ) ;
56
47
const action = eg . mkActionRegisterComplete ( { queue_id : '100' } ) ;
0 commit comments