Skip to content

Commit

Permalink
test: add test case for StateUtils.pop
Browse files Browse the repository at this point in the history
From the current implementation of `NavigationStateUtils.pop`, a new
test case was added to document the behavior when popping when the index
is at the first route and there are multiple routes.
  • Loading branch information
oltrep authored and satya164 committed Sep 2, 2020
1 parent fcd7d83 commit 1fa2edd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/core/src/__tests__/NavigationStateUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('StateUtils', () => {
expect(NavigationStateUtils.pop(state)).toEqual(newState);
});

it('does not pop route if not applicable', () => {
it('does not pop route if not applicable with single route config', () => {
const state = {
index: 0,
routes: [{ key: 'a', routeName }],
Expand All @@ -102,6 +102,18 @@ describe('StateUtils', () => {
expect(NavigationStateUtils.pop(state)).toBe(state);
});

it('does not pop route if not applicable with multiple route config', () => {
const state = {
index: 0,
routes: [
{ key: 'a', routeName },
{ key: 'b', routeName },
],
isTransitioning: false,
};
expect(NavigationStateUtils.pop(state)).toBe(state);
});

// Jump
it('jumps to new index', () => {
const state = {
Expand Down

0 comments on commit 1fa2edd

Please sign in to comment.