Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "Back button appearing in root of navbar scenario" #1433 #1838

Merged
merged 6 commits into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
287 changes: 192 additions & 95 deletions Example/__tests__/__snapshots__/Example-test.js.snap

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions Example/__tests__/index.android.js

This file was deleted.

12 changes: 0 additions & 12 deletions Example/__tests__/index.ios.js

This file was deleted.

7 changes: 7 additions & 0 deletions Example/jest-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jest.mock('Linking', () => ({
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
openURL: jest.fn(),
canOpenURL: jest.fn(),
getInitialURL: jest.fn(),
}));
10 changes: 8 additions & 2 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"jest-react-native": "^18.0.0",
"react-test-renderer": "~15.4.1"
"react-test-renderer": "~15.4.1",
"lodash.isequal": "^4.5.0",
"react-addons-pure-render-mixin": "^15.4.2",
"react-dom": "^15.4.2",
"react-native-experimental-navigation": "0.26.x",
"react-native-tabs": "^1.0.9",
"react-static-container": "1.0.1"
},
"jest": {
"preset": "react-native",
"setupFiles": ["./jest/setup.js"],
"setupFiles": ["./node_modules/react-native/jest/setup.js", "./jest-setup.js"],
"transformIgnorePatterns": [
"node_modules/(?!react-native|native-base|react-clone-referenced-element)"
]
Expand Down
23 changes: 21 additions & 2 deletions Example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ fbjs-scripts@^0.7.0:
semver "^5.1.0"
through2 "^2.0.0"

fbjs@^0.8.1, fbjs@^0.8.4, fbjs@^0.8.5:
fbjs@^0.8.1, fbjs@^0.8.4, fbjs@^0.8.5, fbjs@^0.8.9:
version "0.8.11"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.11.tgz#340b590b8a2278a01ef7467c07a16da9b753db24"
dependencies:
Expand Down Expand Up @@ -2363,6 +2363,10 @@ lodash.isarray@^3.0.0:
version "3.0.4"
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55"

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"

lodash.keys@^3.0.0:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a"
Expand Down Expand Up @@ -2848,6 +2852,12 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@~15.5.7:
version "15.5.8"
resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.5.8.tgz#6b7b2e141083be38c8595aa51fc55775c7199394"
dependencies:
fbjs "^0.8.9"

prr@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a"
Expand Down Expand Up @@ -2891,7 +2901,7 @@ raw-body@~2.1.2:
iconv-lite "0.4.13"
unpipe "1.0.0"

react-addons-pure-render-mixin@^15.0.2:
react-addons-pure-render-mixin@^15.0.2, react-addons-pure-render-mixin@^15.4.2:
version "15.4.2"
resolved "https://registry.yarnpkg.com/react-addons-pure-render-mixin/-/react-addons-pure-render-mixin-15.4.2.tgz#a8433c71c45e2368503721921dc47bdaf1fbabcd"
dependencies:
Expand All @@ -2906,6 +2916,15 @@ react-deep-force-update@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.0.1.tgz#f911b5be1d2a6fe387507dd6e9a767aa2924b4c7"

react-dom@^15.4.2:
version "15.5.4"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-15.5.4.tgz#ba0c28786fd52ed7e4f2135fe0288d462aef93da"
dependencies:
fbjs "^0.8.9"
loose-envify "^1.1.0"
object-assign "^4.1.0"
prop-types "~15.5.7"

react-native-button@^1.8.2:
version "1.8.2"
resolved "https://registry.yarnpkg.com/react-native-button/-/react-native-button-1.8.2.tgz#49e5cadd22ee443adea52a85539d288aa2117ade"
Expand Down
2 changes: 1 addition & 1 deletion src/Reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function inject(state, action, props, scenes) {
}

state.children = state.children.splice(0, 1);
state.children[0] = getInitialState(props, scenes, state.index, action);
state.children[0] = getInitialState(props, scenes, 0, action);

return {
...state,
Expand Down
17 changes: 17 additions & 0 deletions test/Reducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ describe('handling actions', () => {
</Scene>
</Scene>
</Scene>
<Scene key="foo" component={component} />
<Scene key="bar" component={component} />
</Scene>
);

Expand Down Expand Up @@ -162,6 +164,21 @@ describe('handling actions', () => {
expect(current.key).to.eq('hello_0_hello_');
});

it('reset to a correct scene on RESET', () => {
Actions.world();
expect(current.key).to.eq('world_0_world_content');

Actions.maps({ type: 'push' });
expect(current.key).to.eq('maps_0_maps_content');

Actions.map_tabs();
expect(current.key).to.eq('map_tabs_0_map_tab_1_');
expect(current.parentIndex).to.eq(1);
Actions.foo();
Actions.bar({ type: 'reset' });
expect(current.key).to.eq('bar_0_bar');
});

it('maintains scene parentIndex when switching tabs', () => {
Actions.world();
expect(current.key).to.eq('world_0_world_content');
Expand Down