Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit eb043ed

Browse files
committed
Fix tests
1 parent 2bbb3c7 commit eb043ed

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/routers/StackRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export default (routeConfigs, stackConfig = {}) => {
435435
}
436436
const routes = [...state.routes];
437437
routes[routeIndex] = {
438-
params: getParamsForRouteAndAction(action.routeName, action.params),
438+
params: getParamsForRouteAndAction(action.routeName, action),
439439
// merge the child state in this order to allow params override
440440
...childState,
441441
routeName: action.routeName,

src/routers/__tests__/StackRouter-test.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ describe('StackRouter', () => {
12841284
screen: FooScreen,
12851285
},
12861286
},
1287-
{ initialRouteName: 'Bar', initialRouteParams: { foo: 'bar' } }
1287+
{ initialRouteName: 'Foo', initialRouteParams: { foo: 'bar' } }
12881288
);
12891289
const state = router.getStateForAction({ type: NavigationActions.INIT });
12901290
expect(state).toEqual({
@@ -1294,13 +1294,39 @@ describe('StackRouter', () => {
12941294
routes: [
12951295
{
12961296
key: state && state.routes[0].key,
1297-
routeName: 'Bar',
1297+
routeName: 'Foo',
12981298
params: { foo: 'bar' },
12991299
},
13001300
],
13011301
});
13021302
});
13031303

1304+
test('params in route config are merged with initialRouteParams', () => {
1305+
const FooScreen = () => <div />;
1306+
const router = StackRouter(
1307+
{
1308+
Foo: {
1309+
screen: FooScreen,
1310+
params: { foo: 'not-bar', meaning: 42 }
1311+
},
1312+
},
1313+
{ initialRouteName: 'Foo', initialRouteParams: { foo: 'bar' } }
1314+
);
1315+
const state = router.getStateForAction({ type: NavigationActions.INIT });
1316+
expect(state).toEqual({
1317+
index: 0,
1318+
isTransitioning: false,
1319+
key: 'StackRouterRoot',
1320+
routes: [
1321+
{
1322+
key: state && state.routes[0].key,
1323+
routeName: 'Foo',
1324+
params: { foo: 'bar', meaning: 42 },
1325+
},
1326+
],
1327+
});
1328+
});
1329+
13041330
test('Action params appear in nav state', () => {
13051331
const FooScreen = () => <div />;
13061332
const BarScreen = () => <div />;

0 commit comments

Comments
 (0)