@react-navigation/core 3.5.0-alpha.6 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/navigators/__tests__/createSwitchnavigator-test.js +1 -1
- package/lib/commonjs/navigators/__tests__/createSwitchnavigator-test.js.map +1 -1
- package/lib/commonjs/navigators/createNavigator.js +1 -1
- package/lib/commonjs/navigators/createNavigator.js.map +1 -1
- package/lib/commonjs/routers/SwitchRouter.js +1 -1
- package/lib/commonjs/routers/SwitchRouter.js.map +1 -1
- package/lib/commonjs/routers/__tests__/PathHandling-test.js +1 -1
- package/lib/commonjs/routers/__tests__/PathHandling-test.js.map +1 -1
- package/lib/commonjs/routers/__tests__/Routers-test.js +1 -1
- package/lib/commonjs/routers/__tests__/Routers-test.js.map +1 -1
- package/lib/commonjs/routers/__tests__/StackRouter-test.js +1 -1
- package/lib/commonjs/routers/__tests__/StackRouter-test.js.map +1 -1
- package/lib/commonjs/routers/__tests__/SwitchRouter-test.js +1 -1
- package/lib/commonjs/routers/__tests__/SwitchRouter-test.js.map +1 -1
- package/lib/commonjs/routers/__tests__/TabRouter-test.js +1 -1
- package/lib/commonjs/routers/__tests__/TabRouter-test.js.map +1 -1
- package/lib/commonjs/routers/__tests__/pathUtils-test.js +1 -1
- package/lib/commonjs/routers/__tests__/pathUtils-test.js.map +1 -1
- package/lib/commonjs/routers/__tests__/validateRouteConfigMap-test.js +1 -1
- package/lib/commonjs/routers/__tests__/validateRouteConfigMap-test.js.map +1 -1
- package/lib/commonjs/routers/createConfigGetter.js +1 -1
- package/lib/commonjs/routers/createConfigGetter.js.map +1 -1
- package/lib/commonjs/routers/pathUtils.js +1 -1
- package/lib/commonjs/routers/pathUtils.js.map +1 -1
- package/lib/commonjs/useTheme.js +1 -1
- package/lib/commonjs/useTheme.js.map +1 -1
- package/lib/commonjs/utils/getActiveChildNavigationOptions.js +1 -1
- package/lib/commonjs/utils/getActiveChildNavigationOptions.js.map +1 -1
- package/lib/commonjs/views/SceneView.js +1 -1
- package/lib/commonjs/views/SceneView.js.map +1 -1
- package/lib/commonjs/views/SwitchView/SwitchView.js +1 -1
- package/lib/commonjs/views/SwitchView/SwitchView.js.map +1 -1
- package/lib/commonjs/views/__tests__/NavigationEvents-test.js +1 -1
- package/lib/commonjs/views/__tests__/NavigationEvents-test.js.map +1 -1
- package/lib/commonjs/views/withNavigation.js +1 -1
- package/lib/commonjs/views/withNavigation.js.map +1 -1
- package/lib/commonjs/views/withNavigationFocus.js +1 -1
- package/lib/commonjs/views/withNavigationFocus.js.map +1 -1
- package/lib/module/navigators/__tests__/createSwitchnavigator-test.js +1 -1
- package/lib/module/navigators/__tests__/createSwitchnavigator-test.js.map +1 -1
- package/lib/module/navigators/createNavigator.js +1 -1
- package/lib/module/navigators/createNavigator.js.map +1 -1
- package/lib/module/routers/SwitchRouter.js +1 -1
- package/lib/module/routers/SwitchRouter.js.map +1 -1
- package/lib/module/routers/__tests__/PathHandling-test.js +1 -1
- package/lib/module/routers/__tests__/PathHandling-test.js.map +1 -1
- package/lib/module/routers/__tests__/Routers-test.js +1 -1
- package/lib/module/routers/__tests__/Routers-test.js.map +1 -1
- package/lib/module/routers/__tests__/StackRouter-test.js +1 -1
- package/lib/module/routers/__tests__/StackRouter-test.js.map +1 -1
- package/lib/module/routers/__tests__/SwitchRouter-test.js +1 -1
- package/lib/module/routers/__tests__/SwitchRouter-test.js.map +1 -1
- package/lib/module/routers/__tests__/TabRouter-test.js +1 -1
- package/lib/module/routers/__tests__/TabRouter-test.js.map +1 -1
- package/lib/module/routers/__tests__/pathUtils-test.js +1 -1
- package/lib/module/routers/__tests__/pathUtils-test.js.map +1 -1
- package/lib/module/routers/__tests__/validateRouteConfigMap-test.js +1 -1
- package/lib/module/routers/__tests__/validateRouteConfigMap-test.js.map +1 -1
- package/lib/module/routers/createConfigGetter.js +1 -1
- package/lib/module/routers/createConfigGetter.js.map +1 -1
- package/lib/module/routers/pathUtils.js +1 -1
- package/lib/module/routers/pathUtils.js.map +1 -1
- package/lib/module/useTheme.js +1 -1
- package/lib/module/useTheme.js.map +1 -1
- package/lib/module/utils/getActiveChildNavigationOptions.js +1 -1
- package/lib/module/utils/getActiveChildNavigationOptions.js.map +1 -1
- package/lib/module/views/SceneView.js +1 -1
- package/lib/module/views/SceneView.js.map +1 -1
- package/lib/module/views/SwitchView/SwitchView.js +1 -1
- package/lib/module/views/SwitchView/SwitchView.js.map +1 -1
- package/lib/module/views/__tests__/NavigationEvents-test.js +1 -1
- package/lib/module/views/__tests__/NavigationEvents-test.js.map +1 -1
- package/lib/module/views/withNavigation.js +1 -1
- package/lib/module/views/withNavigation.js.map +1 -1
- package/lib/module/views/withNavigationFocus.js +1 -1
- package/lib/module/views/withNavigationFocus.js.map +1 -1
- package/lib/typescript/useTheme.d.ts +1 -1
- package/package.json +1 -1
- package/src/navigators/createNavigator.js +35 -16
- package/src/routers/SwitchRouter.js +13 -11
- package/src/routers/__tests__/pathUtils-test.js +37 -1
- package/src/routers/createConfigGetter.js +3 -2
- package/src/routers/pathUtils.js +16 -5
- package/src/useTheme.ts +1 -1
- package/src/utils/getActiveChildNavigationOptions.js +6 -2
- package/src/.DS_Store +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Routers-test.js"],"names":["React","StackRouter","TabRouter","SwitchRouter","NavigationActions","StackActions","_TESTING_ONLY_normalize_keys","beforeEach","ROUTERS","dummyEventSubscriber","remove","Object","keys","forEach","routerName","Router","describe","it","FooView","Component","BarView","navigationOptions","title","BazView","navigation","state","params","id","router","Foo","screen","Bar","Baz","routes","key","routeName","expect","getScreenOptions","dispatch","addListener","toEqual","undefined","initState","getStateForAction","init","initRoute","index","state0","setParams","foo","Leaf","First","First1","First2","Second","Second1","Second2","Main","TestRouter","Login","state1","type","INIT","state2","NAVIGATE","state3","state4","action","state5","FooTabNavigator","Zap","Zoo","expectedState","isTransitioning","immediate","Boo","SET_PARAMS","name","getScreen","FooStackNavigator","stateAfterCompleteTransition","COMPLETE_TRANSITION","preserveFocus","stateAfterSetParams","PlainScreen","ScreenA","ScreenB","screenApreState","preState","comparable","result","Array","map","navigate","innerState"],"mappings":"0fAEA,MAAOA,CAAAA,KAAP,KAAkB,OAAlB,CAEA,MAAOC,CAAAA,WAAP,KAAwB,gBAAxB,CACA,MAAOC,CAAAA,SAAP,KAAsB,cAAtB,CACA,MAAOC,CAAAA,YAAP,KAAyB,iBAAzB,CAEA,MAAO,GAAKC,CAAAA,iBAAZ,KAAmC,yBAAnC,CACA,MAAO,GAAKC,CAAAA,YAAZ,KAA8B,iBAA9B,CACA,OAASC,4BAAT,KAA6C,oBAA7C,CAEAC,UAAU,CAAC,UAAM,CACfD,4BAA4B,GAC7B,CAFS,CAAV,CAIA,GAAME,CAAAA,OAAO,CAAG,CACdN,SAAS,CAATA,SADc,CAEdD,WAAW,CAAXA,WAFc,CAGdE,YAAY,CAAZA,YAHc,CAAhB,CAMA,GAAMM,CAAAA,oBAAoB,CAAG,QAAvBA,CAAAA,oBAAuB,SAAO,CAClCC,MAAM,CAAE,iBAAM,CAAE,CADkB,CAAP,EAA7B,CAIAC,MAAM,CAACC,IAAP,CAAYJ,OAAZ,EAAqBK,OAArB,CAA6B,SAAAC,UAAU,CAAI,CACzC,GAAMC,CAAAA,MAAM,CAAGP,OAAO,CAACM,UAAD,CAAtB,CAEAE,QAAQ,8BAA8BF,UAA9B,CAA4C,UAAM,CACxDG,EAAE,yEAAyEH,UAAzE,CAAuF,UAAM,IACvFI,CAAAA,OADuF,oQAElF,CACP,MAAO,4EAAP,CACD,CAJ0F,qBACvElB,KAAK,CAACmB,SADiE,KAMvFC,CAAAA,OANuF,sQAOlF,CACP,MAAO,4EAAP,CACD,CAT0F,qBAMvEpB,KAAK,CAACmB,SANiE,EAMvFC,OANuF,CAUpFC,iBAVoF,CAUhE,CAAEC,KAAK,CAAE,UAAT,CAVgE,IAYvFC,CAAAA,OAZuF,sQAalF,CACP,MAAO,4EA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D,UAAU,EAAIL,UAAU,CAACK,UAAD,CAD1B,EAGD,CAzDC,CAAF","sourcesContent":["/* eslint react/no-multi-comp:0, react/display-name:0 */\n\nimport React from 'react';\n\nimport StackRouter from '../StackRouter';\nimport TabRouter from '../TabRouter';\nimport SwitchRouter from '../SwitchRouter';\n\nimport * as NavigationActions from '../../NavigationActions';\nimport * as StackActions from '../StackActions';\nimport { _TESTING_ONLY_normalize_keys } from '../KeyGenerator.ts';\n\nbeforeEach(() => {\n _TESTING_ONLY_normalize_keys();\n});\n\nconst ROUTERS = {\n TabRouter,\n StackRouter,\n SwitchRouter,\n};\n\nconst dummyEventSubscriber = () => ({\n remove: () => {},\n});\n\nObject.keys(ROUTERS).forEach(routerName => {\n const Router = ROUTERS[routerName];\n\n describe(`General router features - ${routerName}`, () => {\n it(`title is configurable using navigationOptions and getScreenOptions - ${routerName}`, () => {\n class FooView extends React.Component {\n render() {\n return <div />;\n }\n }\n class BarView extends React.Component {\n render() {\n return <div />;\n }\n static navigationOptions = { title: 'BarTitle' };\n }\n class BazView extends React.Component {\n render() {\n return <div />;\n }\n static navigationOptions = ({ navigation }) => ({\n title: `Baz-${navigation.state.params.id}`,\n });\n }\n const router = Router({\n Foo: { screen: FooView },\n Bar: { screen: BarView },\n Baz: { screen: BazView },\n });\n const routes = [\n { key: 'A', routeName: 'Foo' },\n { key: 'B', routeName: 'Bar' },\n { key: 'A', routeName: 'Baz', params: { id: '123' } },\n ];\n expect(\n router.getScreenOptions(\n {\n state: routes[0],\n dispatch: () => false,\n addListener: dummyEventSubscriber,\n },\n {}\n ).title\n ).toEqual(undefined);\n expect(\n router.getScreenOptions(\n {\n state: routes[1],\n dispatch: () => false,\n addListener: dummyEventSubscriber,\n },\n {}\n ).title\n ).toEqual('BarTitle');\n expect(\n router.getScreenOptions(\n {\n state: routes[2],\n dispatch: () => false,\n addListener: dummyEventSubscriber,\n },\n {}\n ).title\n ).toEqual('Baz-123');\n });\n\n it(`set params works in ${routerName}`, () => {\n class FooView extends React.Component {\n render() {\n return <div />;\n }\n }\n const router = Router({\n Foo: { screen: FooView },\n Bar: { screen: FooView },\n });\n\n const initState = router.getStateForAction(NavigationActions.init());\n const initRoute = initState.routes[initState.index];\n expect(initRoute.params).toEqual(undefined);\n\n const state0 = router.getStateForAction(\n NavigationActions.setParams({\n params: { foo: 42 },\n key: initRoute.key,\n }),\n initState\n );\n expect(state0.routes[state0.index].params.foo).toEqual(42);\n });\n });\n});\n\nit('Nested navigate behavior test', () => {\n const Leaf = () => <div />;\n\n const First = () => <div />;\n First.router = StackRouter({\n First1: Leaf,\n First2: Leaf,\n });\n\n const Second = () => <div />;\n Second.router = StackRouter({\n Second1: Leaf,\n Second2: Leaf,\n });\n\n const Main = () => <div />;\n Main.router = StackRouter({\n First,\n Second,\n });\n const TestRouter = SwitchRouter({\n Login: Leaf,\n Main,\n });\n\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n\n const state2 = TestRouter.getStateForAction(\n { type: NavigationActions.NAVIGATE, routeName: 'First' },\n state1\n );\n expect(state2.index).toEqual(1);\n expect(state2.routes[1].index).toEqual(0);\n expect(state2.routes[1].routes[0].index).toEqual(0);\n\n const state3 = TestRouter.getStateForAction(\n { type: NavigationActions.NAVIGATE, routeName: 'Second2' },\n state2\n );\n expect(state3.index).toEqual(1);\n expect(state3.routes[1].index).toEqual(1); // second\n expect(state3.routes[1].routes[1].index).toEqual(1); //second.second2\n\n const state4 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'First',\n action: { type: NavigationActions.NAVIGATE, routeName: 'First2' },\n },\n state3,\n true\n );\n expect(state4.index).toEqual(1); // main\n expect(state4.routes[1].index).toEqual(0); // first\n expect(state4.routes[1].routes[0].index).toEqual(1); // first2\n\n const state5 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'First',\n action: { type: NavigationActions.NAVIGATE, routeName: 'First1' },\n },\n state3 // second.second2 is active on state3\n );\n expect(state5.index).toEqual(1); // main\n expect(state5.routes[1].index).toEqual(0); // first\n expect(state5.routes[1].routes[0].index).toEqual(0); // first.first1\n});\n\nit('Handles no-op actions with tabs within stack router', () => {\n const BarView = () => <div />;\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Zap: { screen: BarView },\n Zoo: { screen: BarView },\n });\n const TestRouter = StackRouter({\n Foo: {\n screen: FooTabNavigator,\n },\n Bar: {\n screen: BarView,\n },\n });\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction({\n type: NavigationActions.NAVIGATE,\n routeName: 'Qux',\n });\n expect(state1.routes[0].key).toEqual('id-0');\n expect(state2.routes[0].key).toEqual('id-1');\n state1.routes[0].key = state2.routes[0].key;\n expect(state1).toEqual(state2);\n const state3 = TestRouter.getStateForAction(\n { type: NavigationActions.NAVIGATE, routeName: 'Zap' },\n state2\n );\n expect(state2).toEqual(state3);\n});\n\nit('Handles deep action', () => {\n const BarView = () => <div />;\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Zap: { screen: BarView },\n Zoo: { screen: BarView },\n });\n const TestRouter = StackRouter({\n Bar: { screen: BarView },\n Foo: { screen: FooTabNavigator },\n });\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const expectedState = {\n index: 0,\n isTransitioning: false,\n key: 'StackRouterRoot',\n routes: [\n {\n key: 'id-0',\n routeName: 'Bar',\n },\n ],\n };\n expect(state1).toEqual(expectedState);\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'Foo',\n immediate: true,\n action: { type: NavigationActions.NAVIGATE, routeName: 'Zoo' },\n },\n state1\n );\n expect(state2 && state2.index).toEqual(1);\n expect(state2 && state2.routes[1].index).toEqual(1);\n});\n\nit('Handles the navigate action with params', () => {\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Baz: { screen: () => <div /> },\n Boo: { screen: () => <div /> },\n });\n\n const TestRouter = StackRouter({\n Foo: { screen: () => <div /> },\n Bar: { screen: FooTabNavigator },\n });\n const state = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n immediate: true,\n routeName: 'Bar',\n params: { foo: '42' },\n },\n state\n );\n expect(state2 && state2.routes[1].params).toEqual({ foo: '42' });\n expect(state2 && state2.routes[1].routes).toEqual([\n {\n key: 'Baz',\n routeName: 'Baz',\n params: { foo: '42' },\n },\n {\n key: 'Boo',\n routeName: 'Boo',\n params: { foo: '42' },\n },\n ]);\n});\n\nit('Handles the setParams action', () => {\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Baz: { screen: () => <div /> },\n });\n const TestRouter = StackRouter({\n Foo: { screen: FooTabNavigator },\n Bar: { screen: () => <div /> },\n });\n const state = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.SET_PARAMS,\n params: { name: 'foobar' },\n key: 'Baz',\n },\n state\n );\n expect(state2 && state2.index).toEqual(0);\n expect(state2 && state2.routes[0].routes).toEqual([\n {\n key: 'Baz',\n routeName: 'Baz',\n params: { name: 'foobar' },\n },\n ]);\n});\n\nit('Supports lazily-evaluated getScreen', () => {\n const BarView = () => <div />;\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Zap: { screen: BarView },\n Zoo: { screen: BarView },\n });\n const TestRouter = StackRouter({\n Foo: {\n screen: FooTabNavigator,\n },\n Bar: {\n getScreen: () => BarView,\n },\n });\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction({\n type: NavigationActions.NAVIGATE,\n immediate: true,\n routeName: 'Qux',\n });\n expect(state1.routes[0].key).toEqual('id-0');\n expect(state2.routes[0].key).toEqual('id-1');\n state1.routes[0].key = state2.routes[0].key;\n expect(state1).toEqual(state2);\n const state3 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n immediate: true,\n routeName: 'Zap',\n },\n state2\n );\n expect(state2).toEqual(state3);\n});\n\nit('Does not switch tab index when TabRouter child handles COMPLETE_NAVIGATION or SET_PARAMS', () => {\n const FooStackNavigator = () => <div />;\n const BarView = () => <div />;\n FooStackNavigator.router = StackRouter({\n Foo: {\n screen: BarView,\n },\n Bar: {\n screen: BarView,\n },\n });\n\n const TestRouter = TabRouter({\n Zap: { screen: FooStackNavigator },\n Zoo: { screen: FooStackNavigator },\n });\n\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n\n // Navigate to the second screen in the first tab\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'Bar',\n },\n state1\n );\n\n // Switch tabs\n const state3 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'Zoo',\n },\n state2\n );\n\n const stateAfterCompleteTransition = TestRouter.getStateForAction(\n {\n type: StackActions.COMPLETE_TRANSITION,\n preserveFocus: true,\n key: state2.routes[0].key,\n },\n state3\n );\n const stateAfterSetParams = TestRouter.getStateForAction(\n {\n type: NavigationActions.SET_PARAMS,\n preserveFocus: true,\n key: state1.routes[0].routes[0].key,\n params: { key: 'value' },\n },\n state3\n );\n\n expect(stateAfterCompleteTransition.index).toEqual(1);\n expect(stateAfterSetParams.index).toEqual(1);\n});\n\nit('Inner actions are only unpacked if the current tab matches', () => {\n const PlainScreen = () => <div />;\n const ScreenA = () => <div />;\n const ScreenB = () => <div />;\n ScreenB.router = StackRouter({\n Baz: { screen: PlainScreen },\n Zoo: { screen: PlainScreen },\n });\n ScreenA.router = StackRouter({\n Bar: { screen: PlainScreen },\n Boo: { screen: ScreenB },\n });\n const TestRouter = TabRouter({\n Foo: { screen: ScreenA },\n });\n const screenApreState = {\n index: 0,\n key: 'Init',\n isTransitioning: false,\n routeName: 'Foo',\n routes: [{ key: 'Init', routeName: 'Bar' }],\n };\n const preState = {\n index: 0,\n isTransitioning: false,\n routes: [screenApreState],\n };\n\n const comparable = state => {\n let result = {};\n if (typeof state.routeName === 'string') {\n result = { ...result, routeName: state.routeName };\n }\n if (state.routes instanceof Array) {\n result = {\n ...result,\n routes: state.routes.map(comparable),\n };\n }\n return result;\n };\n\n const action = NavigationActions.navigate({\n routeName: 'Boo',\n action: NavigationActions.navigate({ routeName: 'Zoo' }),\n });\n\n const expectedState = ScreenA.router.getStateForAction(\n action,\n screenApreState\n );\n const state = TestRouter.getStateForAction(action, preState);\n const innerState = state ? state.routes[0] : state;\n\n expect(expectedState && comparable(expectedState)).toEqual(\n innerState && comparable(innerState)\n );\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["Routers-test.js"],"names":["React","StackRouter","TabRouter","SwitchRouter","NavigationActions","StackActions","_TESTING_ONLY_normalize_keys","beforeEach","ROUTERS","dummyEventSubscriber","remove","Object","keys","forEach","routerName","Router","describe","it","FooView","Component","BarView","navigationOptions","title","BazView","navigation","state","params","id","router","Foo","screen","Bar","Baz","routes","key","routeName","expect","getScreenOptions","dispatch","addListener","toEqual","undefined","initState","getStateForAction","init","initRoute","index","state0","setParams","foo","Leaf","First","First1","First2","Second","Second1","Second2","Main","TestRouter","Login","state1","type","INIT","state2","NAVIGATE","state3","state4","action","state5","FooTabNavigator","Zap","Zoo","expectedState","isTransitioning","immediate","Boo","SET_PARAMS","name","getScreen","FooStackNavigator","stateAfterCompleteTransition","COMPLETE_TRANSITION","preserveFocus","stateAfterSetParams","PlainScreen","ScreenA","ScreenB","screenApreState","preState","comparable","result","Array","map","navigate","innerState"],"mappings":"kgBAEA,MAAOA,CAAAA,KAAP,KAAkB,OAAlB,CAEA,MAAOC,CAAAA,WAAP,KAAwB,gBAAxB,CACA,MAAOC,CAAAA,SAAP,KAAsB,cAAtB,CACA,MAAOC,CAAAA,YAAP,KAAyB,iBAAzB,CAEA,MAAO,GAAKC,CAAAA,iBAAZ,KAAmC,yBAAnC,CACA,MAAO,GAAKC,CAAAA,YAAZ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,MAAR,EAAgBvD,SAAS,CAAEV,KAAK,CAACU,SAAjC,EAAN,CACD,CACD,GAAIV,KAAK,CAACQ,MAAN,WAAwB0D,CAAAA,KAA5B,CAAmC,CACjCD,MAAM,kBACDA,MADC,EAEJzD,MAAM,CAAER,KAAK,CAACQ,MAAN,CAAa2D,GAAb,CAAiBH,UAAjB,CAFJ,EAAN,CAID,CACD,MAAOC,CAAAA,MAAP,CACD,CAZD,CAcA,GAAMvB,CAAAA,MAAM,CAAG/D,iBAAiB,CAACyF,QAAlB,CAA2B,CACxC1D,SAAS,CAAE,KAD6B,CAExCgC,MAAM,CAAE/D,iBAAiB,CAACyF,QAAlB,CAA2B,CAAE1D,SAAS,CAAE,KAAb,CAA3B,CAFgC,CAA3B,CAAf,CAKA,GAAMqC,CAAAA,aAAa,CAAGa,OAAO,CAACzD,MAAR,CAAee,iBAAf,CACpBwB,MADoB,CAEpBoB,eAFoB,CAAtB,CAIA,GAAM9D,CAAAA,KAAK,CAAGiC,UAAU,CAACf,iBAAX,CAA6BwB,MAA7B,CAAqCqB,QAArC,CAAd,CACA,GAAMM,CAAAA,UAAU,CAAGrE,KAAK,CAAGA,KAAK,CAACQ,MAAN,CAAa,CAAb,CAAH,CAAqBR,KAA7C,CAEAW,MAAM,CAACoC,aAAa,EAAIiB,UAAU,CAACjB,aAAD,CAA5B,CAAN,CAAmDhC,OAAnD,CACEsD,UAAU,EAAIL,UAAU,CAACK,UAAD,CAD1B,EAGD,CAzDC,CAAF","sourcesContent":["/* eslint react/no-multi-comp:0, react/display-name:0 */\n\nimport React from 'react';\n\nimport StackRouter from '../StackRouter';\nimport TabRouter from '../TabRouter';\nimport SwitchRouter from '../SwitchRouter';\n\nimport * as NavigationActions from '../../NavigationActions';\nimport * as StackActions from '../StackActions';\nimport { _TESTING_ONLY_normalize_keys } from '../KeyGenerator.ts';\n\nbeforeEach(() => {\n _TESTING_ONLY_normalize_keys();\n});\n\nconst ROUTERS = {\n TabRouter,\n StackRouter,\n SwitchRouter,\n};\n\nconst dummyEventSubscriber = () => ({\n remove: () => {},\n});\n\nObject.keys(ROUTERS).forEach(routerName => {\n const Router = ROUTERS[routerName];\n\n describe(`General router features - ${routerName}`, () => {\n it(`title is configurable using navigationOptions and getScreenOptions - ${routerName}`, () => {\n class FooView extends React.Component {\n render() {\n return <div />;\n }\n }\n class BarView extends React.Component {\n render() {\n return <div />;\n }\n static navigationOptions = { title: 'BarTitle' };\n }\n class BazView extends React.Component {\n render() {\n return <div />;\n }\n static navigationOptions = ({ navigation }) => ({\n title: `Baz-${navigation.state.params.id}`,\n });\n }\n const router = Router({\n Foo: { screen: FooView },\n Bar: { screen: BarView },\n Baz: { screen: BazView },\n });\n const routes = [\n { key: 'A', routeName: 'Foo' },\n { key: 'B', routeName: 'Bar' },\n { key: 'A', routeName: 'Baz', params: { id: '123' } },\n ];\n expect(\n router.getScreenOptions(\n {\n state: routes[0],\n dispatch: () => false,\n addListener: dummyEventSubscriber,\n },\n {}\n ).title\n ).toEqual(undefined);\n expect(\n router.getScreenOptions(\n {\n state: routes[1],\n dispatch: () => false,\n addListener: dummyEventSubscriber,\n },\n {}\n ).title\n ).toEqual('BarTitle');\n expect(\n router.getScreenOptions(\n {\n state: routes[2],\n dispatch: () => false,\n addListener: dummyEventSubscriber,\n },\n {}\n ).title\n ).toEqual('Baz-123');\n });\n\n it(`set params works in ${routerName}`, () => {\n class FooView extends React.Component {\n render() {\n return <div />;\n }\n }\n const router = Router({\n Foo: { screen: FooView },\n Bar: { screen: FooView },\n });\n\n const initState = router.getStateForAction(NavigationActions.init());\n const initRoute = initState.routes[initState.index];\n expect(initRoute.params).toEqual(undefined);\n\n const state0 = router.getStateForAction(\n NavigationActions.setParams({\n params: { foo: 42 },\n key: initRoute.key,\n }),\n initState\n );\n expect(state0.routes[state0.index].params.foo).toEqual(42);\n });\n });\n});\n\nit('Nested navigate behavior test', () => {\n const Leaf = () => <div />;\n\n const First = () => <div />;\n First.router = StackRouter({\n First1: Leaf,\n First2: Leaf,\n });\n\n const Second = () => <div />;\n Second.router = StackRouter({\n Second1: Leaf,\n Second2: Leaf,\n });\n\n const Main = () => <div />;\n Main.router = StackRouter({\n First,\n Second,\n });\n const TestRouter = SwitchRouter({\n Login: Leaf,\n Main,\n });\n\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n\n const state2 = TestRouter.getStateForAction(\n { type: NavigationActions.NAVIGATE, routeName: 'First' },\n state1\n );\n expect(state2.index).toEqual(1);\n expect(state2.routes[1].index).toEqual(0);\n expect(state2.routes[1].routes[0].index).toEqual(0);\n\n const state3 = TestRouter.getStateForAction(\n { type: NavigationActions.NAVIGATE, routeName: 'Second2' },\n state2\n );\n expect(state3.index).toEqual(1);\n expect(state3.routes[1].index).toEqual(1); // second\n expect(state3.routes[1].routes[1].index).toEqual(1); //second.second2\n\n const state4 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'First',\n action: { type: NavigationActions.NAVIGATE, routeName: 'First2' },\n },\n state3,\n true\n );\n expect(state4.index).toEqual(1); // main\n expect(state4.routes[1].index).toEqual(0); // first\n expect(state4.routes[1].routes[0].index).toEqual(1); // first2\n\n const state5 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'First',\n action: { type: NavigationActions.NAVIGATE, routeName: 'First1' },\n },\n state3 // second.second2 is active on state3\n );\n expect(state5.index).toEqual(1); // main\n expect(state5.routes[1].index).toEqual(0); // first\n expect(state5.routes[1].routes[0].index).toEqual(0); // first.first1\n});\n\nit('Handles no-op actions with tabs within stack router', () => {\n const BarView = () => <div />;\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Zap: { screen: BarView },\n Zoo: { screen: BarView },\n });\n const TestRouter = StackRouter({\n Foo: {\n screen: FooTabNavigator,\n },\n Bar: {\n screen: BarView,\n },\n });\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction({\n type: NavigationActions.NAVIGATE,\n routeName: 'Qux',\n });\n expect(state1.routes[0].key).toEqual('id-0');\n expect(state2.routes[0].key).toEqual('id-1');\n state1.routes[0].key = state2.routes[0].key;\n expect(state1).toEqual(state2);\n const state3 = TestRouter.getStateForAction(\n { type: NavigationActions.NAVIGATE, routeName: 'Zap' },\n state2\n );\n expect(state2).toEqual(state3);\n});\n\nit('Handles deep action', () => {\n const BarView = () => <div />;\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Zap: { screen: BarView },\n Zoo: { screen: BarView },\n });\n const TestRouter = StackRouter({\n Bar: { screen: BarView },\n Foo: { screen: FooTabNavigator },\n });\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const expectedState = {\n index: 0,\n isTransitioning: false,\n key: 'StackRouterRoot',\n routes: [\n {\n key: 'id-0',\n routeName: 'Bar',\n },\n ],\n };\n expect(state1).toEqual(expectedState);\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'Foo',\n immediate: true,\n action: { type: NavigationActions.NAVIGATE, routeName: 'Zoo' },\n },\n state1\n );\n expect(state2 && state2.index).toEqual(1);\n expect(state2 && state2.routes[1].index).toEqual(1);\n});\n\nit('Handles the navigate action with params', () => {\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Baz: { screen: () => <div /> },\n Boo: { screen: () => <div /> },\n });\n\n const TestRouter = StackRouter({\n Foo: { screen: () => <div /> },\n Bar: { screen: FooTabNavigator },\n });\n const state = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n immediate: true,\n routeName: 'Bar',\n params: { foo: '42' },\n },\n state\n );\n expect(state2 && state2.routes[1].params).toEqual({ foo: '42' });\n expect(state2 && state2.routes[1].routes).toEqual([\n {\n key: 'Baz',\n routeName: 'Baz',\n params: { foo: '42' },\n },\n {\n key: 'Boo',\n routeName: 'Boo',\n params: { foo: '42' },\n },\n ]);\n});\n\nit('Handles the setParams action', () => {\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Baz: { screen: () => <div /> },\n });\n const TestRouter = StackRouter({\n Foo: { screen: FooTabNavigator },\n Bar: { screen: () => <div /> },\n });\n const state = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.SET_PARAMS,\n params: { name: 'foobar' },\n key: 'Baz',\n },\n state\n );\n expect(state2 && state2.index).toEqual(0);\n expect(state2 && state2.routes[0].routes).toEqual([\n {\n key: 'Baz',\n routeName: 'Baz',\n params: { name: 'foobar' },\n },\n ]);\n});\n\nit('Supports lazily-evaluated getScreen', () => {\n const BarView = () => <div />;\n const FooTabNavigator = () => <div />;\n FooTabNavigator.router = TabRouter({\n Zap: { screen: BarView },\n Zoo: { screen: BarView },\n });\n const TestRouter = StackRouter({\n Foo: {\n screen: FooTabNavigator,\n },\n Bar: {\n getScreen: () => BarView,\n },\n });\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n const state2 = TestRouter.getStateForAction({\n type: NavigationActions.NAVIGATE,\n immediate: true,\n routeName: 'Qux',\n });\n expect(state1.routes[0].key).toEqual('id-0');\n expect(state2.routes[0].key).toEqual('id-1');\n state1.routes[0].key = state2.routes[0].key;\n expect(state1).toEqual(state2);\n const state3 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n immediate: true,\n routeName: 'Zap',\n },\n state2\n );\n expect(state2).toEqual(state3);\n});\n\nit('Does not switch tab index when TabRouter child handles COMPLETE_NAVIGATION or SET_PARAMS', () => {\n const FooStackNavigator = () => <div />;\n const BarView = () => <div />;\n FooStackNavigator.router = StackRouter({\n Foo: {\n screen: BarView,\n },\n Bar: {\n screen: BarView,\n },\n });\n\n const TestRouter = TabRouter({\n Zap: { screen: FooStackNavigator },\n Zoo: { screen: FooStackNavigator },\n });\n\n const state1 = TestRouter.getStateForAction({ type: NavigationActions.INIT });\n\n // Navigate to the second screen in the first tab\n const state2 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'Bar',\n },\n state1\n );\n\n // Switch tabs\n const state3 = TestRouter.getStateForAction(\n {\n type: NavigationActions.NAVIGATE,\n routeName: 'Zoo',\n },\n state2\n );\n\n const stateAfterCompleteTransition = TestRouter.getStateForAction(\n {\n type: StackActions.COMPLETE_TRANSITION,\n preserveFocus: true,\n key: state2.routes[0].key,\n },\n state3\n );\n const stateAfterSetParams = TestRouter.getStateForAction(\n {\n type: NavigationActions.SET_PARAMS,\n preserveFocus: true,\n key: state1.routes[0].routes[0].key,\n params: { key: 'value' },\n },\n state3\n );\n\n expect(stateAfterCompleteTransition.index).toEqual(1);\n expect(stateAfterSetParams.index).toEqual(1);\n});\n\nit('Inner actions are only unpacked if the current tab matches', () => {\n const PlainScreen = () => <div />;\n const ScreenA = () => <div />;\n const ScreenB = () => <div />;\n ScreenB.router = StackRouter({\n Baz: { screen: PlainScreen },\n Zoo: { screen: PlainScreen },\n });\n ScreenA.router = StackRouter({\n Bar: { screen: PlainScreen },\n Boo: { screen: ScreenB },\n });\n const TestRouter = TabRouter({\n Foo: { screen: ScreenA },\n });\n const screenApreState = {\n index: 0,\n key: 'Init',\n isTransitioning: false,\n routeName: 'Foo',\n routes: [{ key: 'Init', routeName: 'Bar' }],\n };\n const preState = {\n index: 0,\n isTransitioning: false,\n routes: [screenApreState],\n };\n\n const comparable = state => {\n let result = {};\n if (typeof state.routeName === 'string') {\n result = { ...result, routeName: state.routeName };\n }\n if (state.routes instanceof Array) {\n result = {\n ...result,\n routes: state.routes.map(comparable),\n };\n }\n return result;\n };\n\n const action = NavigationActions.navigate({\n routeName: 'Boo',\n action: NavigationActions.navigate({ routeName: 'Zoo' }),\n });\n\n const expectedState = ScreenA.router.getStateForAction(\n action,\n screenApreState\n );\n const state = TestRouter.getStateForAction(action, preState);\n const innerState = state ? state.routes[0] : state;\n\n expect(expectedState && comparable(expectedState)).toEqual(\n innerState && comparable(innerState)\n );\n});\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectSpread from"@babel/runtime/helpers/objectSpread";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";var _jsxFileName="/Users/brentvatne/coding/react-navigation-core/src/routers/__tests__/StackRouter-test.js";import React from'react';import StackRouter from'../StackRouter';import*as StackActions from'../StackActions';import*as NavigationActions from'../../NavigationActions';import{_TESTING_ONLY_normalize_keys}from'../KeyGenerator.ts';beforeEach(function(){_TESTING_ONLY_normalize_keys();});var ListScreen=function ListScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:14}});};var ProfileNavigator=function ProfileNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:16}});};ProfileNavigator.router=StackRouter({list:{path:'list/:id',screen:ListScreen}});var MainNavigator=function MainNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:24}});};MainNavigator.router=StackRouter({profile:{path:'p/:id',screen:ProfileNavigator}});var LoginScreen=function LoginScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:32}});};var AuthNavigator=function AuthNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:34}});};AuthNavigator.router=StackRouter({login:{screen:LoginScreen}});var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:41}});};var FooNavigator=function(_React$Component){_inherits(FooNavigator,_React$Component);function FooNavigator(){_classCallCheck(this,FooNavigator);return _possibleConstructorReturn(this,_getPrototypeOf(FooNavigator).apply(this,arguments));}_createClass(FooNavigator,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:51}});}}]);return FooNavigator;}(React.Component);FooNavigator.router=StackRouter({bar:{path:'b/:barThing',screen:BarScreen}});var PersonScreen=function PersonScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:55}});};var TestStackRouter=StackRouter({main:{screen:MainNavigator},baz:{path:null,screen:FooNavigator},auth:{screen:AuthNavigator},person:{path:'people/:id',screen:PersonScreen},foo:{path:'fo/:fooThing',screen:FooNavigator}});describe('StackRouter',function(){it('Gets the active screen for a given state',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:80}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:81}});};var router=StackRouter({foo:{screen:FooScreen},bar:{screen:BarScreen}});expect(router.getComponentForState({index:0,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'},{key:'c',routeName:'foo'}]})).toBe(FooScreen);expect(router.getComponentForState({index:1,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'}]})).toBe(BarScreen);});it('Handles getScreen in getComponentForState',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:115}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:116}});};var router=StackRouter({foo:{getScreen:function getScreen(){return FooScreen;}},bar:{getScreen:function getScreen(){return BarScreen;}}});expect(router.getComponentForState({index:0,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'},{key:'c',routeName:'foo'}]})).toBe(FooScreen);expect(router.getComponentForState({index:1,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'}]})).toBe(BarScreen);});it('Gets the screen for given route',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:150}});};var BarScreen=function(_React$Component2){_inherits(BarScreen,_React$Component2);function BarScreen(){_classCallCheck(this,BarScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BarScreen).apply(this,arguments));}_createClass(BarScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:153}});}}]);return BarScreen;}(React.Component);var BazScreen=function(_React$Component3){_inherits(BazScreen,_React$Component3);function BazScreen(){_classCallCheck(this,BazScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BazScreen).apply(this,arguments));}_createClass(BazScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:158}});}}]);return BazScreen;}(React.Component);var router=StackRouter({foo:{screen:FooScreen},bar:{screen:BarScreen},baz:{screen:BazScreen}});expect(router.getComponentForRouteName('foo')).toBe(FooScreen);expect(router.getComponentForRouteName('bar')).toBe(BarScreen);expect(router.getComponentForRouteName('baz')).toBe(BazScreen);});it('Handles getScreen in getComponent',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:179}});};var BarScreen=function(_React$Component4){_inherits(BarScreen,_React$Component4);function BarScreen(){_classCallCheck(this,BarScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BarScreen).apply(this,arguments));}_createClass(BarScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:182}});}}]);return BarScreen;}(React.Component);var BazScreen=function(_React$Component5){_inherits(BazScreen,_React$Component5);function BazScreen(){_classCallCheck(this,BazScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BazScreen).apply(this,arguments));}_createClass(BazScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:187}});}}]);return BazScreen;}(React.Component);var router=StackRouter({foo:{getScreen:function getScreen(){return FooScreen;}},bar:{getScreen:function getScreen(){return BarScreen;}},baz:{getScreen:function getScreen(){return BazScreen;}}});expect(router.getComponentForRouteName('foo')).toBe(FooScreen);expect(router.getComponentForRouteName('bar')).toBe(BarScreen);expect(router.getComponentForRouteName('baz')).toBe(BazScreen);});it('Parses simple paths',function(){expect(AuthNavigator.router.getActionForPathAndParams('login')).toEqual({type:NavigationActions.NAVIGATE,routeName:'login',params:{}});});it('Parses paths with a param',function(){expect(TestStackRouter.getActionForPathAndParams('people/foo')).toEqual({type:NavigationActions.NAVIGATE,routeName:'person',params:{id:'foo'}});});it('Parses paths with a query',function(){expect(TestStackRouter.getActionForPathAndParams('people/foo',{code:'test',foo:'bar'})).toEqual({type:NavigationActions.NAVIGATE,routeName:'person',params:{id:'foo',code:'test',foo:'bar'}});});it('Parses paths with an empty query value',function(){expect(TestStackRouter.getActionForPathAndParams('people/foo',{code:'',foo:'bar'})).toEqual({type:NavigationActions.NAVIGATE,routeName:'person',params:{id:'foo',code:'',foo:'bar'}});});it('Correctly parses a path without arguments into an action chain',function(){var uri='auth/login';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'auth',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'login',params:{}}});});it('Correctly parses a path with arguments into an action chain',function(){var uri='main/p/4/list/10259959195';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'main',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'profile',params:{id:'4'},action:{type:NavigationActions.NAVIGATE,routeName:'list',params:{id:'10259959195'}}}});});it('Correctly parses a path to the router connected to another router through a pure wildcard route into an action chain',function(){var uri='b/123';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'baz',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'bar',params:{barThing:'123'}}});});it('Correctly returns null action for non-existent path',function(){var uri='asdf/1234';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual(null);});it('Correctly returns action chain for partially matched path',function(){var uri='auth/login';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'auth',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'login',params:{}}});});it('Correctly returns action for path with multiple parameters',function(){var path='fo/22/b/hello';var action=TestStackRouter.getActionForPathAndParams(path);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'foo',params:{fooThing:'22'},action:{type:NavigationActions.NAVIGATE,routeName:'bar',params:{barThing:'hello'}}});});it('Pushes other navigators when navigating to an unopened route name',function(){var Bar=function Bar(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:356}});};Bar.router=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:358}});}},qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:359}});}}});var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:362}});}},bar:{screen:Bar}});var initState=TestRouter.getStateForAction(NavigationActions.init());expect(initState).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'foo'}]});var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'qux'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].index).toEqual(1);expect(pushedState.routes[1].routes[1].routeName).toEqual('qux');});it('push bubbles up',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:382}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:384}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:385}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:388}});}},Bar:{screen:ChildNavigator},Bad:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:390}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:StackActions.PUSH,routeName:'Bad'},state2);expect(state3&&state3.index).toEqual(2);expect(state3&&state3.routes.length).toEqual(3);});it('pop bubbles up',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:412}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:414}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:415}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:418}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',key:'StackRouterRoot'},state);var state3=router.getStateForAction({type:StackActions.POP},state2);expect(state3&&state3.index).toEqual(0);});it('Handle navigation to nested navigator',function(){var action=TestStackRouter.getActionForPathAndParams('fo/22/b/hello');var state2=TestStackRouter.getStateForAction(action);expect(state2).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{index:0,key:'id-1',isTransitioning:false,routeName:'foo',params:{fooThing:'22'},routes:[{routeName:'bar',key:'id-0',params:{barThing:'hello'}}]}]});});it('popToTop bubbles up',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:472}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:474}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:475}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:479}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:StackActions.POP_TO_TOP},state2);expect(state3&&state3.index).toEqual(0);});it('popToTop targets StackRouter by key if specified',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:501}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:503}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:504}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:507}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:StackActions.POP_TO_TOP,key:state2.key},state2);expect(state3&&state3.index).toEqual(0);});it('pop action works as expected',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:531}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:532}});}}});var state={index:3,isTransitioning:false,routes:[{key:'A',routeName:'foo'},{key:'B',routeName:'bar',params:{bazId:'321'}},{key:'C',routeName:'foo'},{key:'D',routeName:'bar'}]};var poppedState=TestRouter.getStateForAction(StackActions.pop(),state);expect(poppedState.routes.length).toBe(3);expect(poppedState.index).toBe(2);expect(poppedState.isTransitioning).toBe(true);var poppedState2=TestRouter.getStateForAction(StackActions.pop({n:2,immediate:true}),state);expect(poppedState2.routes.length).toBe(2);expect(poppedState2.index).toBe(1);expect(poppedState2.isTransitioning).toBe(false);var poppedState3=TestRouter.getStateForAction(StackActions.pop({n:5}),state);expect(poppedState3.routes.length).toBe(1);expect(poppedState3.index).toBe(0);expect(poppedState3.isTransitioning).toBe(true);});it('popToTop works as expected',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:569}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:570}});}}});var state={index:2,isTransitioning:false,routes:[{key:'A',routeName:'foo'},{key:'B',routeName:'bar',params:{bazId:'321'}},{key:'C',routeName:'foo'}]};var poppedState=TestRouter.getStateForAction(StackActions.popToTop(),state);expect(poppedState.routes.length).toBe(1);expect(poppedState.index).toBe(0);expect(poppedState.isTransitioning).toBe(true);var poppedState2=TestRouter.getStateForAction(StackActions.popToTop(),poppedState);expect(poppedState).toEqual(poppedState2);var poppedImmediatelyState=TestRouter.getStateForAction(StackActions.popToTop({immediate:true}),state);expect(poppedImmediatelyState.routes.length).toBe(1);expect(poppedImmediatelyState.index).toBe(0);expect(poppedImmediatelyState.isTransitioning).toBe(false);});it('Navigate does not push duplicate routeName',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:606}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:607}});}}},{initialRouteName:'foo'});var initState=TestRouter.getStateForAction(NavigationActions.init());var barState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),initState);expect(barState.index).toEqual(1);expect(barState.routes[1].routeName).toEqual('bar');var navigateOnBarState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),barState);expect(navigateOnBarState).toEqual(null);});it('Navigate focuses given routeName if already active in stack',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:628}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:629}});}},baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:630}});}}},{initialRouteName:'foo'});var initialState=TestRouter.getStateForAction(NavigationActions.init());var fooBarState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),initialState);var fooBarBazState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'baz'}),fooBarState);expect(fooBarBazState.index).toEqual(2);expect(fooBarBazState.routes[2].routeName).toEqual('baz');var fooState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo'}),fooBarBazState);expect(fooState.index).toEqual(0);expect(fooState.routes.length).toEqual(1);expect(fooState.routes[0].routeName).toEqual('foo');});it('Navigate pushes duplicate routeName if unique key is provided',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:657}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:658}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');var pushedTwiceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'new-unique-key!'}),pushedState);expect(pushedTwiceState.index).toEqual(2);expect(pushedTwiceState.routes[2].routeName).toEqual('bar');});it('Navigate from top propagates to any arbitary depth of stacks',function(){var GrandChildNavigator=function GrandChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:676}});};GrandChildNavigator.router=StackRouter({Quux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:678}});}},Corge:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:679}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:682}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:684}});}},Woo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:685}});}},Qux:{screen:GrandChildNavigator}});var Parent=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:690}});}},Bar:{screen:ChildNavigator}});var state=Parent.getStateForAction({type:NavigationActions.INIT});var state2=Parent.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Corge'},state);expect(state2.isTransitioning).toEqual(true);expect(state2.index).toEqual(1);expect(state2.routes[1].index).toEqual(1);expect(state2.routes[1].routes[1].index).toEqual(1);expect(state2.routes[1].routes[1].routes[1].routeName).toEqual('Corge');});it('Navigate to initial screen is possible',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:713}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:714}});}}},{initialRouteKey:'foo'});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo',key:'foo'}),initState);expect(pushedState).toEqual(null);});it('Navigate with key and without it is idempotent',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:728}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:729}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'a'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');var pushedTwiceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'a'}),pushedState);expect(pushedTwiceState).toEqual(null);});it('Navigate on inactive stackrouter is idempotent',function(){var FirstChildNavigator=function FirstChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:747}});};FirstChildNavigator.router=StackRouter({First1:function First1(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:749}});},First2:function First2(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:750}});}});var SecondChildNavigator=function SecondChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:753}});};SecondChildNavigator.router=StackRouter({Second1:function Second1(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:755}});},Second2:function Second2(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:756}});}});var router=StackRouter({Leaf:function Leaf(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:760}});},First:FirstChildNavigator,Second:SecondChildNavigator});var state=router.getStateForAction({type:NavigationActions.INIT});var first=router.getStateForAction(NavigationActions.navigate({routeName:'First2'}),state);var second=router.getStateForAction(NavigationActions.navigate({routeName:'Second2'}),first);var firstAgain=router.getStateForAction(NavigationActions.navigate({routeName:'First2',params:{debug:true}}),second);expect(first.routes.length).toEqual(2);expect(first.index).toEqual(1);expect(second.routes.length).toEqual(3);expect(second.index).toEqual(2);expect(firstAgain.index).toEqual(1);expect(firstAgain.routes.length).toEqual(2);});it('Navigate to current routeName returns null to indicate handled action',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:796}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:797}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var navigatedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo'}),initState);expect(navigatedState).toBe(null);});it('Push behaves like navigate, except for key',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:809}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:810}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(StackActions.push({routeName:'bar'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');expect(function(){TestRouter.getStateForAction({type:StackActions.PUSH,routeName:'bar',key:'a'},pushedState);}).toThrow('StackRouter does not support key on the push action');});it('Push adds new routes every time',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:829}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:830}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(StackActions.push({routeName:'bar'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');var secondPushedState=TestRouter.getStateForAction(StackActions.push({routeName:'bar'}),pushedState);expect(secondPushedState.index).toEqual(2);expect(secondPushedState.routes[2].routeName).toEqual('bar');});it('Navigate backwards with key removes leading routes',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:849}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:850}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'a'}),initState);var pushedTwiceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'b`'}),pushedState);var pushedThriceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo',key:'c`'}),pushedTwiceState);expect(pushedThriceState.routes.length).toEqual(4);var navigatedBackToFirstRouteState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo',key:pushedThriceState.routes[0].key}),pushedThriceState);expect(navigatedBackToFirstRouteState.index).toEqual(0);expect(navigatedBackToFirstRouteState.routes.length).toEqual(1);});it('Handle basic stack logic for plain components',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:879}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:880}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{name:'Zoom'},immediate:true},state);expect(state2.index).toEqual(1);expect(state2.routes[1].routeName).toEqual('Bar');expect(state2.routes[1].params).toEqual({name:'Zoom'});expect(state2.routes.length).toEqual(2);var state3=router.getStateForAction({type:NavigationActions.BACK,immediate:true},state2);expect(state3).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});});it('Replace action works',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:933}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:934}});}}});var initState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo'}));var replacedState=TestRouter.getStateForAction(StackActions.replace({routeName:'bar',params:{meaning:42},key:initState.routes[0].key}),initState);expect(replacedState.index).toEqual(0);expect(replacedState.routes.length).toEqual(1);expect(replacedState.routes[0].key).not.toEqual(initState.routes[0].key);expect(replacedState.routes[0].routeName).toEqual('bar');expect(replacedState.routes[0].params.meaning).toEqual(42);var replacedState2=TestRouter.getStateForAction(StackActions.replace({routeName:'bar',key:initState.routes[0].key,newKey:'wow'}),initState);expect(replacedState2.index).toEqual(0);expect(replacedState2.routes.length).toEqual(1);expect(replacedState2.routes[0].key).toEqual('wow');expect(replacedState2.routes[0].routeName).toEqual('bar');});it('Replace action returns most recent route if no key is provided',function(){var GrandChildNavigator=function GrandChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:967}});};GrandChildNavigator.router=StackRouter({Quux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:969}});}},Corge:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:970}});}},Grault:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:971}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:974}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:976}});}},Woo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:977}});}},Qux:{screen:GrandChildNavigator}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:982}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Qux'},state2);var state4=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Corge'},state3);var state5=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Grault'},state4);var replacedState=router.getStateForAction(StackActions.replace({routeName:'Woo',params:{meaning:42}}),state5);var originalCurrentScreen=state5.routes[1].routes[1].routes[2];var replacedCurrentScreen=replacedState.routes[1].routes[1].routes[2];expect(replacedState.routes[1].routes[1].index).toEqual(2);expect(replacedState.routes[1].routes[1].routes.length).toEqual(3);expect(replacedCurrentScreen.key).not.toEqual(originalCurrentScreen.key);expect(replacedCurrentScreen.routeName).not.toEqual(originalCurrentScreen.routeName);expect(replacedCurrentScreen.routeName).toEqual('Woo');expect(replacedCurrentScreen.params.meaning).toEqual(42);});it('Handles push transition logic with completion action',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1038}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1039}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{name:'Zoom'}},state);expect(state2&&state2.index).toEqual(1);expect(state2&&state2.isTransitioning).toEqual(true);var state3=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:state2.routes[1].key},state2);expect(state3&&state3.index).toEqual(1);expect(state3&&state3.isTransitioning).toEqual(false);});it('Completion action does not work with incorrect key',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1071}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:FooScreen}});var state={key:'StackKey',index:1,isTransitioning:true,routes:[{key:'a',routeName:'Foo'},{key:'b',routeName:'Foo'}]};var outputState=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:state.routes[state.index].key,key:'not StackKey'},state);expect(outputState.isTransitioning).toEqual(true);});it('Completion action does not work with incorrect toChildKey',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1098}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:FooScreen}});var state={key:'StackKey',index:1,isTransitioning:true,routes:[{key:'a',routeName:'Foo'},{key:'b',routeName:'Foo'}]};var outputState=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:'incorrect',key:'StackKey'},state);expect(outputState.isTransitioning).toEqual(true);});it('Back action parent is prioritized over inactive child routers',function(){var Bar=function Bar(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1126}});};Bar.router=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1128}});}},qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1129}});}}});var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1132}});}},bar:{screen:Bar},boo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1134}});}}});var state={key:'top',index:3,routes:[{routeName:'foo',key:'f'},{routeName:'bar',key:'b',index:1,routes:[{routeName:'baz',key:'bz'},{routeName:'qux',key:'bx'}]},{routeName:'foo',key:'f1'},{routeName:'boo',key:'z'}]};var testState=TestRouter.getStateForAction({type:NavigationActions.BACK},state);expect(testState.index).toBe(2);expect(testState.routes[1].index).toBe(1);});it('Handle basic stack logic for components with router',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1163}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1164}});};BarScreen.router=StackRouter({Xyz:{screen:function screen(){return null;}}});var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{name:'Zoom'},immediate:true},state);expect(state2&&state2.index).toEqual(1);expect(state2&&state2.routes[1].routeName).toEqual('Bar');expect(state2&&state2.routes[1].params).toEqual({name:'Zoom'});expect(state2&&state2.routes.length).toEqual(2);var state3=router.getStateForAction({type:NavigationActions.BACK,immediate:true},state2);expect(state3).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});});it('Gets deep path (stack behavior)',function(){var ScreenA=function ScreenA(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1221}});};var ScreenB=function ScreenB(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1222}});};ScreenA.router=StackRouter({Boo:{path:'boo',screen:ScreenB},Baz:{path:'baz/:bazId',screen:ScreenB}});var router=StackRouter({Foo:{path:'f/:id',screen:ScreenA},Bar:{screen:ScreenB}});var state={index:0,isTransitioning:false,routes:[{index:1,key:'Foo',routeName:'Foo',params:{id:'123'},routes:[{key:'Boo',routeName:'Boo'},{key:'Baz',routeName:'Baz',params:{bazId:'321'}}]},{key:'Bar',routeName:'Bar'}]};var _router$getPathAndPar=router.getPathAndParamsForState(state),path=_router$getPathAndPar.path,params=_router$getPathAndPar.params;expect(path).toEqual('f/123/baz/321');expect(params).toEqual({});});it('Handle goBack identified by key',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1262}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1263}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true,params:{name:'Zoom'}},state);var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true,params:{name:'Foo'}},state2);var state4=router.getStateForAction({type:NavigationActions.BACK,key:'wrongKey'},state3);expect(state3).toEqual(state4);var state5=router.getStateForAction({type:NavigationActions.BACK,key:state3&&state3.routes[1].key,immediate:true},state4);expect(state5).toEqual(state);});it('Handle initial route navigation',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1308}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1309}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}},{initialRouteName:'Bar'});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Bar'}]});});it('Initial route params appear in nav state',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1336}});};var router=StackRouter({Foo:{screen:FooScreen}},{initialRouteName:'Foo',initialRouteParams:{foo:'bar'}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:state&&state.routes[0].key,routeName:'Foo',params:{foo:'bar'}}]});});it('params in route config are merged with initialRouteParams',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1361}});};var router=StackRouter({Foo:{screen:FooScreen,params:{foo:'not-bar',meaning:42}}},{initialRouteName:'Foo',initialRouteParams:{foo:'bar'}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:state&&state.routes[0].key,routeName:'Foo',params:{foo:'bar',meaning:42}}]});});it('Action params appear in nav state',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1387}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1388}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{bar:'42'},immediate:true},state);expect(state2).not.toBeNull();expect(state2&&state2.index).toEqual(1);expect(state2&&state2.routes[1].params).toEqual({bar:'42'});});it('Handles the SetParams action',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1416}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1419}});}}},{initialRouteName:'Bar',initialRouteParams:{name:'Zoo'}});var state=router.getStateForAction({type:NavigationActions.INIT});var key=state&&state.routes[0].key;var state2=key&&router.getStateForAction({type:NavigationActions.SET_PARAMS,params:{name:'Qux'},key:key},state);expect(state2&&state2.index).toEqual(0);expect(state2&&state2.routes[0].params).toEqual({name:'Qux'});});it('Handles the SetParams action for inactive routes',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1447}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1450}});}}},{initialRouteName:'Bar',initialRouteParams:{name:'Zoo'}});var initialState={index:1,routes:[{key:'RouteA',routeName:'Foo',params:{name:'InitialParam',other:'Unchanged'}},{key:'RouteB',routeName:'Bar',params:{}}]};var state=router.getStateForAction({type:NavigationActions.SET_PARAMS,params:{name:'NewParam'},key:'RouteA'},initialState);expect(state.index).toEqual(1);expect(state.routes[0].params).toEqual({name:'NewParam',other:'Unchanged'});});it('Handles the setParams action with nested routers',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1485}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1487}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1488}});}}});var router=StackRouter({Foo:{screen:ChildNavigator},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1492}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.SET_PARAMS,params:{name:'foobar'},key:'id-0'},state);expect(state2&&state2.index).toEqual(0);expect(state2&&state2.routes[0].routes).toEqual([{key:'id-0',routeName:'Baz',params:{name:'foobar'}}]);});it('Handles the reset action',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1516}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1519}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:StackActions.RESET,actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',params:{bar:'42'},immediate:true},{type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true}],index:1},state);expect(state2&&state2.index).toEqual(1);expect(state2&&state2.routes[0].params).toEqual({bar:'42'});expect(state2&&state2.routes[0].routeName).toEqual('Foo');expect(state2&&state2.routes[1].routeName).toEqual('Bar');});it('Handles the reset action only with correct key set',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1552}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1555}});}}});var state1=router.getStateForAction({type:NavigationActions.INIT});var resetAction={type:StackActions.RESET,key:'Bad Key',actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',params:{bar:'42'},immediate:true},{type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true}],index:1};var state2=router.getStateForAction(resetAction,state1);expect(state2).toEqual(state1);var state3=router.getStateForAction(_objectSpread({},resetAction,{key:state2.key}),state2);expect(state3&&state3.index).toEqual(1);expect(state3&&state3.routes[0].params).toEqual({bar:'42'});expect(state3&&state3.routes[0].routeName).toEqual('Foo');expect(state3&&state3.routes[1].routeName).toEqual('Bar');});it('Handles the reset action with nested Router',function(){var ChildRouter=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1595}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1599}});};ChildNavigator.router=ChildRouter;var router=StackRouter({Foo:{screen:ChildNavigator},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1607}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:StackActions.RESET,key:null,actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',immediate:true}],index:0},state);expect(state2&&state2.index).toEqual(0);expect(state2&&state2.routes[0].routeName).toEqual('Foo');expect(state2&&state2.routes[0].routes[0].routeName).toEqual('baz');});it('Handles the reset action with a key',function(){var ChildRouter=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1635}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1639}});};ChildNavigator.router=ChildRouter;var router=StackRouter({Foo:{screen:ChildNavigator},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1647}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Foo',immediate:true,action:{type:NavigationActions.NAVIGATE,routeName:'baz',immediate:true}},state);var state3=router.getStateForAction({type:StackActions.RESET,key:'Init',actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',immediate:true}],index:0},state2);var state4=router.getStateForAction({type:StackActions.RESET,key:null,actions:[{type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true}],index:0},state3);expect(state4&&state4.index).toEqual(0);expect(state4&&state4.routes[0].routeName).toEqual('Bar');});it('Handles the navigate action with params and nested StackRouter',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1700}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1701}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1704}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,immediate:true,routeName:'Bar',params:{foo:'42'}},state);expect(state2&&state2.routes[1].params).toEqual({foo:'42'});expect(state2&&state2.routes[1].routes).toEqual([expect.objectContaining({routeName:'Baz',params:{foo:'42'}})]);});it('Navigate action to previous nested StackRouter causes isTransitioning start',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1727}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1729}});}}});var router=StackRouter({Bar:{screen:ChildNavigator},Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1733}});}}});var state=router.getStateForAction({type:NavigationActions.NAVIGATE,immediate:true,routeName:'Foo'},router.getStateForAction({type:NavigationActions.INIT}));var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Baz'},state);expect(state2.index).toEqual(0);expect(state2.isTransitioning).toEqual(true);});it('Handles the navigate action with params and nested StackRouter as a first action',function(){var state=TestStackRouter.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'main',params:{code:'test',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'profile',params:{id:'4',code:'test',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'list',params:{id:'10259959195',code:'test',foo:'bar'}}}});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{index:0,isTransitioning:false,key:'id-2',params:{code:'test',foo:'bar'},routeName:'main',routes:[{index:0,isTransitioning:false,key:'id-1',params:{code:'test',foo:'bar',id:'4'},routeName:'profile',routes:[{key:'id-0',params:{code:'test',foo:'bar',id:'10259959195'},routeName:'list',type:undefined}]}]}]});var state2=TestStackRouter.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'main',params:{code:'',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'profile',params:{id:'4',code:'',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'list',params:{id:'10259959195',code:'',foo:'bar'}}}});expect(state2).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{index:0,isTransitioning:false,key:'id-5',params:{code:'',foo:'bar'},routeName:'main',routes:[{index:0,isTransitioning:false,key:'id-4',params:{code:'',foo:'bar',id:'4'},routeName:'profile',routes:[{key:'id-3',params:{code:'',foo:'bar',id:'10259959195'},routeName:'list',type:undefined}]}]}]});});it('Handles deep navigate completion action',function(){var LeafScreen=function LeafScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1875}});};var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1876}});};FooScreen.router=StackRouter({Boo:{path:'boo',screen:LeafScreen},Baz:{path:'baz/:bazId',screen:LeafScreen}});var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:LeafScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state&&state.index).toEqual(0);expect(state&&state.routes[0].routeName).toEqual('Foo');var key=state&&state.routes[0].key;var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Baz'},state);expect(state2.index).toEqual(0);expect(state2.isTransitioning).toEqual(false);expect(state2.routes[0].index).toEqual(1);expect(state2.routes[0].isTransitioning).toEqual(true);expect(!!key).toEqual(true);var state3=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:state2.routes[0].routes[1].key},state2);expect(state3&&state3.index).toEqual(0);expect(state3&&state3.isTransitioning).toEqual(false);expect(state3&&state3.routes[0].index).toEqual(1);expect(state3&&state3.routes[0].isTransitioning).toEqual(false);});it('order of handling navigate action is correct for nested stackrouters',function(){var Screen=function Screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1920}});};var NestedStack=function NestedStack(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1921}});};var nestedRouter=StackRouter({Foo:Screen,Bar:Screen});NestedStack.router=nestedRouter;var router=StackRouter({NestedStack:NestedStack,Bar:Screen,Baz:Screen},{initialRouteName:'Baz'});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state.routes[state.index].routeName).toEqual('Baz');var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);expect(state2.routes[state2.index].routeName).toEqual('Bar');var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Baz'},state2);expect(state3.routes[state3.index].routeName).toEqual('Baz');var state4=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Foo'},state3);var activeState4=state4.routes[state4.index];expect(activeState4.routeName).toEqual('NestedStack');expect(activeState4.routes[activeState4.index].routeName).toEqual('Foo');var state5=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state4);var activeState5=state5.routes[state5.index];expect(activeState5.routeName).toEqual('NestedStack');expect(activeState5.routes[activeState5.index].routeName).toEqual('Bar');});it('order of handling navigate action is correct for nested stackrouters 2',function(){var Screen=function Screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1985}});};var NestedStack=function NestedStack(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1986}});};var OtherNestedStack=function OtherNestedStack(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1987}});};var nestedRouter=StackRouter({Foo:Screen,Bar:Screen});var otherNestedRouter=StackRouter({Foo:Screen});NestedStack.router=nestedRouter;OtherNestedStack.router=otherNestedRouter;var router=StackRouter({NestedStack:NestedStack,OtherNestedStack:OtherNestedStack,Bar:Screen},{initialRouteName:'OtherNestedStack'});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state.routes[state.index].routeName).toEqual('OtherNestedStack');var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);expect(state2.routes[state2.index].routeName).toEqual('Bar');var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'NestedStack'},state2);var state4=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state3);var activeState4=state4.routes[state4.index];expect(activeState4.routeName).toEqual('NestedStack');expect(activeState4.routes[activeState4.index].routeName).toEqual('Bar');});});
|
|
1
|
+
import _objectSpread from"@babel/runtime/helpers/objectSpread";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";var _jsxFileName="/Users/satya/Workspace/Callstack/react-navigation-core/src/routers/__tests__/StackRouter-test.js";import React from'react';import StackRouter from'../StackRouter';import*as StackActions from'../StackActions';import*as NavigationActions from'../../NavigationActions';import{_TESTING_ONLY_normalize_keys}from'../KeyGenerator.ts';beforeEach(function(){_TESTING_ONLY_normalize_keys();});var ListScreen=function ListScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:14}});};var ProfileNavigator=function ProfileNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:16}});};ProfileNavigator.router=StackRouter({list:{path:'list/:id',screen:ListScreen}});var MainNavigator=function MainNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:24}});};MainNavigator.router=StackRouter({profile:{path:'p/:id',screen:ProfileNavigator}});var LoginScreen=function LoginScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:32}});};var AuthNavigator=function AuthNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:34}});};AuthNavigator.router=StackRouter({login:{screen:LoginScreen}});var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:41}});};var FooNavigator=function(_React$Component){_inherits(FooNavigator,_React$Component);function FooNavigator(){_classCallCheck(this,FooNavigator);return _possibleConstructorReturn(this,_getPrototypeOf(FooNavigator).apply(this,arguments));}_createClass(FooNavigator,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:51}});}}]);return FooNavigator;}(React.Component);FooNavigator.router=StackRouter({bar:{path:'b/:barThing',screen:BarScreen}});var PersonScreen=function PersonScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:55}});};var TestStackRouter=StackRouter({main:{screen:MainNavigator},baz:{path:null,screen:FooNavigator},auth:{screen:AuthNavigator},person:{path:'people/:id',screen:PersonScreen},foo:{path:'fo/:fooThing',screen:FooNavigator}});describe('StackRouter',function(){it('Gets the active screen for a given state',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:80}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:81}});};var router=StackRouter({foo:{screen:FooScreen},bar:{screen:BarScreen}});expect(router.getComponentForState({index:0,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'},{key:'c',routeName:'foo'}]})).toBe(FooScreen);expect(router.getComponentForState({index:1,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'}]})).toBe(BarScreen);});it('Handles getScreen in getComponentForState',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:115}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:116}});};var router=StackRouter({foo:{getScreen:function getScreen(){return FooScreen;}},bar:{getScreen:function getScreen(){return BarScreen;}}});expect(router.getComponentForState({index:0,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'},{key:'c',routeName:'foo'}]})).toBe(FooScreen);expect(router.getComponentForState({index:1,isTransitioning:false,routes:[{key:'a',routeName:'foo'},{key:'b',routeName:'bar'}]})).toBe(BarScreen);});it('Gets the screen for given route',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:150}});};var BarScreen=function(_React$Component2){_inherits(BarScreen,_React$Component2);function BarScreen(){_classCallCheck(this,BarScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BarScreen).apply(this,arguments));}_createClass(BarScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:153}});}}]);return BarScreen;}(React.Component);var BazScreen=function(_React$Component3){_inherits(BazScreen,_React$Component3);function BazScreen(){_classCallCheck(this,BazScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BazScreen).apply(this,arguments));}_createClass(BazScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:158}});}}]);return BazScreen;}(React.Component);var router=StackRouter({foo:{screen:FooScreen},bar:{screen:BarScreen},baz:{screen:BazScreen}});expect(router.getComponentForRouteName('foo')).toBe(FooScreen);expect(router.getComponentForRouteName('bar')).toBe(BarScreen);expect(router.getComponentForRouteName('baz')).toBe(BazScreen);});it('Handles getScreen in getComponent',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:179}});};var BarScreen=function(_React$Component4){_inherits(BarScreen,_React$Component4);function BarScreen(){_classCallCheck(this,BarScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BarScreen).apply(this,arguments));}_createClass(BarScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:182}});}}]);return BarScreen;}(React.Component);var BazScreen=function(_React$Component5){_inherits(BazScreen,_React$Component5);function BazScreen(){_classCallCheck(this,BazScreen);return _possibleConstructorReturn(this,_getPrototypeOf(BazScreen).apply(this,arguments));}_createClass(BazScreen,[{key:"render",value:function render(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:187}});}}]);return BazScreen;}(React.Component);var router=StackRouter({foo:{getScreen:function getScreen(){return FooScreen;}},bar:{getScreen:function getScreen(){return BarScreen;}},baz:{getScreen:function getScreen(){return BazScreen;}}});expect(router.getComponentForRouteName('foo')).toBe(FooScreen);expect(router.getComponentForRouteName('bar')).toBe(BarScreen);expect(router.getComponentForRouteName('baz')).toBe(BazScreen);});it('Parses simple paths',function(){expect(AuthNavigator.router.getActionForPathAndParams('login')).toEqual({type:NavigationActions.NAVIGATE,routeName:'login',params:{}});});it('Parses paths with a param',function(){expect(TestStackRouter.getActionForPathAndParams('people/foo')).toEqual({type:NavigationActions.NAVIGATE,routeName:'person',params:{id:'foo'}});});it('Parses paths with a query',function(){expect(TestStackRouter.getActionForPathAndParams('people/foo',{code:'test',foo:'bar'})).toEqual({type:NavigationActions.NAVIGATE,routeName:'person',params:{id:'foo',code:'test',foo:'bar'}});});it('Parses paths with an empty query value',function(){expect(TestStackRouter.getActionForPathAndParams('people/foo',{code:'',foo:'bar'})).toEqual({type:NavigationActions.NAVIGATE,routeName:'person',params:{id:'foo',code:'',foo:'bar'}});});it('Correctly parses a path without arguments into an action chain',function(){var uri='auth/login';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'auth',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'login',params:{}}});});it('Correctly parses a path with arguments into an action chain',function(){var uri='main/p/4/list/10259959195';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'main',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'profile',params:{id:'4'},action:{type:NavigationActions.NAVIGATE,routeName:'list',params:{id:'10259959195'}}}});});it('Correctly parses a path to the router connected to another router through a pure wildcard route into an action chain',function(){var uri='b/123';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'baz',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'bar',params:{barThing:'123'}}});});it('Correctly returns null action for non-existent path',function(){var uri='asdf/1234';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual(null);});it('Correctly returns action chain for partially matched path',function(){var uri='auth/login';var action=TestStackRouter.getActionForPathAndParams(uri);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'auth',params:{},action:{type:NavigationActions.NAVIGATE,routeName:'login',params:{}}});});it('Correctly returns action for path with multiple parameters',function(){var path='fo/22/b/hello';var action=TestStackRouter.getActionForPathAndParams(path);expect(action).toEqual({type:NavigationActions.NAVIGATE,routeName:'foo',params:{fooThing:'22'},action:{type:NavigationActions.NAVIGATE,routeName:'bar',params:{barThing:'hello'}}});});it('Pushes other navigators when navigating to an unopened route name',function(){var Bar=function Bar(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:356}});};Bar.router=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:358}});}},qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:359}});}}});var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:362}});}},bar:{screen:Bar}});var initState=TestRouter.getStateForAction(NavigationActions.init());expect(initState).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'foo'}]});var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'qux'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].index).toEqual(1);expect(pushedState.routes[1].routes[1].routeName).toEqual('qux');});it('push bubbles up',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:382}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:384}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:385}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:388}});}},Bar:{screen:ChildNavigator},Bad:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:390}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:StackActions.PUSH,routeName:'Bad'},state2);expect(state3&&state3.index).toEqual(2);expect(state3&&state3.routes.length).toEqual(3);});it('pop bubbles up',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:412}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:414}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:415}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:418}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',key:'StackRouterRoot'},state);var state3=router.getStateForAction({type:StackActions.POP},state2);expect(state3&&state3.index).toEqual(0);});it('Handle navigation to nested navigator',function(){var action=TestStackRouter.getActionForPathAndParams('fo/22/b/hello');var state2=TestStackRouter.getStateForAction(action);expect(state2).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{index:0,key:'id-1',isTransitioning:false,routeName:'foo',params:{fooThing:'22'},routes:[{routeName:'bar',key:'id-0',params:{barThing:'hello'}}]}]});});it('popToTop bubbles up',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:472}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:474}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:475}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:479}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:StackActions.POP_TO_TOP},state2);expect(state3&&state3.index).toEqual(0);});it('popToTop targets StackRouter by key if specified',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:501}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:503}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:504}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:507}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:StackActions.POP_TO_TOP,key:state2.key},state2);expect(state3&&state3.index).toEqual(0);});it('pop action works as expected',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:531}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:532}});}}});var state={index:3,isTransitioning:false,routes:[{key:'A',routeName:'foo'},{key:'B',routeName:'bar',params:{bazId:'321'}},{key:'C',routeName:'foo'},{key:'D',routeName:'bar'}]};var poppedState=TestRouter.getStateForAction(StackActions.pop(),state);expect(poppedState.routes.length).toBe(3);expect(poppedState.index).toBe(2);expect(poppedState.isTransitioning).toBe(true);var poppedState2=TestRouter.getStateForAction(StackActions.pop({n:2,immediate:true}),state);expect(poppedState2.routes.length).toBe(2);expect(poppedState2.index).toBe(1);expect(poppedState2.isTransitioning).toBe(false);var poppedState3=TestRouter.getStateForAction(StackActions.pop({n:5}),state);expect(poppedState3.routes.length).toBe(1);expect(poppedState3.index).toBe(0);expect(poppedState3.isTransitioning).toBe(true);});it('popToTop works as expected',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:569}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:570}});}}});var state={index:2,isTransitioning:false,routes:[{key:'A',routeName:'foo'},{key:'B',routeName:'bar',params:{bazId:'321'}},{key:'C',routeName:'foo'}]};var poppedState=TestRouter.getStateForAction(StackActions.popToTop(),state);expect(poppedState.routes.length).toBe(1);expect(poppedState.index).toBe(0);expect(poppedState.isTransitioning).toBe(true);var poppedState2=TestRouter.getStateForAction(StackActions.popToTop(),poppedState);expect(poppedState).toEqual(poppedState2);var poppedImmediatelyState=TestRouter.getStateForAction(StackActions.popToTop({immediate:true}),state);expect(poppedImmediatelyState.routes.length).toBe(1);expect(poppedImmediatelyState.index).toBe(0);expect(poppedImmediatelyState.isTransitioning).toBe(false);});it('Navigate does not push duplicate routeName',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:606}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:607}});}}},{initialRouteName:'foo'});var initState=TestRouter.getStateForAction(NavigationActions.init());var barState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),initState);expect(barState.index).toEqual(1);expect(barState.routes[1].routeName).toEqual('bar');var navigateOnBarState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),barState);expect(navigateOnBarState).toEqual(null);});it('Navigate focuses given routeName if already active in stack',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:628}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:629}});}},baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:630}});}}},{initialRouteName:'foo'});var initialState=TestRouter.getStateForAction(NavigationActions.init());var fooBarState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),initialState);var fooBarBazState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'baz'}),fooBarState);expect(fooBarBazState.index).toEqual(2);expect(fooBarBazState.routes[2].routeName).toEqual('baz');var fooState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo'}),fooBarBazState);expect(fooState.index).toEqual(0);expect(fooState.routes.length).toEqual(1);expect(fooState.routes[0].routeName).toEqual('foo');});it('Navigate pushes duplicate routeName if unique key is provided',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:657}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:658}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');var pushedTwiceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'new-unique-key!'}),pushedState);expect(pushedTwiceState.index).toEqual(2);expect(pushedTwiceState.routes[2].routeName).toEqual('bar');});it('Navigate from top propagates to any arbitary depth of stacks',function(){var GrandChildNavigator=function GrandChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:676}});};GrandChildNavigator.router=StackRouter({Quux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:678}});}},Corge:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:679}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:682}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:684}});}},Woo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:685}});}},Qux:{screen:GrandChildNavigator}});var Parent=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:690}});}},Bar:{screen:ChildNavigator}});var state=Parent.getStateForAction({type:NavigationActions.INIT});var state2=Parent.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Corge'},state);expect(state2.isTransitioning).toEqual(true);expect(state2.index).toEqual(1);expect(state2.routes[1].index).toEqual(1);expect(state2.routes[1].routes[1].index).toEqual(1);expect(state2.routes[1].routes[1].routes[1].routeName).toEqual('Corge');});it('Navigate to initial screen is possible',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:713}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:714}});}}},{initialRouteKey:'foo'});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo',key:'foo'}),initState);expect(pushedState).toEqual(null);});it('Navigate with key and without it is idempotent',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:728}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:729}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'a'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');var pushedTwiceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'a'}),pushedState);expect(pushedTwiceState).toEqual(null);});it('Navigate on inactive stackrouter is idempotent',function(){var FirstChildNavigator=function FirstChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:747}});};FirstChildNavigator.router=StackRouter({First1:function First1(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:749}});},First2:function First2(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:750}});}});var SecondChildNavigator=function SecondChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:753}});};SecondChildNavigator.router=StackRouter({Second1:function Second1(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:755}});},Second2:function Second2(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:756}});}});var router=StackRouter({Leaf:function Leaf(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:760}});},First:FirstChildNavigator,Second:SecondChildNavigator});var state=router.getStateForAction({type:NavigationActions.INIT});var first=router.getStateForAction(NavigationActions.navigate({routeName:'First2'}),state);var second=router.getStateForAction(NavigationActions.navigate({routeName:'Second2'}),first);var firstAgain=router.getStateForAction(NavigationActions.navigate({routeName:'First2',params:{debug:true}}),second);expect(first.routes.length).toEqual(2);expect(first.index).toEqual(1);expect(second.routes.length).toEqual(3);expect(second.index).toEqual(2);expect(firstAgain.index).toEqual(1);expect(firstAgain.routes.length).toEqual(2);});it('Navigate to current routeName returns null to indicate handled action',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:796}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:797}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var navigatedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo'}),initState);expect(navigatedState).toBe(null);});it('Push behaves like navigate, except for key',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:809}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:810}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(StackActions.push({routeName:'bar'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');expect(function(){TestRouter.getStateForAction({type:StackActions.PUSH,routeName:'bar',key:'a'},pushedState);}).toThrow('StackRouter does not support key on the push action');});it('Push adds new routes every time',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:829}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:830}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(StackActions.push({routeName:'bar'}),initState);expect(pushedState.index).toEqual(1);expect(pushedState.routes[1].routeName).toEqual('bar');var secondPushedState=TestRouter.getStateForAction(StackActions.push({routeName:'bar'}),pushedState);expect(secondPushedState.index).toEqual(2);expect(secondPushedState.routes[2].routeName).toEqual('bar');});it('Navigate backwards with key removes leading routes',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:849}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:850}});}}});var initState=TestRouter.getStateForAction(NavigationActions.init());var pushedState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'a'}),initState);var pushedTwiceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'bar',key:'b`'}),pushedState);var pushedThriceState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo',key:'c`'}),pushedTwiceState);expect(pushedThriceState.routes.length).toEqual(4);var navigatedBackToFirstRouteState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo',key:pushedThriceState.routes[0].key}),pushedThriceState);expect(navigatedBackToFirstRouteState.index).toEqual(0);expect(navigatedBackToFirstRouteState.routes.length).toEqual(1);});it('Handle basic stack logic for plain components',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:879}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:880}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{name:'Zoom'},immediate:true},state);expect(state2.index).toEqual(1);expect(state2.routes[1].routeName).toEqual('Bar');expect(state2.routes[1].params).toEqual({name:'Zoom'});expect(state2.routes.length).toEqual(2);var state3=router.getStateForAction({type:NavigationActions.BACK,immediate:true},state2);expect(state3).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});});it('Replace action works',function(){var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:933}});}},bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:934}});}}});var initState=TestRouter.getStateForAction(NavigationActions.navigate({routeName:'foo'}));var replacedState=TestRouter.getStateForAction(StackActions.replace({routeName:'bar',params:{meaning:42},key:initState.routes[0].key}),initState);expect(replacedState.index).toEqual(0);expect(replacedState.routes.length).toEqual(1);expect(replacedState.routes[0].key).not.toEqual(initState.routes[0].key);expect(replacedState.routes[0].routeName).toEqual('bar');expect(replacedState.routes[0].params.meaning).toEqual(42);var replacedState2=TestRouter.getStateForAction(StackActions.replace({routeName:'bar',key:initState.routes[0].key,newKey:'wow'}),initState);expect(replacedState2.index).toEqual(0);expect(replacedState2.routes.length).toEqual(1);expect(replacedState2.routes[0].key).toEqual('wow');expect(replacedState2.routes[0].routeName).toEqual('bar');});it('Replace action returns most recent route if no key is provided',function(){var GrandChildNavigator=function GrandChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:967}});};GrandChildNavigator.router=StackRouter({Quux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:969}});}},Corge:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:970}});}},Grault:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:971}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:974}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:976}});}},Woo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:977}});}},Qux:{screen:GrandChildNavigator}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:982}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Qux'},state2);var state4=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Corge'},state3);var state5=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Grault'},state4);var replacedState=router.getStateForAction(StackActions.replace({routeName:'Woo',params:{meaning:42}}),state5);var originalCurrentScreen=state5.routes[1].routes[1].routes[2];var replacedCurrentScreen=replacedState.routes[1].routes[1].routes[2];expect(replacedState.routes[1].routes[1].index).toEqual(2);expect(replacedState.routes[1].routes[1].routes.length).toEqual(3);expect(replacedCurrentScreen.key).not.toEqual(originalCurrentScreen.key);expect(replacedCurrentScreen.routeName).not.toEqual(originalCurrentScreen.routeName);expect(replacedCurrentScreen.routeName).toEqual('Woo');expect(replacedCurrentScreen.params.meaning).toEqual(42);});it('Handles push transition logic with completion action',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1038}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1039}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{name:'Zoom'}},state);expect(state2&&state2.index).toEqual(1);expect(state2&&state2.isTransitioning).toEqual(true);var state3=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:state2.routes[1].key},state2);expect(state3&&state3.index).toEqual(1);expect(state3&&state3.isTransitioning).toEqual(false);});it('Completion action does not work with incorrect key',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1071}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:FooScreen}});var state={key:'StackKey',index:1,isTransitioning:true,routes:[{key:'a',routeName:'Foo'},{key:'b',routeName:'Foo'}]};var outputState=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:state.routes[state.index].key,key:'not StackKey'},state);expect(outputState.isTransitioning).toEqual(true);});it('Completion action does not work with incorrect toChildKey',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1098}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:FooScreen}});var state={key:'StackKey',index:1,isTransitioning:true,routes:[{key:'a',routeName:'Foo'},{key:'b',routeName:'Foo'}]};var outputState=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:'incorrect',key:'StackKey'},state);expect(outputState.isTransitioning).toEqual(true);});it('Back action parent is prioritized over inactive child routers',function(){var Bar=function Bar(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1126}});};Bar.router=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1128}});}},qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1129}});}}});var TestRouter=StackRouter({foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1132}});}},bar:{screen:Bar},boo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1134}});}}});var state={key:'top',index:3,routes:[{routeName:'foo',key:'f'},{routeName:'bar',key:'b',index:1,routes:[{routeName:'baz',key:'bz'},{routeName:'qux',key:'bx'}]},{routeName:'foo',key:'f1'},{routeName:'boo',key:'z'}]};var testState=TestRouter.getStateForAction({type:NavigationActions.BACK},state);expect(testState.index).toBe(2);expect(testState.routes[1].index).toBe(1);});it('Handle basic stack logic for components with router',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1163}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1164}});};BarScreen.router=StackRouter({Xyz:{screen:function screen(){return null;}}});var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{name:'Zoom'},immediate:true},state);expect(state2&&state2.index).toEqual(1);expect(state2&&state2.routes[1].routeName).toEqual('Bar');expect(state2&&state2.routes[1].params).toEqual({name:'Zoom'});expect(state2&&state2.routes.length).toEqual(2);var state3=router.getStateForAction({type:NavigationActions.BACK,immediate:true},state2);expect(state3).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Foo'}]});});it('Gets deep path (stack behavior)',function(){var ScreenA=function ScreenA(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1221}});};var ScreenB=function ScreenB(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1222}});};ScreenA.router=StackRouter({Boo:{path:'boo',screen:ScreenB},Baz:{path:'baz/:bazId',screen:ScreenB}});var router=StackRouter({Foo:{path:'f/:id',screen:ScreenA},Bar:{screen:ScreenB}});var state={index:0,isTransitioning:false,routes:[{index:1,key:'Foo',routeName:'Foo',params:{id:'123'},routes:[{key:'Boo',routeName:'Boo'},{key:'Baz',routeName:'Baz',params:{bazId:'321'}}]},{key:'Bar',routeName:'Bar'}]};var _router$getPathAndPar=router.getPathAndParamsForState(state),path=_router$getPathAndPar.path,params=_router$getPathAndPar.params;expect(path).toEqual('f/123/baz/321');expect(params).toEqual({});});it('Handle goBack identified by key',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1262}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1263}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true,params:{name:'Zoom'}},state);var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true,params:{name:'Foo'}},state2);var state4=router.getStateForAction({type:NavigationActions.BACK,key:'wrongKey'},state3);expect(state3).toEqual(state4);var state5=router.getStateForAction({type:NavigationActions.BACK,key:state3&&state3.routes[1].key,immediate:true},state4);expect(state5).toEqual(state);});it('Handle initial route navigation',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1308}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1309}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}},{initialRouteName:'Bar'});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:'id-0',routeName:'Bar'}]});});it('Initial route params appear in nav state',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1336}});};var router=StackRouter({Foo:{screen:FooScreen}},{initialRouteName:'Foo',initialRouteParams:{foo:'bar'}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:state&&state.routes[0].key,routeName:'Foo',params:{foo:'bar'}}]});});it('params in route config are merged with initialRouteParams',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1361}});};var router=StackRouter({Foo:{screen:FooScreen,params:{foo:'not-bar',meaning:42}}},{initialRouteName:'Foo',initialRouteParams:{foo:'bar'}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{key:state&&state.routes[0].key,routeName:'Foo',params:{foo:'bar',meaning:42}}]});});it('Action params appear in nav state',function(){var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1387}});};var BarScreen=function BarScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1388}});};var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:BarScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar',params:{bar:'42'},immediate:true},state);expect(state2).not.toBeNull();expect(state2&&state2.index).toEqual(1);expect(state2&&state2.routes[1].params).toEqual({bar:'42'});});it('Handles the SetParams action',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1416}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1419}});}}},{initialRouteName:'Bar',initialRouteParams:{name:'Zoo'}});var state=router.getStateForAction({type:NavigationActions.INIT});var key=state&&state.routes[0].key;var state2=key&&router.getStateForAction({type:NavigationActions.SET_PARAMS,params:{name:'Qux'},key:key},state);expect(state2&&state2.index).toEqual(0);expect(state2&&state2.routes[0].params).toEqual({name:'Qux'});});it('Handles the SetParams action for inactive routes',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1447}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1450}});}}},{initialRouteName:'Bar',initialRouteParams:{name:'Zoo'}});var initialState={index:1,routes:[{key:'RouteA',routeName:'Foo',params:{name:'InitialParam',other:'Unchanged'}},{key:'RouteB',routeName:'Bar',params:{}}]};var state=router.getStateForAction({type:NavigationActions.SET_PARAMS,params:{name:'NewParam'},key:'RouteA'},initialState);expect(state.index).toEqual(1);expect(state.routes[0].params).toEqual({name:'NewParam',other:'Unchanged'});});it('Handles the setParams action with nested routers',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1485}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1487}});}},Qux:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1488}});}}});var router=StackRouter({Foo:{screen:ChildNavigator},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1492}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.SET_PARAMS,params:{name:'foobar'},key:'id-0'},state);expect(state2&&state2.index).toEqual(0);expect(state2&&state2.routes[0].routes).toEqual([{key:'id-0',routeName:'Baz',params:{name:'foobar'}}]);});it('Handles the reset action',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1516}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1519}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:StackActions.RESET,actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',params:{bar:'42'},immediate:true},{type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true}],index:1},state);expect(state2&&state2.index).toEqual(1);expect(state2&&state2.routes[0].params).toEqual({bar:'42'});expect(state2&&state2.routes[0].routeName).toEqual('Foo');expect(state2&&state2.routes[1].routeName).toEqual('Bar');});it('Handles the reset action only with correct key set',function(){var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1552}});}},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1555}});}}});var state1=router.getStateForAction({type:NavigationActions.INIT});var resetAction={type:StackActions.RESET,key:'Bad Key',actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',params:{bar:'42'},immediate:true},{type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true}],index:1};var state2=router.getStateForAction(resetAction,state1);expect(state2).toEqual(state1);var state3=router.getStateForAction(_objectSpread({},resetAction,{key:state2.key}),state2);expect(state3&&state3.index).toEqual(1);expect(state3&&state3.routes[0].params).toEqual({bar:'42'});expect(state3&&state3.routes[0].routeName).toEqual('Foo');expect(state3&&state3.routes[1].routeName).toEqual('Bar');});it('Handles the reset action with nested Router',function(){var ChildRouter=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1595}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1599}});};ChildNavigator.router=ChildRouter;var router=StackRouter({Foo:{screen:ChildNavigator},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1607}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:StackActions.RESET,key:null,actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',immediate:true}],index:0},state);expect(state2&&state2.index).toEqual(0);expect(state2&&state2.routes[0].routeName).toEqual('Foo');expect(state2&&state2.routes[0].routes[0].routeName).toEqual('baz');});it('Handles the reset action with a key',function(){var ChildRouter=StackRouter({baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1635}});}}});var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1639}});};ChildNavigator.router=ChildRouter;var router=StackRouter({Foo:{screen:ChildNavigator},Bar:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1647}});}}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Foo',immediate:true,action:{type:NavigationActions.NAVIGATE,routeName:'baz',immediate:true}},state);var state3=router.getStateForAction({type:StackActions.RESET,key:'Init',actions:[{type:NavigationActions.NAVIGATE,routeName:'Foo',immediate:true}],index:0},state2);var state4=router.getStateForAction({type:StackActions.RESET,key:null,actions:[{type:NavigationActions.NAVIGATE,routeName:'Bar',immediate:true}],index:0},state3);expect(state4&&state4.index).toEqual(0);expect(state4&&state4.routes[0].routeName).toEqual('Bar');});it('Handles the navigate action with params and nested StackRouter',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1700}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1701}});}}});var router=StackRouter({Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1704}});}},Bar:{screen:ChildNavigator}});var state=router.getStateForAction({type:NavigationActions.INIT});var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,immediate:true,routeName:'Bar',params:{foo:'42'}},state);expect(state2&&state2.routes[1].params).toEqual({foo:'42'});expect(state2&&state2.routes[1].routes).toEqual([expect.objectContaining({routeName:'Baz',params:{foo:'42'}})]);});it('Navigate action to previous nested StackRouter causes isTransitioning start',function(){var ChildNavigator=function ChildNavigator(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1727}});};ChildNavigator.router=StackRouter({Baz:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1729}});}}});var router=StackRouter({Bar:{screen:ChildNavigator},Foo:{screen:function screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1733}});}}});var state=router.getStateForAction({type:NavigationActions.NAVIGATE,immediate:true,routeName:'Foo'},router.getStateForAction({type:NavigationActions.INIT}));var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Baz'},state);expect(state2.index).toEqual(0);expect(state2.isTransitioning).toEqual(true);});it('Handles the navigate action with params and nested StackRouter as a first action',function(){var state=TestStackRouter.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'main',params:{code:'test',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'profile',params:{id:'4',code:'test',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'list',params:{id:'10259959195',code:'test',foo:'bar'}}}});expect(state).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{index:0,isTransitioning:false,key:'id-2',params:{code:'test',foo:'bar'},routeName:'main',routes:[{index:0,isTransitioning:false,key:'id-1',params:{code:'test',foo:'bar',id:'4'},routeName:'profile',routes:[{key:'id-0',params:{code:'test',foo:'bar',id:'10259959195'},routeName:'list',type:undefined}]}]}]});var state2=TestStackRouter.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'main',params:{code:'',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'profile',params:{id:'4',code:'',foo:'bar'},action:{type:NavigationActions.NAVIGATE,routeName:'list',params:{id:'10259959195',code:'',foo:'bar'}}}});expect(state2).toEqual({index:0,isTransitioning:false,key:'StackRouterRoot',routes:[{index:0,isTransitioning:false,key:'id-5',params:{code:'',foo:'bar'},routeName:'main',routes:[{index:0,isTransitioning:false,key:'id-4',params:{code:'',foo:'bar',id:'4'},routeName:'profile',routes:[{key:'id-3',params:{code:'',foo:'bar',id:'10259959195'},routeName:'list',type:undefined}]}]}]});});it('Handles deep navigate completion action',function(){var LeafScreen=function LeafScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1875}});};var FooScreen=function FooScreen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1876}});};FooScreen.router=StackRouter({Boo:{path:'boo',screen:LeafScreen},Baz:{path:'baz/:bazId',screen:LeafScreen}});var router=StackRouter({Foo:{screen:FooScreen},Bar:{screen:LeafScreen}});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state&&state.index).toEqual(0);expect(state&&state.routes[0].routeName).toEqual('Foo');var key=state&&state.routes[0].key;var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Baz'},state);expect(state2.index).toEqual(0);expect(state2.isTransitioning).toEqual(false);expect(state2.routes[0].index).toEqual(1);expect(state2.routes[0].isTransitioning).toEqual(true);expect(!!key).toEqual(true);var state3=router.getStateForAction({type:StackActions.COMPLETE_TRANSITION,toChildKey:state2.routes[0].routes[1].key},state2);expect(state3&&state3.index).toEqual(0);expect(state3&&state3.isTransitioning).toEqual(false);expect(state3&&state3.routes[0].index).toEqual(1);expect(state3&&state3.routes[0].isTransitioning).toEqual(false);});it('order of handling navigate action is correct for nested stackrouters',function(){var Screen=function Screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1920}});};var NestedStack=function NestedStack(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1921}});};var nestedRouter=StackRouter({Foo:Screen,Bar:Screen});NestedStack.router=nestedRouter;var router=StackRouter({NestedStack:NestedStack,Bar:Screen,Baz:Screen},{initialRouteName:'Baz'});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state.routes[state.index].routeName).toEqual('Baz');var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);expect(state2.routes[state2.index].routeName).toEqual('Bar');var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Baz'},state2);expect(state3.routes[state3.index].routeName).toEqual('Baz');var state4=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Foo'},state3);var activeState4=state4.routes[state4.index];expect(activeState4.routeName).toEqual('NestedStack');expect(activeState4.routes[activeState4.index].routeName).toEqual('Foo');var state5=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state4);var activeState5=state5.routes[state5.index];expect(activeState5.routeName).toEqual('NestedStack');expect(activeState5.routes[activeState5.index].routeName).toEqual('Bar');});it('order of handling navigate action is correct for nested stackrouters 2',function(){var Screen=function Screen(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1985}});};var NestedStack=function NestedStack(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1986}});};var OtherNestedStack=function OtherNestedStack(){return React.createElement("div",{__source:{fileName:_jsxFileName,lineNumber:1987}});};var nestedRouter=StackRouter({Foo:Screen,Bar:Screen});var otherNestedRouter=StackRouter({Foo:Screen});NestedStack.router=nestedRouter;OtherNestedStack.router=otherNestedRouter;var router=StackRouter({NestedStack:NestedStack,OtherNestedStack:OtherNestedStack,Bar:Screen},{initialRouteName:'OtherNestedStack'});var state=router.getStateForAction({type:NavigationActions.INIT});expect(state.routes[state.index].routeName).toEqual('OtherNestedStack');var state2=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state);expect(state2.routes[state2.index].routeName).toEqual('Bar');var state3=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'NestedStack'},state2);var state4=router.getStateForAction({type:NavigationActions.NAVIGATE,routeName:'Bar'},state3);var activeState4=state4.routes[state4.index];expect(activeState4.routeName).toEqual('NestedStack');expect(activeState4.routes[activeState4.index].routeName).toEqual('Bar');});});
|
|
2
2
|
//# sourceMappingURL=StackRouter-test.js.map
|