mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-26 09:14:22 +08:00
chore: configure bob
This commit is contained in:
@@ -48,6 +48,12 @@ jobs:
|
||||
- store_artifacts:
|
||||
path: coverage
|
||||
destination: coverage
|
||||
build:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/project
|
||||
- run: yarn prepare
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
@@ -60,3 +66,6 @@ workflows:
|
||||
- unit-tests:
|
||||
requires:
|
||||
- install-dependencies
|
||||
- build:
|
||||
requires:
|
||||
- install-dependencies
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
node_modules/
|
||||
dist/
|
||||
jest-setup.js
|
||||
lib/
|
||||
coverage/
|
||||
|
||||
3
packages/core/.gitignore
vendored
3
packages/core/.gitignore
vendored
@@ -54,3 +54,6 @@ types/
|
||||
|
||||
# Code coverage files
|
||||
coverage/
|
||||
|
||||
# generated by bob
|
||||
lib/
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"increment": "conventional:angular",
|
||||
"changelogCommand": "conventional-changelog -p angular | tail -n +3",
|
||||
"safeBump": false,
|
||||
"src": {
|
||||
"scripts": {
|
||||
"changelog": "conventional-changelog -p angular | tail -n +3"
|
||||
},
|
||||
"git": {
|
||||
"commitMessage": "chore: release %s",
|
||||
"tagName": "v%s"
|
||||
},
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@babel/preset-react',
|
||||
'@babel/preset-flow',
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
plugins: [
|
||||
'@babel/transform-block-scoping',
|
||||
// NOTE(brent): Intentionally leave ES6 imports alone, they supported and
|
||||
// recommended by Webpack
|
||||
// (https://webpack.js.org/api/module-methods/#es6-recommended) and of
|
||||
// course metro
|
||||
// '@babel/transform-modules-commonjs',
|
||||
'@babel/proposal-class-properties',
|
||||
'@babel/proposal-object-rest-spread',
|
||||
],
|
||||
};
|
||||
5
packages/core/commitlint.config.js
Normal file
5
packages/core/commitlint.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
};
|
||||
@@ -1,11 +1,17 @@
|
||||
{
|
||||
"extends": "../.eslintrc",
|
||||
'extends': '../.eslintrc',
|
||||
|
||||
"settings": {
|
||||
"import/core-modules": [ "expo", "@react-navigation/core", "react-navigation-stack" ]
|
||||
},
|
||||
'settings':
|
||||
{
|
||||
'import/core-modules':
|
||||
[
|
||||
'expo',
|
||||
'@react-navigation/core',
|
||||
'react-navigation-stack',
|
||||
'react-native-vector-icons',
|
||||
'@expo/vector-icons',
|
||||
],
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"react/prop-types": "off"
|
||||
}
|
||||
'rules': { 'react-native/no-inline-styles': 'off' },
|
||||
}
|
||||
|
||||
@@ -3,5 +3,3 @@
|
||||
*/
|
||||
|
||||
// No setup
|
||||
|
||||
import React from 'react';
|
||||
|
||||
@@ -2,27 +2,21 @@
|
||||
"name": "@react-navigation/core",
|
||||
"version": "3.3.1",
|
||||
"description": "Core utilities for the react-navigation framework",
|
||||
"main": "dist/index.js",
|
||||
"react-native": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
"main": "lib/commonjs/index.js",
|
||||
"react-native": "src/index.js",
|
||||
"module": "lib/module/index.js",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist/",
|
||||
"src/",
|
||||
"LICENSE.md",
|
||||
"README.md"
|
||||
"src",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"pretest": "yarn lint && yarn build",
|
||||
"test": "jest",
|
||||
"lint": "eslint .",
|
||||
"format": "eslint . --fix",
|
||||
"babel": "babel --extensions '.js,.ts,.tsx' --no-babelrc --config-file=./babel.config.publish.js src --ignore '**/__tests__/**' --copy-files --source-maps --delete-dir-on-start",
|
||||
"tsc": "tsc",
|
||||
"build": "yarn babel --out-dir dist && del-cli 'dist/**/__tests__' && yarn tsc --emitDeclarationOnly",
|
||||
"dev": "yarn babel --watch src --out-dir example/node_modules/@react-navigation/core/dist",
|
||||
"prepare": "yarn build",
|
||||
"release": "release-it"
|
||||
"lint": "eslint --ext .js,.ts,.tsx .",
|
||||
"typescript": "tsc --noEmit",
|
||||
"example": "yarn --cwd example",
|
||||
"bootstrap": "yarn && yarn example",
|
||||
"prepare": "bob build"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
@@ -44,44 +38,38 @@
|
||||
},
|
||||
"homepage": "https://github.com/react-navigation/react-navigation-core#readme",
|
||||
"dependencies": {
|
||||
"hoist-non-react-statics": "^2.5.5",
|
||||
"hoist-non-react-statics": "^3.3.0",
|
||||
"path-to-regexp": "^1.7.0",
|
||||
"query-string": "^6.2.0",
|
||||
"react-is": "^16.6.3"
|
||||
"query-string": "^6.4.2",
|
||||
"react-is": "^16.8.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.3",
|
||||
"@babel/core": "^7.3.4",
|
||||
"@babel/plugin-proposal-class-properties": "7.3.4",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.3.4",
|
||||
"@babel/plugin-transform-block-scoping": "7.3.4",
|
||||
"@babel/plugin-transform-modules-commonjs": "7.2.0",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/preset-typescript": "^7.3.3",
|
||||
"@react-navigation/core": "^3.2.1",
|
||||
"@react-navigation/native": "^3.3.0",
|
||||
"@babel/cli": "^7.4.3",
|
||||
"@commitlint/config-conventional": "^7.5.0",
|
||||
"@react-native-community/bob": "^0.3.4",
|
||||
"@react-navigation/core": "^3.3.1",
|
||||
"@react-navigation/native": "^3.4.1",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-jest": "^24.1.0",
|
||||
"babel-jest": "^24.7.1",
|
||||
"commitlint": "^7.5.2",
|
||||
"conventional-changelog-cli": "^2.0.5",
|
||||
"del-cli": "^1.1.0",
|
||||
"eslint": "^4.12.1",
|
||||
"eslint-config-satya164": "^1.0.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-satya164": "^2.4.1",
|
||||
"eslint-plugin-react-native-globals": "^0.1.0",
|
||||
"husky": "^1.1.2",
|
||||
"jest": "^24.1.0",
|
||||
"jest": "^24.7.1",
|
||||
"jest-expo": "^32.0.0",
|
||||
"metro-react-native-babel-preset": "^0.49.2",
|
||||
"prettier": "^1.13.6",
|
||||
"metro-react-native-babel-preset": "^0.53.1",
|
||||
"prettier": "^1.17.0",
|
||||
"react": "16.6.3",
|
||||
"react-dom": "16.6.3",
|
||||
"react-native": "^0.58.6",
|
||||
"react-native-testing-library": "^1.6.2",
|
||||
"react-test-renderer": "16.6.3",
|
||||
"release-it": "^7.6.1",
|
||||
"ts-jest": "^24.0.0",
|
||||
"typescript": "^3.3.3333"
|
||||
"react-native-testing-library": "^1.7.0",
|
||||
"react-test-renderer": "16.8.6",
|
||||
"release-it": "^10.4.2",
|
||||
"typescript": "^3.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*"
|
||||
@@ -99,28 +87,30 @@
|
||||
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-navigation)"
|
||||
],
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": "ts-jest"
|
||||
"^.+\\.(js|ts|tsx)$": "babel-jest"
|
||||
},
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"js"
|
||||
],
|
||||
"modulePathIgnorePatterns": [
|
||||
"<rootDir>/example/"
|
||||
],
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"tsConfig": "./tsconfig.test.json",
|
||||
"diagnostics": {
|
||||
"ignoreCodes": [
|
||||
151001
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
"<rootDir>/example/",
|
||||
"<rootDir>/lib/"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"trailingComma": "es5",
|
||||
"singleQuote": true
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "yarn lint && yarn typescript && yarn test",
|
||||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
"output": "lib",
|
||||
"targets": [
|
||||
"commonjs",
|
||||
"module",
|
||||
"typescript"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('StateUtils', () => {
|
||||
};
|
||||
expect(() =>
|
||||
NavigationStateUtils.push(state, { key: 'a', routeName })
|
||||
).toThrow();
|
||||
).toThrow('should not push route with duplicated key a');
|
||||
});
|
||||
|
||||
// Pop
|
||||
@@ -112,7 +112,9 @@ describe('StateUtils', () => {
|
||||
routes: [{ key: 'a', routeName }, { key: 'b', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => NavigationStateUtils.jumpToIndex(state, 2)).toThrow();
|
||||
expect(() => NavigationStateUtils.jumpToIndex(state, 2)).toThrow(
|
||||
'invalid index 2 to jump to'
|
||||
);
|
||||
});
|
||||
|
||||
it('jumps to new key', () => {
|
||||
@@ -136,7 +138,9 @@ describe('StateUtils', () => {
|
||||
routes: [{ key: 'a', routeName }, { key: 'b', routeName }],
|
||||
isTransitioning: false,
|
||||
};
|
||||
expect(() => NavigationStateUtils.jumpTo(state, 'c')).toThrow();
|
||||
expect(() => NavigationStateUtils.jumpTo(state, 'c')).toThrow(
|
||||
'invalid index -1 to jump to'
|
||||
);
|
||||
});
|
||||
|
||||
it('move backwards', () => {
|
||||
@@ -234,7 +238,7 @@ describe('StateUtils', () => {
|
||||
|
||||
expect(() => {
|
||||
NavigationStateUtils.reset(state, []);
|
||||
}).toThrow();
|
||||
}).toThrow('invalid routes to replace');
|
||||
});
|
||||
|
||||
it('Resets routes with index', () => {
|
||||
@@ -262,6 +266,6 @@ describe('StateUtils', () => {
|
||||
[{ key: 'x', routeName }, { key: 'y', routeName }],
|
||||
100
|
||||
);
|
||||
}).toThrow();
|
||||
}).toThrow('invalid index 100 to reset');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import getChildEventSubscriber from '../getChildEventSubscriber';
|
||||
|
||||
test('child action events only flow when focused', () => {
|
||||
it('child action events only flow when focused', () => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitParentAction = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
@@ -50,7 +50,7 @@ test('child action events only flow when focused', () => {
|
||||
expect(childDidFocusHandler.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
test('grandchildren subscription', () => {
|
||||
it('grandchildren subscription', () => {
|
||||
const grandParentSubscriber = jest.fn();
|
||||
const emitGrandParentAction = payload => {
|
||||
grandParentSubscriber.mock.calls.forEach(subs => {
|
||||
@@ -117,7 +117,7 @@ test('grandchildren subscription', () => {
|
||||
expect(childDidFocusHandler.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
test('grandchildren transitions', () => {
|
||||
it('grandchildren transitions', () => {
|
||||
const grandParentSubscriber = jest.fn();
|
||||
const emitGrandParentAction = payload => {
|
||||
grandParentSubscriber.mock.calls.forEach(subs => {
|
||||
@@ -210,7 +210,7 @@ test('grandchildren transitions', () => {
|
||||
expect(childActionHandler.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
test('grandchildren pass through transitions', () => {
|
||||
it('grandchildren pass through transitions', () => {
|
||||
const grandParentSubscriber = jest.fn();
|
||||
const emitGrandParentAction = payload => {
|
||||
grandParentSubscriber.mock.calls.forEach(subs => {
|
||||
@@ -303,7 +303,7 @@ test('grandchildren pass through transitions', () => {
|
||||
expect(childActionHandler.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
test('child focus with transition', () => {
|
||||
it('child focus with transition', () => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitParentAction = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
@@ -396,7 +396,7 @@ test('child focus with transition', () => {
|
||||
expect(childDidBlurHandler.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
test('child focus with immediate transition', () => {
|
||||
it('child focus with immediate transition', () => {
|
||||
const parentSubscriber = jest.fn();
|
||||
const emitParentAction = payload => {
|
||||
parentSubscriber.mock.calls.forEach(subs => {
|
||||
@@ -484,7 +484,7 @@ const setupEventTest = (subscriptionKey, initialLastFocusEvent) => {
|
||||
return { emitEvent, handlers, evtProvider };
|
||||
};
|
||||
|
||||
test('immediate back with uncompleted transition will focus first screen again', () => {
|
||||
it('immediate back with uncompleted transition will focus first screen again', () => {
|
||||
const { handlers, emitEvent } = setupEventTest('key0', 'didFocus');
|
||||
emitEvent({
|
||||
type: 'action',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import getNavigation from '../getNavigation';
|
||||
|
||||
test('getNavigation provides default action helpers', () => {
|
||||
it('getNavigation provides default action helpers', () => {
|
||||
const router = {
|
||||
getActionCreators: () => ({}),
|
||||
getStateForAction(action, lastState = {}) {
|
||||
@@ -26,7 +26,7 @@ test('getNavigation provides default action helpers', () => {
|
||||
expect(dispatch.mock.calls[0][0].routeName).toBe('GreatRoute');
|
||||
});
|
||||
|
||||
test('getNavigation provides router action helpers', () => {
|
||||
it('getNavigation provides router action helpers', () => {
|
||||
const router = {
|
||||
getActionCreators: () => ({
|
||||
foo: bar => ({ type: 'FooBarAction', bar }),
|
||||
@@ -54,7 +54,7 @@ test('getNavigation provides router action helpers', () => {
|
||||
expect(dispatch.mock.calls[0][0].bar).toBe('Great');
|
||||
});
|
||||
|
||||
test('getNavigation get child navigation with router', () => {
|
||||
it('getNavigation get child navigation with router', () => {
|
||||
const actionSubscribers = new Set();
|
||||
let navigation = null;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ const performRouterTest = createTestRouter => {
|
||||
},
|
||||
});
|
||||
|
||||
test('Handles empty URIs with empty action', () => {
|
||||
it('Handles empty URIs with empty action', () => {
|
||||
const router = createTestRouter(
|
||||
{
|
||||
Foo: {
|
||||
@@ -100,7 +100,7 @@ const performRouterTest = createTestRouter => {
|
||||
);
|
||||
});
|
||||
|
||||
test('Handles paths with several params', () => {
|
||||
it('Handles paths with several params', () => {
|
||||
const router = createTestRouter({
|
||||
Person: {
|
||||
path: 'people/:person',
|
||||
@@ -150,7 +150,7 @@ const performRouterTest = createTestRouter => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles empty path configuration', () => {
|
||||
it('Handles empty path configuration', () => {
|
||||
const router = createTestRouter({
|
||||
Foo: {
|
||||
screen: () => <div />,
|
||||
@@ -168,7 +168,7 @@ const performRouterTest = createTestRouter => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles wildcard path configuration', () => {
|
||||
it('Handles wildcard path configuration', () => {
|
||||
const router = createTestRouter({
|
||||
Foo: {
|
||||
screen: () => <div />,
|
||||
@@ -195,7 +195,7 @@ const performRouterTest = createTestRouter => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Null path behavior', () => {
|
||||
it('Null path behavior', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const router = createTestRouter({
|
||||
Bar: {
|
||||
@@ -219,7 +219,7 @@ const performRouterTest = createTestRouter => {
|
||||
expect(state1.routes[state1.index].routeName).toBe('Baz');
|
||||
});
|
||||
|
||||
test('Multiple null path sub routers path behavior', () => {
|
||||
it('Multiple null path sub routers path behavior', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
ScreenB.router = createTestRouter({
|
||||
@@ -266,7 +266,7 @@ const performRouterTest = createTestRouter => {
|
||||
expect(action3.action.params.id).toBe('asdf');
|
||||
});
|
||||
|
||||
test('Null and empty string path sub routers behavior', () => {
|
||||
it('Null and empty string path sub routers behavior', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
ScreenB.router = createTestRouter({
|
||||
@@ -311,7 +311,7 @@ const performRouterTest = createTestRouter => {
|
||||
expect(action3).toBe(null);
|
||||
});
|
||||
|
||||
test('Empty path acts as wildcard for nested router', () => {
|
||||
it('Empty path acts as wildcard for nested router', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const Foo = () => <div />;
|
||||
const ScreenC = () => <div />;
|
||||
@@ -338,7 +338,7 @@ const performRouterTest = createTestRouter => {
|
||||
expect(action0.action.action.routeName).toBe('Bar');
|
||||
});
|
||||
|
||||
test('Gets deep path with pure wildcard match', () => {
|
||||
it('Gets deep path with pure wildcard match', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const ScreenC = () => <div />;
|
||||
@@ -418,7 +418,7 @@ const performRouterTest = createTestRouter => {
|
||||
}
|
||||
});
|
||||
|
||||
test('URI encoded string get passed to deep link', () => {
|
||||
it('URI encoded string get passed to deep link', () => {
|
||||
const uri = 'people/2018%2F02%2F07';
|
||||
const action = testRouter.getActionForPathAndParams(uri);
|
||||
expect(action).toEqual({
|
||||
@@ -440,7 +440,7 @@ const performRouterTest = createTestRouter => {
|
||||
});
|
||||
});
|
||||
|
||||
test('URI encoded path param gets parsed and correctly printed', () => {
|
||||
it('URI encoded path param gets parsed and correctly printed', () => {
|
||||
const action = testRouter.getActionForPathAndParams('people/Henry%20L');
|
||||
expect(action).toEqual({
|
||||
routeName: 'person',
|
||||
@@ -455,7 +455,7 @@ const performRouterTest = createTestRouter => {
|
||||
expect(out.params).toEqual({});
|
||||
});
|
||||
|
||||
test('Querystring params get passed to nested deep link', () => {
|
||||
it('Querystring params get passed to nested deep link', () => {
|
||||
const action = testRouter.getActionForPathAndParams(
|
||||
'main/p/4/list/10259959195',
|
||||
{ code: 'test', foo: 'bar' }
|
||||
@@ -519,7 +519,7 @@ const performRouterTest = createTestRouter => {
|
||||
});
|
||||
});
|
||||
|
||||
test('paths option on router overrides path from route config', () => {
|
||||
it('paths option on router overrides path from route config', () => {
|
||||
const router = createTestRouter(
|
||||
{
|
||||
main: {
|
||||
@@ -537,7 +537,7 @@ const performRouterTest = createTestRouter => {
|
||||
expect(action.routeName).toEqual('baz');
|
||||
});
|
||||
|
||||
test('paths option set as null on router overrides path from route config', () => {
|
||||
it('paths option set as null on router overrides path from route config', () => {
|
||||
const router = createTestRouter(
|
||||
{
|
||||
main: {
|
||||
@@ -563,7 +563,7 @@ describe('Path handling for switch router', () => {
|
||||
performRouterTest(SwitchRouter);
|
||||
});
|
||||
|
||||
test('Handles nested switch routers', () => {
|
||||
it('Handles nested switch routers', () => {
|
||||
const AScreen = () => <div />;
|
||||
const DocsNavigator = () => <div />;
|
||||
DocsNavigator.router = SwitchRouter({
|
||||
@@ -600,7 +600,7 @@ const performRouteNameAsPathDisabledTest = createTestRouter => {
|
||||
{ disableRouteNamePaths: true }
|
||||
);
|
||||
|
||||
test('disableRouteNamePaths option on router prevent the default path to be the routeName', () => {
|
||||
it('disableRouteNamePaths option on router prevent the default path to be the routeName', () => {
|
||||
const action = router.getActionForPathAndParams('baz', {});
|
||||
|
||||
expect(action.routeName).toBe('A');
|
||||
|
||||
@@ -27,7 +27,7 @@ Object.keys(ROUTERS).forEach(routerName => {
|
||||
const Router = ROUTERS[routerName];
|
||||
|
||||
describe(`General router features - ${routerName}`, () => {
|
||||
test(`title is configurable using navigationOptions and getScreenOptions - ${routerName}`, () => {
|
||||
it(`title is configurable using navigationOptions and getScreenOptions - ${routerName}`, () => {
|
||||
class FooView extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
@@ -89,7 +89,7 @@ Object.keys(ROUTERS).forEach(routerName => {
|
||||
).toEqual('Baz-123');
|
||||
});
|
||||
|
||||
test(`set params works in ${routerName}`, () => {
|
||||
it(`set params works in ${routerName}`, () => {
|
||||
class FooView extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
@@ -116,7 +116,7 @@ Object.keys(ROUTERS).forEach(routerName => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Nested navigate behavior test', () => {
|
||||
it('Nested navigate behavior test', () => {
|
||||
const Leaf = () => <div />;
|
||||
|
||||
const First = () => <div />;
|
||||
@@ -185,7 +185,7 @@ test('Nested navigate behavior test', () => {
|
||||
expect(state5.routes[1].routes[0].index).toEqual(0); // first.first1
|
||||
});
|
||||
|
||||
test('Handles no-op actions with tabs within stack router', () => {
|
||||
it('Handles no-op actions with tabs within stack router', () => {
|
||||
const BarView = () => <div />;
|
||||
const FooTabNavigator = () => <div />;
|
||||
FooTabNavigator.router = TabRouter({
|
||||
@@ -216,7 +216,7 @@ test('Handles no-op actions with tabs within stack router', () => {
|
||||
expect(state2).toEqual(state3);
|
||||
});
|
||||
|
||||
test('Handles deep action', () => {
|
||||
it('Handles deep action', () => {
|
||||
const BarView = () => <div />;
|
||||
const FooTabNavigator = () => <div />;
|
||||
FooTabNavigator.router = TabRouter({
|
||||
@@ -253,7 +253,7 @@ test('Handles deep action', () => {
|
||||
expect(state2 && state2.routes[1].index).toEqual(1);
|
||||
});
|
||||
|
||||
test('Handles the navigate action with params', () => {
|
||||
it('Handles the navigate action with params', () => {
|
||||
const FooTabNavigator = () => <div />;
|
||||
FooTabNavigator.router = TabRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -289,7 +289,7 @@ test('Handles the navigate action with params', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('Handles the setParams action', () => {
|
||||
it('Handles the setParams action', () => {
|
||||
const FooTabNavigator = () => <div />;
|
||||
FooTabNavigator.router = TabRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -317,7 +317,7 @@ test('Handles the setParams action', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('Supports lazily-evaluated getScreen', () => {
|
||||
it('Supports lazily-evaluated getScreen', () => {
|
||||
const BarView = () => <div />;
|
||||
const FooTabNavigator = () => <div />;
|
||||
FooTabNavigator.router = TabRouter({
|
||||
@@ -353,7 +353,7 @@ test('Supports lazily-evaluated getScreen', () => {
|
||||
expect(state2).toEqual(state3);
|
||||
});
|
||||
|
||||
test('Does not switch tab index when TabRouter child handles COMPLETE_NAVIGATION or SET_PARAMS', () => {
|
||||
it('Does not switch tab index when TabRouter child handles COMPLETE_NAVIGATION or SET_PARAMS', () => {
|
||||
const FooStackNavigator = () => <div />;
|
||||
const BarView = () => <div />;
|
||||
FooStackNavigator.router = StackRouter({
|
||||
@@ -410,7 +410,7 @@ test('Does not switch tab index when TabRouter child handles COMPLETE_NAVIGATION
|
||||
expect(stateAfterSetParams.index).toEqual(1);
|
||||
});
|
||||
|
||||
test('Inner actions are only unpacked if the current tab matches', () => {
|
||||
it('Inner actions are only unpacked if the current tab matches', () => {
|
||||
const PlainScreen = () => <div />;
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
|
||||
@@ -76,7 +76,7 @@ const TestStackRouter = StackRouter({
|
||||
});
|
||||
|
||||
describe('StackRouter', () => {
|
||||
test('Gets the active screen for a given state', () => {
|
||||
it('Gets the active screen for a given state', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
@@ -111,7 +111,7 @@ describe('StackRouter', () => {
|
||||
).toBe(BarScreen);
|
||||
});
|
||||
|
||||
test('Handles getScreen in getComponentForState', () => {
|
||||
it('Handles getScreen in getComponentForState', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
@@ -146,7 +146,7 @@ describe('StackRouter', () => {
|
||||
).toBe(BarScreen);
|
||||
});
|
||||
|
||||
test('Gets the screen for given route', () => {
|
||||
it('Gets the screen for given route', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = class extends React.Component {
|
||||
render() {
|
||||
@@ -175,7 +175,7 @@ describe('StackRouter', () => {
|
||||
expect(router.getComponentForRouteName('baz')).toBe(BazScreen);
|
||||
});
|
||||
|
||||
test('Handles getScreen in getComponent', () => {
|
||||
it('Handles getScreen in getComponent', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = class extends React.Component {
|
||||
render() {
|
||||
@@ -204,7 +204,7 @@ describe('StackRouter', () => {
|
||||
expect(router.getComponentForRouteName('baz')).toBe(BazScreen);
|
||||
});
|
||||
|
||||
test('Parses simple paths', () => {
|
||||
it('Parses simple paths', () => {
|
||||
expect(AuthNavigator.router.getActionForPathAndParams('login')).toEqual({
|
||||
type: NavigationActions.NAVIGATE,
|
||||
routeName: 'login',
|
||||
@@ -212,7 +212,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Parses paths with a param', () => {
|
||||
it('Parses paths with a param', () => {
|
||||
expect(TestStackRouter.getActionForPathAndParams('people/foo')).toEqual({
|
||||
type: NavigationActions.NAVIGATE,
|
||||
routeName: 'person',
|
||||
@@ -222,7 +222,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Parses paths with a query', () => {
|
||||
it('Parses paths with a query', () => {
|
||||
expect(
|
||||
TestStackRouter.getActionForPathAndParams('people/foo', {
|
||||
code: 'test',
|
||||
@@ -239,7 +239,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Parses paths with an empty query value', () => {
|
||||
it('Parses paths with an empty query value', () => {
|
||||
expect(
|
||||
TestStackRouter.getActionForPathAndParams('people/foo', {
|
||||
code: '',
|
||||
@@ -256,7 +256,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Correctly parses a path without arguments into an action chain', () => {
|
||||
it('Correctly parses a path without arguments into an action chain', () => {
|
||||
const uri = 'auth/login';
|
||||
const action = TestStackRouter.getActionForPathAndParams(uri);
|
||||
expect(action).toEqual({
|
||||
@@ -271,7 +271,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Correctly parses a path with arguments into an action chain', () => {
|
||||
it('Correctly parses a path with arguments into an action chain', () => {
|
||||
const uri = 'main/p/4/list/10259959195';
|
||||
const action = TestStackRouter.getActionForPathAndParams(uri);
|
||||
expect(action).toEqual({
|
||||
@@ -295,7 +295,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Correctly parses a path to the router connected to another router through a pure wildcard route into an action chain', () => {
|
||||
it('Correctly parses a path to the router connected to another router through a pure wildcard route into an action chain', () => {
|
||||
const uri = 'b/123';
|
||||
const action = TestStackRouter.getActionForPathAndParams(uri);
|
||||
expect(action).toEqual({
|
||||
@@ -312,13 +312,13 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Correctly returns null action for non-existent path', () => {
|
||||
it('Correctly returns null action for non-existent path', () => {
|
||||
const uri = 'asdf/1234';
|
||||
const action = TestStackRouter.getActionForPathAndParams(uri);
|
||||
expect(action).toEqual(null);
|
||||
});
|
||||
|
||||
test('Correctly returns action chain for partially matched path', () => {
|
||||
it('Correctly returns action chain for partially matched path', () => {
|
||||
const uri = 'auth/login';
|
||||
const action = TestStackRouter.getActionForPathAndParams(uri);
|
||||
expect(action).toEqual({
|
||||
@@ -333,7 +333,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Correctly returns action for path with multiple parameters', () => {
|
||||
it('Correctly returns action for path with multiple parameters', () => {
|
||||
const path = 'fo/22/b/hello';
|
||||
const action = TestStackRouter.getActionForPathAndParams(path);
|
||||
expect(action).toEqual({
|
||||
@@ -352,7 +352,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Pushes other navigators when navigating to an unopened route name', () => {
|
||||
it('Pushes other navigators when navigating to an unopened route name', () => {
|
||||
const Bar = () => <div />;
|
||||
Bar.router = StackRouter({
|
||||
baz: { screen: () => <div /> },
|
||||
@@ -378,7 +378,7 @@ describe('StackRouter', () => {
|
||||
expect(pushedState.routes[1].routes[1].routeName).toEqual('qux');
|
||||
});
|
||||
|
||||
test('push bubbles up', () => {
|
||||
it('push bubbles up', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -408,7 +408,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.routes.length).toEqual(3);
|
||||
});
|
||||
|
||||
test('pop bubbles up', () => {
|
||||
it('pop bubbles up', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -437,7 +437,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.index).toEqual(0);
|
||||
});
|
||||
|
||||
test('Handle navigation to nested navigator', () => {
|
||||
it('Handle navigation to nested navigator', () => {
|
||||
const action = TestStackRouter.getActionForPathAndParams('fo/22/b/hello');
|
||||
/* $FlowFixMe */
|
||||
const state2 = TestStackRouter.getStateForAction(action);
|
||||
@@ -468,7 +468,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('popToTop bubbles up', () => {
|
||||
it('popToTop bubbles up', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -497,7 +497,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.index).toEqual(0);
|
||||
});
|
||||
|
||||
test('popToTop targets StackRouter by key if specified', () => {
|
||||
it('popToTop targets StackRouter by key if specified', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -526,7 +526,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.index).toEqual(0);
|
||||
});
|
||||
|
||||
test('pop action works as expected', () => {
|
||||
it('pop action works as expected', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -564,7 +564,7 @@ describe('StackRouter', () => {
|
||||
expect(poppedState3.isTransitioning).toBe(true);
|
||||
});
|
||||
|
||||
test('popToTop works as expected', () => {
|
||||
it('popToTop works as expected', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -600,7 +600,7 @@ describe('StackRouter', () => {
|
||||
expect(poppedImmediatelyState.isTransitioning).toBe(false);
|
||||
});
|
||||
|
||||
test('Navigate does not push duplicate routeName', () => {
|
||||
it('Navigate does not push duplicate routeName', () => {
|
||||
const TestRouter = StackRouter(
|
||||
{
|
||||
foo: { screen: () => <div /> },
|
||||
@@ -622,7 +622,7 @@ describe('StackRouter', () => {
|
||||
expect(navigateOnBarState).toEqual(null);
|
||||
});
|
||||
|
||||
test('Navigate focuses given routeName if already active in stack', () => {
|
||||
it('Navigate focuses given routeName if already active in stack', () => {
|
||||
const TestRouter = StackRouter(
|
||||
{
|
||||
foo: { screen: () => <div /> },
|
||||
@@ -652,7 +652,7 @@ describe('StackRouter', () => {
|
||||
expect(fooState.routes[0].routeName).toEqual('foo');
|
||||
});
|
||||
|
||||
test('Navigate pushes duplicate routeName if unique key is provided', () => {
|
||||
it('Navigate pushes duplicate routeName if unique key is provided', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -672,7 +672,7 @@ describe('StackRouter', () => {
|
||||
expect(pushedTwiceState.routes[2].routeName).toEqual('bar');
|
||||
});
|
||||
|
||||
test('Navigate from top propagates to any arbitary depth of stacks', () => {
|
||||
it('Navigate from top propagates to any arbitary depth of stacks', () => {
|
||||
const GrandChildNavigator = () => <div />;
|
||||
GrandChildNavigator.router = StackRouter({
|
||||
Quux: { screen: () => <div /> },
|
||||
@@ -707,7 +707,7 @@ describe('StackRouter', () => {
|
||||
expect(state2.routes[1].routes[1].routes[1].routeName).toEqual('Corge');
|
||||
});
|
||||
|
||||
test('Navigate to initial screen is possible', () => {
|
||||
it('Navigate to initial screen is possible', () => {
|
||||
const TestRouter = StackRouter(
|
||||
{
|
||||
foo: { screen: () => <div /> },
|
||||
@@ -723,7 +723,7 @@ describe('StackRouter', () => {
|
||||
expect(pushedState).toEqual(null);
|
||||
});
|
||||
|
||||
test('Navigate with key and without it is idempotent', () => {
|
||||
it('Navigate with key and without it is idempotent', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -743,7 +743,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
|
||||
// https://github.com/react-navigation/react-navigation/issues/4063
|
||||
test('Navigate on inactive stackrouter is idempotent', () => {
|
||||
it('Navigate on inactive stackrouter is idempotent', () => {
|
||||
const FirstChildNavigator = () => <div />;
|
||||
FirstChildNavigator.router = StackRouter({
|
||||
First1: () => <div />,
|
||||
@@ -791,7 +791,7 @@ describe('StackRouter', () => {
|
||||
expect(firstAgain.routes.length).toEqual(2);
|
||||
});
|
||||
|
||||
test('Navigate to current routeName returns null to indicate handled action', () => {
|
||||
it('Navigate to current routeName returns null to indicate handled action', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -804,7 +804,7 @@ describe('StackRouter', () => {
|
||||
expect(navigatedState).toBe(null);
|
||||
});
|
||||
|
||||
test('Push behaves like navigate, except for key', () => {
|
||||
it('Push behaves like navigate, except for key', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -821,10 +821,10 @@ describe('StackRouter', () => {
|
||||
{ type: StackActions.PUSH, routeName: 'bar', key: 'a' },
|
||||
pushedState
|
||||
);
|
||||
}).toThrow();
|
||||
}).toThrow('StackRouter does not support key on the push action');
|
||||
});
|
||||
|
||||
test('Push adds new routes every time', () => {
|
||||
it('Push adds new routes every time', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -844,7 +844,7 @@ describe('StackRouter', () => {
|
||||
expect(secondPushedState.routes[2].routeName).toEqual('bar');
|
||||
});
|
||||
|
||||
test('Navigate backwards with key removes leading routes', () => {
|
||||
it('Navigate backwards with key removes leading routes', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -875,7 +875,7 @@ describe('StackRouter', () => {
|
||||
expect(navigatedBackToFirstRouteState.routes.length).toEqual(1);
|
||||
});
|
||||
|
||||
test('Handle basic stack logic for plain components', () => {
|
||||
it('Handle basic stack logic for plain components', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
@@ -928,7 +928,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Replace action works', () => {
|
||||
it('Replace action works', () => {
|
||||
const TestRouter = StackRouter({
|
||||
foo: { screen: () => <div /> },
|
||||
bar: { screen: () => <div /> },
|
||||
@@ -963,7 +963,7 @@ describe('StackRouter', () => {
|
||||
expect(replacedState2.routes[0].routeName).toEqual('bar');
|
||||
});
|
||||
|
||||
test('Replace action returns most recent route if no key is provided', () => {
|
||||
it('Replace action returns most recent route if no key is provided', () => {
|
||||
const GrandChildNavigator = () => <div />;
|
||||
GrandChildNavigator.router = StackRouter({
|
||||
Quux: { screen: () => <div /> },
|
||||
@@ -1034,7 +1034,7 @@ describe('StackRouter', () => {
|
||||
expect(replacedCurrentScreen.params.meaning).toEqual(42);
|
||||
});
|
||||
|
||||
test('Handles push transition logic with completion action', () => {
|
||||
it('Handles push transition logic with completion action', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
@@ -1067,7 +1067,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.isTransitioning).toEqual(false);
|
||||
});
|
||||
|
||||
test('Completion action does not work with incorrect key', () => {
|
||||
it('Completion action does not work with incorrect key', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
Foo: {
|
||||
@@ -1094,7 +1094,7 @@ describe('StackRouter', () => {
|
||||
expect(outputState.isTransitioning).toEqual(true);
|
||||
});
|
||||
|
||||
test('Completion action does not work with incorrect toChildKey', () => {
|
||||
it('Completion action does not work with incorrect toChildKey', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
Foo: {
|
||||
@@ -1122,7 +1122,7 @@ describe('StackRouter', () => {
|
||||
expect(outputState.isTransitioning).toEqual(true);
|
||||
});
|
||||
|
||||
test('Back action parent is prioritized over inactive child routers', () => {
|
||||
it('Back action parent is prioritized over inactive child routers', () => {
|
||||
const Bar = () => <div />;
|
||||
Bar.router = StackRouter({
|
||||
baz: { screen: () => <div /> },
|
||||
@@ -1159,7 +1159,7 @@ describe('StackRouter', () => {
|
||||
expect(testState.routes[1].index).toBe(1);
|
||||
});
|
||||
|
||||
test('Handle basic stack logic for components with router', () => {
|
||||
it('Handle basic stack logic for components with router', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
BarScreen.router = StackRouter({
|
||||
@@ -1217,7 +1217,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Gets deep path (stack behavior)', () => {
|
||||
it('Gets deep path (stack behavior)', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
ScreenA.router = StackRouter({
|
||||
@@ -1258,7 +1258,7 @@ describe('StackRouter', () => {
|
||||
expect(params).toEqual({});
|
||||
});
|
||||
|
||||
test('Handle goBack identified by key', () => {
|
||||
it('Handle goBack identified by key', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
@@ -1304,7 +1304,7 @@ describe('StackRouter', () => {
|
||||
expect(state5).toEqual(state);
|
||||
});
|
||||
|
||||
test('Handle initial route navigation', () => {
|
||||
it('Handle initial route navigation', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter(
|
||||
@@ -1332,7 +1332,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Initial route params appear in nav state', () => {
|
||||
it('Initial route params appear in nav state', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const router = StackRouter(
|
||||
{
|
||||
@@ -1357,7 +1357,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('params in route config are merged with initialRouteParams', () => {
|
||||
it('params in route config are merged with initialRouteParams', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const router = StackRouter(
|
||||
{
|
||||
@@ -1383,7 +1383,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Action params appear in nav state', () => {
|
||||
it('Action params appear in nav state', () => {
|
||||
const FooScreen = () => <div />;
|
||||
const BarScreen = () => <div />;
|
||||
const router = StackRouter({
|
||||
@@ -1409,7 +1409,7 @@ describe('StackRouter', () => {
|
||||
expect(state2 && state2.routes[1].params).toEqual({ bar: '42' });
|
||||
});
|
||||
|
||||
test('Handles the SetParams action', () => {
|
||||
it('Handles the SetParams action', () => {
|
||||
const router = StackRouter(
|
||||
{
|
||||
Foo: {
|
||||
@@ -1440,7 +1440,7 @@ describe('StackRouter', () => {
|
||||
expect(state2 && state2.routes[0].params).toEqual({ name: 'Qux' });
|
||||
});
|
||||
|
||||
test('Handles the SetParams action for inactive routes', () => {
|
||||
it('Handles the SetParams action for inactive routes', () => {
|
||||
const router = StackRouter(
|
||||
{
|
||||
Foo: {
|
||||
@@ -1481,7 +1481,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles the setParams action with nested routers', () => {
|
||||
it('Handles the setParams action with nested routers', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -1510,7 +1510,7 @@ describe('StackRouter', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('Handles the reset action', () => {
|
||||
it('Handles the reset action', () => {
|
||||
const router = StackRouter({
|
||||
Foo: {
|
||||
screen: () => <div />,
|
||||
@@ -1546,7 +1546,7 @@ describe('StackRouter', () => {
|
||||
expect(state2 && state2.routes[1].routeName).toEqual('Bar');
|
||||
});
|
||||
|
||||
test('Handles the reset action only with correct key set', () => {
|
||||
it('Handles the reset action only with correct key set', () => {
|
||||
const router = StackRouter({
|
||||
Foo: {
|
||||
screen: () => <div />,
|
||||
@@ -1589,7 +1589,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.routes[1].routeName).toEqual('Bar');
|
||||
});
|
||||
|
||||
test('Handles the reset action with nested Router', () => {
|
||||
it('Handles the reset action with nested Router', () => {
|
||||
const ChildRouter = StackRouter({
|
||||
baz: {
|
||||
screen: () => <div />,
|
||||
@@ -1629,7 +1629,7 @@ describe('StackRouter', () => {
|
||||
expect(state2 && state2.routes[0].routes[0].routeName).toEqual('baz');
|
||||
});
|
||||
|
||||
test('Handles the reset action with a key', () => {
|
||||
it('Handles the reset action with a key', () => {
|
||||
const ChildRouter = StackRouter({
|
||||
baz: {
|
||||
screen: () => <div />,
|
||||
@@ -1696,7 +1696,7 @@ describe('StackRouter', () => {
|
||||
expect(state4 && state4.routes[0].routeName).toEqual('Bar');
|
||||
});
|
||||
|
||||
test('Handles the navigate action with params and nested StackRouter', () => {
|
||||
it('Handles the navigate action with params and nested StackRouter', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({ Baz: { screen: () => <div /> } });
|
||||
|
||||
@@ -1723,7 +1723,7 @@ describe('StackRouter', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('Navigate action to previous nested StackRouter causes isTransitioning start', () => {
|
||||
it('Navigate action to previous nested StackRouter causes isTransitioning start', () => {
|
||||
const ChildNavigator = () => <div />;
|
||||
ChildNavigator.router = StackRouter({
|
||||
Baz: { screen: () => <div /> },
|
||||
@@ -1751,7 +1751,7 @@ describe('StackRouter', () => {
|
||||
expect(state2.isTransitioning).toEqual(true);
|
||||
});
|
||||
|
||||
test('Handles the navigate action with params and nested StackRouter as a first action', () => {
|
||||
it('Handles the navigate action with params and nested StackRouter as a first action', () => {
|
||||
const state = TestStackRouter.getStateForAction({
|
||||
type: NavigationActions.NAVIGATE,
|
||||
routeName: 'main',
|
||||
@@ -1871,7 +1871,7 @@ describe('StackRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles deep navigate completion action', () => {
|
||||
it('Handles deep navigate completion action', () => {
|
||||
const LeafScreen = () => <div />;
|
||||
const FooScreen = () => <div />;
|
||||
FooScreen.router = StackRouter({
|
||||
@@ -1916,7 +1916,7 @@ describe('StackRouter', () => {
|
||||
expect(state3 && state3.routes[0].isTransitioning).toEqual(false);
|
||||
});
|
||||
|
||||
test('order of handling navigate action is correct for nested stackrouters', () => {
|
||||
it('order of handling navigate action is correct for nested stackrouters', () => {
|
||||
const Screen = () => <div />;
|
||||
const NestedStack = () => <div />;
|
||||
let nestedRouter = StackRouter({
|
||||
@@ -1981,7 +1981,7 @@ describe('StackRouter', () => {
|
||||
expect(activeState5.routes[activeState5.index].routeName).toEqual('Bar');
|
||||
});
|
||||
|
||||
test('order of handling navigate action is correct for nested stackrouters 2', () => {
|
||||
it('order of handling navigate action is correct for nested stackrouters 2', () => {
|
||||
const Screen = () => <div />;
|
||||
const NestedStack = () => <div />;
|
||||
const OtherNestedStack = () => <div />;
|
||||
|
||||
@@ -6,7 +6,7 @@ import StackRouter from '../StackRouter';
|
||||
import NavigationActions from '../../NavigationActions';
|
||||
|
||||
describe('SwitchRouter', () => {
|
||||
test('resets the route when unfocusing a tab by default', () => {
|
||||
it('resets the route when unfocusing a tab by default', () => {
|
||||
const router = getExampleRouter();
|
||||
const state = router.getStateForAction({ type: NavigationActions.INIT });
|
||||
const state2 = router.getStateForAction(
|
||||
@@ -25,7 +25,7 @@ describe('SwitchRouter', () => {
|
||||
expect(state3.routes[0].routes.length).toEqual(1);
|
||||
});
|
||||
|
||||
test('does not reset the route on unfocus if resetOnBlur is false', () => {
|
||||
it('does not reset the route on unfocus if resetOnBlur is false', () => {
|
||||
const router = getExampleRouter({ resetOnBlur: false });
|
||||
const state = router.getStateForAction({ type: NavigationActions.INIT });
|
||||
const state2 = router.getStateForAction(
|
||||
@@ -44,7 +44,7 @@ describe('SwitchRouter', () => {
|
||||
expect(state3.routes[0].routes.length).toEqual(2);
|
||||
});
|
||||
|
||||
test('ignores back by default', () => {
|
||||
it('ignores back by default', () => {
|
||||
const router = getExampleRouter();
|
||||
const state = router.getStateForAction({ type: NavigationActions.INIT });
|
||||
const state2 = router.getStateForAction(
|
||||
@@ -61,7 +61,7 @@ describe('SwitchRouter', () => {
|
||||
expect(state3.index).toEqual(1);
|
||||
});
|
||||
|
||||
test('handles initialRoute backBehavior', () => {
|
||||
it('handles initialRoute backBehavior', () => {
|
||||
const router = getExampleRouter({ backBehavior: 'initialRoute' });
|
||||
|
||||
const state = router.getStateForAction({ type: NavigationActions.INIT });
|
||||
@@ -81,7 +81,7 @@ describe('SwitchRouter', () => {
|
||||
expect(state3.index).toEqual(0);
|
||||
});
|
||||
|
||||
test('handles order backBehavior', () => {
|
||||
it('handles order backBehavior', () => {
|
||||
const routerHelper = new ExampleRouterHelper({ backBehavior: 'order' });
|
||||
expect(routerHelper.getCurrentState().routeKeyHistory).toBeUndefined();
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('SwitchRouter', () => {
|
||||
).toMatchObject({ index: 0 });
|
||||
});
|
||||
|
||||
test('handles history backBehavior', () => {
|
||||
it('handles history backBehavior', () => {
|
||||
const routerHelper = new ExampleRouterHelper({ backBehavior: 'history' });
|
||||
expect(routerHelper.getCurrentState().routeKeyHistory).toMatchObject(['A']);
|
||||
|
||||
@@ -150,7 +150,7 @@ describe('SwitchRouter', () => {
|
||||
).toMatchObject({ index: 1, routeKeyHistory: ['B'] });
|
||||
});
|
||||
|
||||
test('handles nested actions', () => {
|
||||
it('handles nested actions', () => {
|
||||
const router = getExampleRouter();
|
||||
const state = router.getStateForAction({ type: NavigationActions.INIT });
|
||||
const state2 = router.getStateForAction(
|
||||
@@ -166,7 +166,7 @@ describe('SwitchRouter', () => {
|
||||
expect(activeGrandChildRoute.routeName).toEqual('B2');
|
||||
});
|
||||
|
||||
test('handles nested actions and params simultaneously', () => {
|
||||
it('handles nested actions and params simultaneously', () => {
|
||||
const router = getExampleRouter();
|
||||
const state = router.getStateForAction({ type: NavigationActions.INIT });
|
||||
const state2 = router.getStateForAction(
|
||||
@@ -184,7 +184,7 @@ describe('SwitchRouter', () => {
|
||||
expect(activeGrandChildRoute.routeName).toEqual('B2');
|
||||
});
|
||||
|
||||
test('order of handling navigate action is correct for nested switchrouters', () => {
|
||||
it('order of handling navigate action is correct for nested switchrouters', () => {
|
||||
// router = switch({ Nested: switch({ Foo, Bar }), Other: switch({ Foo }), Bar })
|
||||
// if we are focused on Other and navigate to Bar, what should happen?
|
||||
|
||||
@@ -240,7 +240,7 @@ describe('SwitchRouter', () => {
|
||||
});
|
||||
|
||||
// https://github.com/react-navigation/react-navigation.github.io/issues/117#issuecomment-385597628
|
||||
test('order of handling navigate action is correct for nested stackrouters', () => {
|
||||
it('order of handling navigate action is correct for nested stackrouters', () => {
|
||||
const Screen = () => <div />;
|
||||
const MainStack = () => <div />;
|
||||
const LoginStack = () => <div />;
|
||||
|
||||
@@ -12,7 +12,7 @@ const BareLeafRouteConfig = {
|
||||
};
|
||||
|
||||
describe('TabRouter', () => {
|
||||
test('Handles basic tab logic', () => {
|
||||
it('Handles basic tab logic', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const router = TabRouter({
|
||||
@@ -51,7 +51,7 @@ describe('TabRouter', () => {
|
||||
expect(state3).toEqual(null);
|
||||
});
|
||||
|
||||
test('Handles getScreen', () => {
|
||||
it('Handles getScreen', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const router = TabRouter({
|
||||
@@ -90,7 +90,7 @@ describe('TabRouter', () => {
|
||||
expect(state3).toEqual(null);
|
||||
});
|
||||
|
||||
test('Can set the initial tab', () => {
|
||||
it('Can set the initial tab', () => {
|
||||
const router = TabRouter(
|
||||
{ Foo: BareLeafRouteConfig, Bar: BareLeafRouteConfig },
|
||||
{ initialRouteName: 'Bar' }
|
||||
@@ -106,7 +106,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Can set the initial params', () => {
|
||||
it('Can set the initial params', () => {
|
||||
const router = TabRouter(
|
||||
{ Foo: BareLeafRouteConfig, Bar: BareLeafRouteConfig },
|
||||
{ initialRouteName: 'Bar', initialRouteParams: { name: 'Qux' } }
|
||||
@@ -122,7 +122,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles the SetParams action', () => {
|
||||
it('Handles the SetParams action', () => {
|
||||
const router = TabRouter({
|
||||
Foo: {
|
||||
screen: () => <div />,
|
||||
@@ -139,7 +139,7 @@ describe('TabRouter', () => {
|
||||
expect(state2 && state2.routes[0].params).toEqual({ name: 'Qux' });
|
||||
});
|
||||
|
||||
test('Handles the SetParams action for inactive routes', () => {
|
||||
it('Handles the SetParams action for inactive routes', () => {
|
||||
const router = TabRouter(
|
||||
{
|
||||
Foo: {
|
||||
@@ -179,7 +179,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('getStateForAction returns null when navigating to same tab', () => {
|
||||
it('getStateForAction returns null when navigating to same tab', () => {
|
||||
const router = TabRouter(
|
||||
{ Foo: BareLeafRouteConfig, Bar: BareLeafRouteConfig },
|
||||
{ initialRouteName: 'Bar' }
|
||||
@@ -192,7 +192,7 @@ describe('TabRouter', () => {
|
||||
expect(state2).toEqual(null);
|
||||
});
|
||||
|
||||
test('getStateForAction returns initial navigate', () => {
|
||||
it('getStateForAction returns initial navigate', () => {
|
||||
const router = TabRouter({
|
||||
Foo: BareLeafRouteConfig,
|
||||
Bar: BareLeafRouteConfig,
|
||||
@@ -204,7 +204,7 @@ describe('TabRouter', () => {
|
||||
expect(state && state.index).toEqual(0);
|
||||
});
|
||||
|
||||
test('Handles nested tabs and nested actions', () => {
|
||||
it('Handles nested tabs and nested actions', () => {
|
||||
const ChildTabNavigator = () => <div />;
|
||||
ChildTabNavigator.router = TabRouter({
|
||||
Foo: BareLeafRouteConfig,
|
||||
@@ -264,7 +264,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles passing params to nested tabs', () => {
|
||||
it('Handles passing params to nested tabs', () => {
|
||||
const ChildTabNavigator = () => <div />;
|
||||
ChildTabNavigator.router = TabRouter({
|
||||
Boo: BareLeafRouteConfig,
|
||||
@@ -318,7 +318,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles initial deep linking into nested tabs', () => {
|
||||
it('Handles initial deep linking into nested tabs', () => {
|
||||
const ChildTabNavigator = () => <div />;
|
||||
ChildTabNavigator.router = TabRouter({
|
||||
Foo: BareLeafRouteConfig,
|
||||
@@ -380,7 +380,7 @@ describe('TabRouter', () => {
|
||||
expect(state3).toEqual(null);
|
||||
});
|
||||
|
||||
test('Handles linking across of deeply nested tabs', () => {
|
||||
it('Handles linking across of deeply nested tabs', () => {
|
||||
const ChildNavigator0 = () => <div />;
|
||||
ChildNavigator0.router = TabRouter({
|
||||
Boo: BareLeafRouteConfig,
|
||||
@@ -529,7 +529,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Handles path configuration', () => {
|
||||
it('Handles path configuration', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const router = TabRouter({
|
||||
@@ -586,7 +586,7 @@ describe('TabRouter', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('Handles default configuration', () => {
|
||||
it('Handles default configuration', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const router = TabRouter({
|
||||
@@ -609,7 +609,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Gets deep path', () => {
|
||||
it('Gets deep path', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
ScreenA.router = TabRouter({
|
||||
@@ -647,7 +647,7 @@ describe('TabRouter', () => {
|
||||
expect(path).toEqual('f/Baz');
|
||||
});
|
||||
|
||||
test('Can navigate to other tab (no router) with params', () => {
|
||||
it('Can navigate to other tab (no router) with params', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
|
||||
@@ -681,7 +681,7 @@ describe('TabRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Back actions are not propagated to inactive children', () => {
|
||||
it('Back actions are not propagated to inactive children', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const ScreenC = () => <div />;
|
||||
@@ -721,7 +721,7 @@ describe('TabRouter', () => {
|
||||
expect(state3).toEqual(state2);
|
||||
});
|
||||
|
||||
test('Back behavior initialRoute works', () => {
|
||||
it('Back behavior initialRoute works', () => {
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
const router = TabRouter({
|
||||
@@ -744,7 +744,7 @@ describe('TabRouter', () => {
|
||||
expect(state2).toEqual(state0);
|
||||
});
|
||||
|
||||
test('Inner actions are only unpacked if the current tab matches', () => {
|
||||
it('Inner actions are only unpacked if the current tab matches', () => {
|
||||
const PlainScreen = () => <div />;
|
||||
const ScreenA = () => <div />;
|
||||
const ScreenB = () => <div />;
|
||||
|
||||
@@ -5,7 +5,7 @@ const dummyEventSubscriber = () => ({
|
||||
remove: () => {},
|
||||
});
|
||||
|
||||
test('should get config for screen', () => {
|
||||
it('should get config for screen', () => {
|
||||
class HomeScreen extends Component {
|
||||
static navigationOptions = ({ navigation }) => ({
|
||||
title: `Welcome ${
|
||||
@@ -144,7 +144,7 @@ test('should get config for screen', () => {
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
test('should throw if the route does not exist', () => {
|
||||
it('should throw if the route does not exist', () => {
|
||||
const HomeScreen = () => null;
|
||||
HomeScreen.navigationOptions = {
|
||||
title: 'Home screen',
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import { urlToPathAndParams } from '../pathUtils';
|
||||
|
||||
test('urlToPathAndParams empty', () => {
|
||||
it('urlToPathAndParams empty', () => {
|
||||
const { path, params } = urlToPathAndParams('foo://');
|
||||
expect(path).toBe('');
|
||||
expect(params).toEqual({});
|
||||
});
|
||||
|
||||
test('urlToPathAndParams empty params', () => {
|
||||
it('urlToPathAndParams empty params', () => {
|
||||
const { path, params } = urlToPathAndParams('foo://foo/bar/b');
|
||||
expect(path).toBe('foo/bar/b');
|
||||
expect(params).toEqual({});
|
||||
});
|
||||
|
||||
test('urlToPathAndParams trailing slash', () => {
|
||||
it('urlToPathAndParams trailing slash', () => {
|
||||
const { path, params } = urlToPathAndParams('foo://foo/bar/');
|
||||
expect(path).toBe('foo/bar');
|
||||
expect(params).toEqual({});
|
||||
});
|
||||
|
||||
test('urlToPathAndParams with params', () => {
|
||||
it('urlToPathAndParams with params', () => {
|
||||
const { path, params } = urlToPathAndParams('foo://foo/bar?asdf=1&dude=foo');
|
||||
expect(path).toBe('foo/bar');
|
||||
expect(params).toEqual({ asdf: '1', dude: 'foo' });
|
||||
});
|
||||
|
||||
test('urlToPathAndParams with custom delimeter', () => {
|
||||
it('urlToPathAndParams with custom delimeter', () => {
|
||||
const { path, params } = urlToPathAndParams(
|
||||
'https://example.com/foo/bar?asdf=1',
|
||||
'https://example.com/'
|
||||
|
||||
@@ -13,7 +13,7 @@ ProfileNavigator.router = StackRouter({
|
||||
});
|
||||
|
||||
describe('validateRouteConfigMap', () => {
|
||||
test('Fails on empty bare screen', () => {
|
||||
it('Fails on empty bare screen', () => {
|
||||
const invalidMap = {
|
||||
Home: undefined,
|
||||
};
|
||||
@@ -21,13 +21,13 @@ describe('validateRouteConfigMap', () => {
|
||||
validateRouteConfigMap(invalidMap)
|
||||
).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
test('Fails on empty config', () => {
|
||||
it('Fails on empty config', () => {
|
||||
const invalidMap = {};
|
||||
expect(() =>
|
||||
validateRouteConfigMap(invalidMap)
|
||||
).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
test('Fails on bad object', () => {
|
||||
it('Fails on bad object', () => {
|
||||
const invalidMap = {
|
||||
Home: {
|
||||
foo: 'bar',
|
||||
@@ -37,7 +37,7 @@ describe('validateRouteConfigMap', () => {
|
||||
validateRouteConfigMap(invalidMap)
|
||||
).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
test('Fails if both screen and getScreen are defined', () => {
|
||||
it('Fails if both screen and getScreen are defined', () => {
|
||||
const invalidMap = {
|
||||
Home: {
|
||||
screen: ListScreen,
|
||||
@@ -48,7 +48,7 @@ describe('validateRouteConfigMap', () => {
|
||||
validateRouteConfigMap(invalidMap)
|
||||
).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
test('Succeeds on a valid config', () => {
|
||||
it('Succeeds on a valid config', () => {
|
||||
const validMap = {
|
||||
Home: {
|
||||
screen: ProfileNavigator,
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": ["dom", "es2015", "es2016"],
|
||||
"sourceMap": false,
|
||||
"moduleResolution": "node",
|
||||
"rootDir": "src",
|
||||
"allowUnreachableCode": false,
|
||||
"allowUnusedLabels": false,
|
||||
"alwaysStrict": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react",
|
||||
"lib": ["esnext"],
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"noImplicitUseStrict": false,
|
||||
"noStrictGenericChecks": false,
|
||||
"noUnusedLocals": true,
|
||||
"declaration": true,
|
||||
"pretty": true,
|
||||
"jsx": "react-native",
|
||||
"noEmitHelpers": true,
|
||||
"importHelpers": true,
|
||||
"noUnusedParameters": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"outDir": "dist",
|
||||
"declarationDir": "./types",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true
|
||||
"target": "esnext",
|
||||
"plugins": [{ "name": "typescript-tslint-plugin" }]
|
||||
},
|
||||
"typeAcquisition": {
|
||||
"enable": true,
|
||||
|
||||
1
packages/core/types/getChildRouter.d.ts
vendored
1
packages/core/types/getChildRouter.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export default function getChildRouter(router: any, routeName: string): any;
|
||||
@@ -1,2 +0,0 @@
|
||||
export declare function _TESTING_ONLY_normalize_keys(): void;
|
||||
export declare function generateKey(): string;
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user