fix: don't handle replace if screen to replace with isn't present

fixes #193
This commit is contained in:
Satyajit Sahoo
2019-12-07 05:20:12 +01:00
parent d618ab382e
commit 7b13a81ac8
2 changed files with 13 additions and 0 deletions

View File

@@ -22,6 +22,10 @@ const BaseRouter = {
const { name, key, params } = action.payload;
if (!state.routeNames.includes(name)) {
return null;
}
return {
...state,
routes: state.routes.map((route, i) =>

View File

@@ -65,6 +65,15 @@ it("doesn't handle REPLACE if source key isn't present", () => {
expect(result).toBe(null);
});
it("doesn't handle REPLACE if screen to replace with isn't present", () => {
const result = BaseRouter.getStateForAction(
STATE,
CommonActions.replace('nonexistent', { answer: 42 })
);
expect(result).toBe(null);
});
it('sets params for the focused screen with SET_PARAMS', () => {
const result = BaseRouter.getStateForAction(
STATE,