UNPKG

react-native-twopane-navigation

Version:

React Native package for dual screen devices navigation support (Surface Duo)

2 lines 15 kB
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _appStore=require("../../../../appStore");var _keyMethods=require("./key.methods.helpers");var _interfaces=require("../../../../utilities/interfaces");var _key=require("../key.actions");describe('keyStore tests',function(){beforeEach(function(){_appStore.store.dispatch((0,_appStore.resetApp)());});describe('onePane',function(){it('PUSH_KEY',function(){var expectedState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.ONE,false,_interfaces.paneType.ONE+"_");_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"first",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"second",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"third",false));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedState);});it('PUSH_KEY_EXPECT_DUPLICATION',function(){var original=(0,_keyMethods.mockKeyState)(_interfaces.paneType.ONE,false,_interfaces.paneType.ONE+"_");var duplicate=(0,_keyMethods.mockKeyState)(_interfaces.paneType.ONE,false,_interfaces.paneType.ONE+"_");var expectedState={keys:[].concat((0,_toConsumableArray2.default)(original.keys),(0,_toConsumableArray2.default)(duplicate.keys))};_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"first",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"second",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"third",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"first",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"second",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.ONE,"third",false));var data=_appStore.store.getState().KeyReducers;expect(data).toEqual(expectedState);});it('POP_TO_FRONT_KEY',function(){var expectedState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);_appStore.store.dispatch((0,_key.popToFront)(_interfaces.paneType.ONE));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedState);});it('POP_TO_FRONT_KEY twoPane untouched',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE)]};var expectedTWOState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.TWO,false,_interfaces.paneType.TWO+"_");(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popToFront)(_interfaces.paneType.ONE));var data=_appStore.store.getState().KeyReducers;var onePaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.ONE;});var twoPaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.TWO;});expect(onePaneState).toStrictEqual(expectedONEState.keys);expect(twoPaneState).toStrictEqual(expectedTWOState.keys);});it('POP_KEY',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_second",false,_interfaces.paneType.ONE)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedONEState);});it('POP_KEY Multiple',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedONEState);});it('POP_KEY twoPane untouched',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_second",false,_interfaces.paneType.ONE)]};var expectedTWOState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.TWO,false,_interfaces.paneType.TWO+"_");(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.ONE));var data=_appStore.store.getState().KeyReducers;var onePaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.ONE;});var twoPaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.TWO;});expect(onePaneState).toStrictEqual(expectedONEState.keys);expect(twoPaneState).toStrictEqual(expectedTWOState.keys);});it('MOVE_TO_FRONT_KEY',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_second",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_third",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);_appStore.store.dispatch((0,_key.moveToFront)(_interfaces.paneType.ONE,_interfaces.paneType.ONE+"_first"));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedONEState);});it('MOVE_TO_FRONT_KEY twoPane untouched',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_second",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_third",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE)]};var expectedTWOState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.TWO,false,_interfaces.paneType.TWO+"_");(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.moveToFront)(_interfaces.paneType.ONE,_interfaces.paneType.ONE+"_first"));var data=_appStore.store.getState().KeyReducers;var onePaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.ONE;});var twoPaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.TWO;});expect(onePaneState).toStrictEqual(expectedONEState.keys);expect(twoPaneState).toStrictEqual(expectedTWOState.keys);});it('CHANGE_SCREEN_KEY',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_first",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_second",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.ONE+"_third",false,_interfaces.paneType.ONE)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);_appStore.store.dispatch((0,_key.changeScreen)(_interfaces.paneType.TWO,_interfaces.paneType.ONE+"_second"));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedONEState);});});describe('twoPane',function(){it('PUSH_KEY',function(){var expectedState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.TWO,false,_interfaces.paneType.TWO+"_");_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"first",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"second",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"third",false));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedState);});it('PUSH_KEY_EXPECT_DUPLICATION',function(){var original=(0,_keyMethods.mockKeyState)(_interfaces.paneType.TWO,false,_interfaces.paneType.TWO+"_");var duplicate=(0,_keyMethods.mockKeyState)(_interfaces.paneType.TWO,false,_interfaces.paneType.TWO+"_");var expectedState={keys:[].concat((0,_toConsumableArray2.default)(original.keys),(0,_toConsumableArray2.default)(duplicate.keys))};_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"first",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"second",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"third",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"first",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"second",false));_appStore.store.dispatch((0,_key.pushKey)(_interfaces.paneType.TWO,"third",false));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedState);});it('POP_TO_FRONT_KEY',function(){var expectedState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popToFront)(_interfaces.paneType.TWO));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedState);});it('POP_TO_FRONT_KEY onePane untouched',function(){var expectedONEState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.ONE,false,_interfaces.paneType.ONE+"_");var expectedTWOState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popToFront)(_interfaces.paneType.TWO));var data=_appStore.store.getState().KeyReducers;var onePaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.ONE;});var twoPaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.TWO;});expect(onePaneState).toStrictEqual(expectedONEState.keys);expect(twoPaneState).toStrictEqual(expectedTWOState.keys);});it('POP_KEY',function(){var expectedTWOState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_second",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedTWOState);});it('POP_KEY Multiple',function(){var expectedTWOState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedTWOState);});it('POP_KEY onePane untouched',function(){var expectedONEState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.ONE,false,_interfaces.paneType.ONE+"_");var expectedTWOState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_second",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.popScreen)(_interfaces.paneType.TWO));var data=_appStore.store.getState().KeyReducers;var onePaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.ONE;});var twoPaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.TWO;});expect(onePaneState).toStrictEqual(expectedONEState.keys);expect(twoPaneState).toStrictEqual(expectedTWOState.keys);});it('MOVE_TO_FRONT_KEY',function(){var expectedTWOState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_second",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_third",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.moveToFront)(_interfaces.paneType.TWO,_interfaces.paneType.TWO+"_first"));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedTWOState);});it('MOVE_TO_FRONT_KEY onePane untouched',function(){var expectedTWOState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_second",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_third",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO)]};var expectedONEState=(0,_keyMethods.mockKeyState)(_interfaces.paneType.ONE,false,_interfaces.paneType.ONE+"_");(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.ONE,false);(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.moveToFront)(_interfaces.paneType.TWO,_interfaces.paneType.TWO+"_first"));var data=_appStore.store.getState().KeyReducers;var onePaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.ONE;});var twoPaneState=data.keys.filter(function(x){return x.screen===_interfaces.paneType.TWO;});expect(onePaneState).toStrictEqual(expectedONEState.keys);expect(twoPaneState).toStrictEqual(expectedTWOState.keys);});it('CHANGE_SCREEN_KEY',function(){var expectedONEState={keys:[(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_first",false,_interfaces.paneType.TWO),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_second",false,_interfaces.paneType.ONE),(0,_keyMethods.keyObjectBuilder)(_interfaces.paneType.TWO+"_third",false,_interfaces.paneType.TWO)]};(0,_keyMethods.populateKeyStore3)(_interfaces.paneType.TWO,false);_appStore.store.dispatch((0,_key.changeScreen)(_interfaces.paneType.ONE,_interfaces.paneType.TWO+"_second"));var data=_appStore.store.getState().KeyReducers;expect(data).toStrictEqual(expectedONEState);});});}); //# sourceMappingURL=key.test.js.map