11import * as mock from 'ringcentral-integration/integration-test/mock' ;
2- import presenceBody from 'ringcentral-integration/integration-test/mock/data/presence' ;
32import { getWrapper , timeout } from '../shared' ;
43import SettingsPanel from '../../src/components/SettingsPanel' ;
54import LinkLine from '../../src/components/LinkLine' ;
@@ -9,21 +8,19 @@ import PresenceItem from '../../src/components/PresenceItem';
98import Eula from '../../src/components/Eula' ;
109import NavigationBar from '../../src/components/NavigationBar' ;
1110
12- let wrapper = null ;
13- let store = null ;
14- let panel = null ;
15- beforeEach ( async ( ) => {
11+ const setupWrapper = async ( ) => {
1612 jasmine . DEFAULT_TIMEOUT_INTERVAL = 64000 ;
17- wrapper = await getWrapper ( ) ;
18- store = wrapper . props ( ) . phone . store ;
13+ const wrapper = await getWrapper ( ) ;
1914 const navigationBar = wrapper . find ( NavigationBar ) . first ( ) ;
2015 await navigationBar . props ( ) . goTo ( '/settings' ) ;
2116 wrapper . update ( ) ;
22- panel = wrapper . find ( SettingsPanel ) . first ( ) ;
23- } ) ;
17+ return wrapper ;
18+ } ;
2419
2520describe ( 'settings panel' , ( ) => {
26- test ( 'initial state' , ( ) => {
21+ test ( 'initial state' , async ( ) => {
22+ const wrapper = await setupWrapper ( ) ;
23+ let panel = wrapper . find ( SettingsPanel ) . first ( ) ;
2724 const linkLines = panel . find ( LinkLine ) ;
2825 expect ( linkLines . length ) . toBe ( 5 ) ;
2926 expect ( linkLines . at ( 0 ) . props ( ) . children ) . toEqual ( 'Calling' ) ;
@@ -36,21 +33,25 @@ describe('settings panel', () => {
3633 } ) ;
3734
3835 test ( 'logout' , async ( ) => {
36+ const storage = JSON . parse ( JSON . stringify ( localStorage . store ) ) ;
37+ const wrapper = await setupWrapper ( ) ;
38+ let panel = wrapper . find ( SettingsPanel ) . first ( ) ;
3939 const logoutIcon = panel . find ( 'span.logout' ) . first ( ) ;
4040 const logoutLines = logoutIcon . closest ( IconLine ) ;
4141 expect ( logoutLines . length ) . toBe ( 1 ) ;
4242 const logoutLine = logoutLines . at ( 0 ) ;
43+ const store = wrapper . props ( ) . phone . store ;
4344 expect ( store . getState ( ) . auth . loginStatus ) . toMatch ( / - l o g g e d I n $ / ) ;
4445 await logoutLine . props ( ) . onClick ( ) ;
4546 expect ( store . getState ( ) . auth . loginStatus ) . toMatch ( / - l o g g i n g O u t $ / ) ;
46-
47- // need to login again, otherwise other tests will fail
48- window . authData = null ; // set it to null will trigger login
47+ localStorage . store = JSON . parse ( JSON . stringify ( storage ) ) ;
4948 } ) ;
5049
5150 test ( 'change presence status' , async ( ) => {
51+ const wrapper = await setupWrapper ( ) ;
52+ let panel = wrapper . find ( SettingsPanel ) . first ( ) ;
5253 let presenceSettingSection = panel . find ( PresenceSettingSection ) . first ( ) ;
53-
54+ const store = wrapper . props ( ) . phone . store ;
5455 const presenceItems = presenceSettingSection . find ( '.presenceList' ) . first ( ) . find ( PresenceItem ) ;
5556 expect ( presenceItems . length ) . toBe ( 4 ) ;
5657 const availableItem = presenceItems . at ( 0 ) ;
0 commit comments