@common-stack/client-react 1.0.1-alpha.1 → 1.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/connector/base-connector.js +3 -10
- package/lib/connector/base-connector.js.map +1 -1
- package/lib/connector/connector.d.ts +0 -1
- package/lib/connector/connector.js +3 -8
- package/lib/connector/connector.js.map +1 -1
- package/lib/connector/connector.native.d.ts +0 -1
- package/lib/connector/connector.native.js +3 -9
- package/lib/connector/connector.native.js.map +1 -1
- package/lib/index.js +1 -11
- package/lib/index.js.map +1 -1
- package/lib/index.native.js +1 -11
- package/lib/index.native.js.map +1 -1
- package/lib/interfaces/menu.js +2 -3
- package/lib/interfaces/menu.js.map +1 -1
- package/lib/inversify/InversifyContext.js +4 -6
- package/lib/inversify/InversifyContext.js.map +1 -1
- package/lib/plugin-area/base-plugin-area.js +4 -10
- package/lib/plugin-area/base-plugin-area.js.map +1 -1
- package/lib/plugin-area/index.js +2 -6
- package/lib/plugin-area/index.js.map +1 -1
- package/lib/plugin-area/index.native.js +2 -7
- package/lib/plugin-area/index.native.js.map +1 -1
- package/lib/plugin-area/plugin-api.js +6 -9
- package/lib/plugin-area/plugin-api.js.map +1 -1
- package/lib/plugin-area/plugin-context.js +2 -18
- package/lib/plugin-area/plugin-context.js.map +1 -1
- package/lib/route/get-routes.js +3 -6
- package/lib/route/get-routes.js.map +1 -1
- package/lib/route/old/get-menus.js +2 -4
- package/lib/route/old/get-menus.js.map +1 -1
- package/lib/route/old/render.js +2 -5
- package/lib/route/old/render.js.map +1 -1
- package/lib/route/react-navigation/get-navigation-utils.js +3 -7
- package/lib/route/react-navigation/get-navigation-utils.js.map +1 -1
- package/lib/route/react-navigation/react-navigation-render.js +6 -10
- package/lib/route/react-navigation/react-navigation-render.js.map +1 -1
- package/lib/route/react-navigation/root-navigation.js +3 -5
- package/lib/route/react-navigation/root-navigation.js.map +1 -1
- package/lib/route/react-navigation/types.js +1 -2
- package/lib/route/react-navigation/types.js.map +1 -1
- package/lib/route/render-routes.js +2 -60
- package/lib/route/render-routes.js.map +1 -1
- package/lib/route/render-routes.native.js +2 -60
- package/lib/route/render-routes.native.js.map +1 -1
- package/lib/route/root-navigation.js +3 -5
- package/lib/route/root-navigation.js.map +1 -1
- package/lib/route-based-plugin-area/plugin-api.js +6 -9
- package/lib/route-based-plugin-area/plugin-api.js.map +1 -1
- package/lib/route-based-plugin-area/plugin-context.js +2 -18
- package/lib/route-based-plugin-area/plugin-context.js.map +1 -1
- package/lib/route-based-plugin-area/route-based-plugin-area.js +4 -10
- package/lib/route-based-plugin-area/route-based-plugin-area.js.map +1 -1
- package/lib/router-factory/index.js +3 -7
- package/lib/router-factory/index.js.map +1 -1
- package/lib/router-factory/index.native.js +3 -7
- package/lib/router-factory/index.native.js.map +1 -1
- package/lib/utils/before-ssr.js +2 -4
- package/lib/utils/before-ssr.js.map +1 -1
- package/lib/utils/combine.js +1 -3
- package/lib/utils/combine.js.map +1 -1
- package/lib/utils/hydrate.js +2 -4
- package/lib/utils/hydrate.js.map +1 -1
- package/lib/utils/sort-keys.js +2 -4
- package/lib/utils/sort-keys.js.map +1 -1
- package/lib/utils/utils.js +2 -3
- package/lib/utils/utils.js.map +1 -1
- package/package.json +5 -4
- package/lib/__tests__/fill-register-test.js +0 -45
- package/lib/__tests__/fill-register-test.js.map +0 -1
- package/lib/__tests__/helpers/sample-menu.js +0 -75
- package/lib/__tests__/helpers/sample-menu.js.map +0 -1
- package/lib/__tests__/integrated-routes.test.js +0 -59
- package/lib/__tests__/integrated-routes.test.js.map +0 -1
- package/lib/__tests__/router-render.test.js +0 -50
- package/lib/__tests__/router-render.test.js.map +0 -1
- package/lib/connector/connector.test.js +0 -11
- package/lib/connector/connector.test.js.map +0 -1
- package/lib/connector/index.js +0 -2
- package/lib/connector/index.js.map +0 -1
- package/lib/interfaces/extended-feature.js +0 -2
- package/lib/interfaces/extended-feature.js.map +0 -1
- package/lib/interfaces/feature.js +0 -2
- package/lib/interfaces/feature.js.map +0 -1
- package/lib/interfaces/index.js +0 -6
- package/lib/interfaces/index.js.map +0 -1
- package/lib/interfaces/new-router.js +0 -2
- package/lib/interfaces/new-router.js.map +0 -1
- package/lib/interfaces/router.js +0 -2
- package/lib/interfaces/router.js.map +0 -1
- package/lib/inversify/index.js +0 -2
- package/lib/inversify/index.js.map +0 -1
- package/lib/plugin-area/__tests__/higher-order-component-util.test.js +0 -39
- package/lib/plugin-area/__tests__/higher-order-component-util.test.js.map +0 -1
- package/lib/plugin-area/__tests__/plugin-api.test.js +0 -52
- package/lib/plugin-area/__tests__/plugin-api.test.js.map +0 -1
- package/lib/plugin-area/higher-order-component-util.js +0 -19
- package/lib/plugin-area/higher-order-component-util.js.map +0 -1
- package/lib/route/__tests__/admin-new-routes.test.js +0 -145
- package/lib/route/__tests__/admin-new-routes.test.js.map +0 -1
- package/lib/route/__tests__/config-routes.test.d.ts +0 -0
- package/lib/route/__tests__/config-routes.test.js +0 -326
- package/lib/route/__tests__/config-routes.test.js.map +0 -1
- package/lib/route/__tests__/getFlatMenus.test.js +0 -94
- package/lib/route/__tests__/getFlatMenus.test.js.map +0 -1
- package/lib/route/__tests__/render-routes-config.test.js +0 -57
- package/lib/route/__tests__/render-routes-config.test.js.map +0 -1
- package/lib/route/__tests__/route-type.test.js +0 -8
- package/lib/route/__tests__/route-type.test.js.map +0 -1
- package/lib/route/get-routes.test.js +0 -184
- package/lib/route/get-routes.test.js.map +0 -1
- package/lib/route/index.js +0 -3
- package/lib/route/index.js.map +0 -1
- package/lib/route/index.native.js +0 -2
- package/lib/route/index.native.js.map +0 -1
- package/lib/route/old/__tests__/config-sidebar-menu.test.js +0 -200
- package/lib/route/old/__tests__/config-sidebar-menu.test.js.map +0 -1
- package/lib/route/old/get-routes-notused.js +0 -63
- package/lib/route/old/get-routes-notused.js.map +0 -1
- package/lib/route/react-navigation/get-navigation-utils.test.js +0 -180
- package/lib/route/react-navigation/get-navigation-utils.test.js.map +0 -1
- package/lib/route/react-navigation/index.js +0 -3
- package/lib/route/react-navigation/index.js.map +0 -1
- package/lib/route/react-navigation/react-native.sample.test.js +0 -13
- package/lib/route/react-navigation/react-native.sample.test.js.map +0 -1
- package/lib/route/react-navigation/react-native.sample1.test.js +0 -30
- package/lib/route/react-navigation/react-native.sample1.test.js.map +0 -1
- package/lib/route/react-navigation/react-navigation-render.test.js +0 -139
- package/lib/route/react-navigation/react-navigation-render.test.js.map +0 -1
- package/lib/route/react-navigation/routes.js +0 -2
- package/lib/route/react-navigation/routes.js.map +0 -1
- package/lib/route/render-routes.test.js +0 -248
- package/lib/route/render-routes.test.js.map +0 -1
- package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js +0 -39
- package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js.map +0 -1
- package/lib/route-based-plugin-area/__tests__/plugin-api.test.js +0 -52
- package/lib/route-based-plugin-area/__tests__/plugin-api.test.js.map +0 -1
- package/lib/route-based-plugin-area/higher-order-component-util.js +0 -19
- package/lib/route-based-plugin-area/higher-order-component-util.js.map +0 -1
- package/lib/route-based-plugin-area/index.js +0 -3
- package/lib/route-based-plugin-area/index.js.map +0 -1
- package/lib/utils/index.js +0 -6
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/sort-keys.test.js +0 -31
- package/lib/utils/sort-keys.test.js.map +0 -1
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { getNavigation, getSortedNavigations } from './get-navigation-utils';
|
|
2
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
|
-
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
4
|
-
import { Feature } from '../../connector/connector.native';
|
|
5
|
-
const MyComponent = () => { };
|
|
6
|
-
describe('getRoutes utility with basic routes', () => {
|
|
7
|
-
const routerConfig1 = {
|
|
8
|
-
['/']: {
|
|
9
|
-
exact: false,
|
|
10
|
-
container: createStackNavigator(),
|
|
11
|
-
name: 'MainStack',
|
|
12
|
-
props: {
|
|
13
|
-
initialRouteName: 'Guest',
|
|
14
|
-
screenOptions: {
|
|
15
|
-
headerShown: false,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
['//guest']: {
|
|
20
|
-
container: createBottomTabNavigator(),
|
|
21
|
-
exact: false,
|
|
22
|
-
name: 'Guest',
|
|
23
|
-
props: {
|
|
24
|
-
initialRouteName: 'Home',
|
|
25
|
-
screenOptions: {
|
|
26
|
-
headerShown: false,
|
|
27
|
-
tabBarLabel: 'About',
|
|
28
|
-
// tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
['//guest/home']: {
|
|
33
|
-
name: 'Home',
|
|
34
|
-
props: {
|
|
35
|
-
initialParams: {},
|
|
36
|
-
component: MyComponent,
|
|
37
|
-
options: {
|
|
38
|
-
headerShown: true,
|
|
39
|
-
tabBarLabel: 'Home',
|
|
40
|
-
headerTitle: 'Home',
|
|
41
|
-
// tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
['//guest/about']: {
|
|
46
|
-
exact: false,
|
|
47
|
-
container: createStackNavigator(),
|
|
48
|
-
name: 'About',
|
|
49
|
-
props: {
|
|
50
|
-
initialRouteName: 'Hello',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
['//guest/about/hello']: {
|
|
54
|
-
name: 'Hello',
|
|
55
|
-
props: {
|
|
56
|
-
initialParams: {},
|
|
57
|
-
component: MyComponent,
|
|
58
|
-
options: {
|
|
59
|
-
headerTitle: 'About',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
['//guest/about/personalinfo']: {
|
|
64
|
-
name: 'PersonalInfo',
|
|
65
|
-
props: {
|
|
66
|
-
initialParams: { name: 'Test' },
|
|
67
|
-
component: MyComponent,
|
|
68
|
-
options: {
|
|
69
|
-
headerTitle: 'Personal Info',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
['//setting']: {
|
|
74
|
-
name: 'Setting',
|
|
75
|
-
props: {
|
|
76
|
-
initialParams: {},
|
|
77
|
-
component: MyComponent,
|
|
78
|
-
options: {
|
|
79
|
-
headerShown: true,
|
|
80
|
-
headerTitle: 'Settings',
|
|
81
|
-
headerBackTitle: 'Back',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
exact: false,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
const routerConfig2 = {
|
|
88
|
-
['/']: {
|
|
89
|
-
exact: false,
|
|
90
|
-
container: createStackNavigator(),
|
|
91
|
-
name: 'MainStack',
|
|
92
|
-
props: {
|
|
93
|
-
initialRouteName: 'Guest', screenOptions: {
|
|
94
|
-
headerShown: false,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
['/l']: {
|
|
99
|
-
container: createBottomTabNavigator(),
|
|
100
|
-
exact: false,
|
|
101
|
-
name: 'Layout',
|
|
102
|
-
props: {
|
|
103
|
-
initialRouteName: 'Guest',
|
|
104
|
-
screenOptions: {
|
|
105
|
-
headerShown: false,
|
|
106
|
-
// tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
['/l/:guest']: {
|
|
111
|
-
exact: false,
|
|
112
|
-
name: 'Guest',
|
|
113
|
-
props: {
|
|
114
|
-
initialRouteName: 'Home',
|
|
115
|
-
screenOptions: {
|
|
116
|
-
headerShown: false,
|
|
117
|
-
tabBarLabel: 'About',
|
|
118
|
-
// tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
['/l/:guest/home']: {
|
|
123
|
-
name: 'Home',
|
|
124
|
-
props: {
|
|
125
|
-
component: MyComponent,
|
|
126
|
-
options: {
|
|
127
|
-
headerShown: true,
|
|
128
|
-
tabBarLabel: 'Home',
|
|
129
|
-
headerTitle: 'Home',
|
|
130
|
-
// tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
['/l/:guest/home/:about']: {
|
|
135
|
-
exact: false,
|
|
136
|
-
container: createStackNavigator(),
|
|
137
|
-
name: 'About',
|
|
138
|
-
props: {
|
|
139
|
-
initialRouteName: 'Hello',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
['/l/:guest/home/:about/info']: {
|
|
143
|
-
name: 'Info',
|
|
144
|
-
props: {
|
|
145
|
-
initialParams: {},
|
|
146
|
-
component: MyComponent,
|
|
147
|
-
options: {
|
|
148
|
-
headerTitle: 'Info',
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
const routerConfig3 = {};
|
|
154
|
-
xit('getNavigation ', () => {
|
|
155
|
-
const Navigation = getNavigation('/', routerConfig1);
|
|
156
|
-
expect(Navigation).toMatchSnapshot();
|
|
157
|
-
});
|
|
158
|
-
it('get sorted navigation with add params', () => {
|
|
159
|
-
const navigation = getSortedNavigations('/', routerConfig2);
|
|
160
|
-
expect(navigation).toMatchSnapshot();
|
|
161
|
-
});
|
|
162
|
-
it('get ', () => {
|
|
163
|
-
});
|
|
164
|
-
xit('with feature', () => {
|
|
165
|
-
const feature = new Feature({ routeConfig: routerConfig1 });
|
|
166
|
-
const Navigation = feature.getConfiguredRoutes2('/');
|
|
167
|
-
expect(Navigation).toMatchSnapshot();
|
|
168
|
-
const Render = feature.getRoutes2('/', 'MainStack');
|
|
169
|
-
expect(Render).toMatchSnapshot();
|
|
170
|
-
});
|
|
171
|
-
xit('Add routeParams parameter', () => {
|
|
172
|
-
const feature = new Feature({ routeConfig: routerConfig2 });
|
|
173
|
-
const Nav = feature.getConfiguredRoutes2('/');
|
|
174
|
-
expect(Nav).toMatchSnapshot();
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
describe('messnager routes', () => {
|
|
178
|
-
const routerConfig1 = {};
|
|
179
|
-
});
|
|
180
|
-
//# sourceMappingURL=get-navigation-utils.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-navigation-utils.test.js","sourceRoot":"","sources":["../../../src/route/react-navigation/get-navigation-utils.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,MAAM,WAAW,GAAG,GAAG,EAAE,GAAG,CAAC,CAAA;AAC7B,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IAEjD,MAAM,aAAa,GAAe;QAC9B,CAAC,GAAG,CAAC,EAAE;YACH,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,oBAAoB,EAAE;YACjC,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACH,gBAAgB,EAAE,OAAO;gBACzB,aAAa,EAAE;oBACX,WAAW,EAAE,KAAK;iBACrB;aACJ;SACJ;QACD,CAAC,SAAS,CAAC,EAAE;YACT,SAAS,EAAE,wBAAwB,EAAE;YACrC,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACH,gBAAgB,EAAE,MAAM;gBACxB,aAAa,EAAE;oBACX,WAAW,EAAE,KAAK;oBAClB,WAAW,EAAE,OAAO;oBACpB,iFAAiF;iBACpF;aACJ;SACJ;QACD,CAAC,cAAc,CAAC,EAAE;YACd,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE;gBACH,aAAa,EAAE,EAAE;gBACjB,SAA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C1C,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavigationContainer } from "@react-navigation/native";
|
|
3
|
-
import { act } from 'react-test-renderer';
|
|
4
|
-
import { render } from 'react-native-testing-library';
|
|
5
|
-
// Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
|
|
6
|
-
// jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
|
|
7
|
-
describe('<NavigationContainer />', () => {
|
|
8
|
-
it('should match snapshot', async () => {
|
|
9
|
-
const result = render(React.createElement(NavigationContainer, null));
|
|
10
|
-
await act(async () => { expect(result).toMatchSnapshot(); });
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=react-native.sample.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.sample.test.js","sourceRoot":"","sources":["../../../src/route/react-navigation/react-native.sample.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAa,MAAM,8BAA8B,CAAC;AAEjE,mGAAmG;AACnG,yEAAyE;AAEzE,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAC,mBAAmB,OACpB,CAAC,CAAC;QACxB,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Button, Text, TextInput, View } from 'react-native';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/react-native';
|
|
4
|
-
function Example() {
|
|
5
|
-
const [name, setUser] = React.useState('');
|
|
6
|
-
const [show, setShow] = React.useState(false);
|
|
7
|
-
return (React.createElement(View, null,
|
|
8
|
-
React.createElement(TextInput, { value: name, onChangeText: setUser, testID: "input" }),
|
|
9
|
-
React.createElement(Button, { title: "Print Username", onPress: () => {
|
|
10
|
-
// let's pretend this is making a server request, so it's async
|
|
11
|
-
// (you'd want to mock this imaginary request in your unit tests)...
|
|
12
|
-
setTimeout(() => {
|
|
13
|
-
setShow(true);
|
|
14
|
-
}, Math.floor(Math.random() * 200));
|
|
15
|
-
} }),
|
|
16
|
-
show && React.createElement(Text, { testID: "printed-username" }, name)));
|
|
17
|
-
}
|
|
18
|
-
test('examples of some things', async () => {
|
|
19
|
-
const expectedUsername = 'Ada Lovelace';
|
|
20
|
-
render(React.createElement(Example, null));
|
|
21
|
-
fireEvent.changeText(screen.getByTestId('input'), expectedUsername);
|
|
22
|
-
fireEvent.press(screen.getByText('Print Username'));
|
|
23
|
-
// Using `findBy` query to wait for asynchronous operation to finish
|
|
24
|
-
const usernameOutput = await screen.findByTestId('printed-username');
|
|
25
|
-
// Using `toHaveTextContent` matcher from `@testing-library/jest-native` package.
|
|
26
|
-
//@ts-ignore
|
|
27
|
-
expect(usernameOutput).toHaveTextContent(expectedUsername);
|
|
28
|
-
expect(screen.toJSON()).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=react-native.sample1.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.sample1.test.js","sourceRoot":"","sources":["../../../src/route/react-navigation/react-native.sample1.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAC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F;IACjF,YAAY;IACZ,MAAM,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;IAE1D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAA;AAC3C,CAAC,CAAC,CAAA"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
// import { Ionicons } from '@expo/vector-icons';
|
|
3
|
-
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
4
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
5
|
-
import { render, screen } from '@testing-library/react-native';
|
|
6
|
-
import { NavigationContainer } from '@react-navigation/native';
|
|
7
|
-
import resolveRootRoute from './react-navigation-render';
|
|
8
|
-
import '@testing-library/jest-dom';
|
|
9
|
-
import { Text, View } from 'react-native';
|
|
10
|
-
function DetailsScreen(props) {
|
|
11
|
-
const item = Object.keys(props).find((item) => item === 'navigation') || "";
|
|
12
|
-
return (React.createElement(View, null,
|
|
13
|
-
React.createElement(Text, null, item)));
|
|
14
|
-
}
|
|
15
|
-
function SampleComponent(props) {
|
|
16
|
-
return (React.createElement(View, null,
|
|
17
|
-
React.createElement(Text, null, "Showing details for"),
|
|
18
|
-
React.createElement(Text, null, "the number you have chosen is")));
|
|
19
|
-
}
|
|
20
|
-
describe('react-navigation ', () => {
|
|
21
|
-
const rootRoutes = [
|
|
22
|
-
{
|
|
23
|
-
container: createStackNavigator(),
|
|
24
|
-
name: 'MainStack',
|
|
25
|
-
props: {
|
|
26
|
-
initialRouteName: 'Guest',
|
|
27
|
-
screenOptions: {
|
|
28
|
-
headerShown: false,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
children: [
|
|
32
|
-
{
|
|
33
|
-
name: 'Guest',
|
|
34
|
-
container: createBottomTabNavigator(),
|
|
35
|
-
props: {
|
|
36
|
-
initialRouteName: 'Home',
|
|
37
|
-
screenOptions: {
|
|
38
|
-
headerShown: false,
|
|
39
|
-
tabBarLabel: 'About',
|
|
40
|
-
// tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
children: [
|
|
44
|
-
{
|
|
45
|
-
name: 'Home',
|
|
46
|
-
props: {
|
|
47
|
-
initialParams: {},
|
|
48
|
-
component: SampleComponent,
|
|
49
|
-
options: {
|
|
50
|
-
headerShown: true,
|
|
51
|
-
tabBarLabel: 'Home',
|
|
52
|
-
headerTitle: 'Home',
|
|
53
|
-
// tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'About',
|
|
59
|
-
container: createStackNavigator(),
|
|
60
|
-
props: {
|
|
61
|
-
initialRouteName: 'Hello',
|
|
62
|
-
},
|
|
63
|
-
children: [
|
|
64
|
-
{
|
|
65
|
-
name: 'Hello',
|
|
66
|
-
props: {
|
|
67
|
-
initialParams: {},
|
|
68
|
-
component: SampleComponent,
|
|
69
|
-
options: {
|
|
70
|
-
headerTitle: 'About',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'PersonalInfo',
|
|
76
|
-
props: {
|
|
77
|
-
initialParams: { name: 'Test' },
|
|
78
|
-
component: SampleComponent,
|
|
79
|
-
options: {
|
|
80
|
-
headerTitle: 'Personal Info',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'Setting',
|
|
90
|
-
props: {
|
|
91
|
-
initialParams: {},
|
|
92
|
-
component: SampleComponent,
|
|
93
|
-
options: {
|
|
94
|
-
headerShown: true,
|
|
95
|
-
headerTitle: 'Settings',
|
|
96
|
-
headerBackTitle: 'Back',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
const MainStack = resolveRootRoute(rootRoutes[0], 'MainStack');
|
|
104
|
-
it('test component', () => {
|
|
105
|
-
expect(MainStack).toMatchSnapshot();
|
|
106
|
-
});
|
|
107
|
-
it('tests that child screen component has navigation props ', async () => {
|
|
108
|
-
const sampleRoutes = [
|
|
109
|
-
{
|
|
110
|
-
container: createStackNavigator(),
|
|
111
|
-
name: 'MainStack',
|
|
112
|
-
props: {
|
|
113
|
-
initialRouteName: 'MainStack.Setting',
|
|
114
|
-
screenOptions: {
|
|
115
|
-
headerShown: false,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
children: [
|
|
119
|
-
{
|
|
120
|
-
name: 'Setting',
|
|
121
|
-
props: {
|
|
122
|
-
initialParams: {},
|
|
123
|
-
component: DetailsScreen,
|
|
124
|
-
options: {
|
|
125
|
-
headerShown: true,
|
|
126
|
-
headerTitle: 'Settings',
|
|
127
|
-
headerBackTitle: 'Back',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
];
|
|
134
|
-
const MainStack = resolveRootRoute(sampleRoutes[0], 'MainStack');
|
|
135
|
-
render(React.createElement(NavigationContainer, null, MainStack));
|
|
136
|
-
expect(await screen.findByText('navigation')).toBeOnTheScreen();
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
//# sourceMappingURL=react-navigation-render.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-navigation-render.test.js","sourceRoot":"","sources":["../../../src/route/react-navigation/react-navigation-render.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,iDAAiD;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAA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WAAW;gBACjB,KAAK,EAAE;oBACH,gBAAgB,EAAE,mBAAmB;oBACrC,aAAa,EAAE;wBACX,WAAW,EAAE,KAAK;qBACrB;iBACJ;gBACD,QAAQ,EAAE;oBACN;wBACI,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE;4BACH,aAAa,EAAE,EAAE;4BACjB,SAAS,EAAE,aAAa;4BACxB,OAAO,EAAE;gCACL,WAAW,EAAE,IAAI;gCACjB,WAAW,EAAE,UAAU;gCACvB,eAAe,EAAE,MAAM;6BAC1B;yBACJ;qBACJ;iBACJ;aACJ;SACJ,CAAC;QAEF,MAAM,SAAS,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QAEjE,MAAM,CACF,oBAAC,mBAAmB,QACf,SAAS,CACQ,CACzB,CAAC;QACF,MAAM,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IACpE,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/route/react-navigation/routes.ts"],"names":[],"mappings":""}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { cleanup, getByText, render, screen, waitFor, } from '@testing-library/react';
|
|
2
|
-
import { Link, MemoryRouter } from 'react-router-dom';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { renderRoutes2 as renderRoutes } from './render-routes';
|
|
5
|
-
function TestInitialProps({ foo }) {
|
|
6
|
-
return React.createElement("h1", { "data-testid": "test" }, foo);
|
|
7
|
-
}
|
|
8
|
-
let mountCount = 0;
|
|
9
|
-
let renderCount = 0;
|
|
10
|
-
function TestInitialPropsWithoutUnmount({ foo }) {
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
return () => {
|
|
13
|
-
mountCount++;
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
return (React.createElement("div", null,
|
|
17
|
-
React.createElement("h1", { "data-testid": "test2" }, foo),
|
|
18
|
-
React.createElement("a", { href: "#bar" }, "link-bar"),
|
|
19
|
-
React.createElement(Link, { to: "/get-initial-props" }, "change-route"),
|
|
20
|
-
React.createElement("h2", { id: "bar" }, "h2-bar")));
|
|
21
|
-
}
|
|
22
|
-
function TestInitialPropsWithMount({ foo }) {
|
|
23
|
-
React.useEffect(() => {
|
|
24
|
-
mountCount++;
|
|
25
|
-
}, []);
|
|
26
|
-
renderCount++;
|
|
27
|
-
return React.createElement("h1", { "data-testid": "test" }, foo);
|
|
28
|
-
}
|
|
29
|
-
const getInitialProps = async () => {
|
|
30
|
-
return new Promise((resolve) => {
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
resolve({
|
|
33
|
-
foo: 'bar',
|
|
34
|
-
});
|
|
35
|
-
}, 100);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
TestInitialProps.getInitialProps = getInitialProps;
|
|
39
|
-
TestInitialPropsWithoutUnmount.getInitialProps = getInitialProps;
|
|
40
|
-
TestInitialPropsWithMount.getInitialProps = getInitialProps;
|
|
41
|
-
function TestInitialPropsParent({ foo, children, }) {
|
|
42
|
-
return (React.createElement(React.Fragment, null,
|
|
43
|
-
React.createElement("h1", { "data-testid": "test-parent" }, foo),
|
|
44
|
-
children));
|
|
45
|
-
}
|
|
46
|
-
TestInitialPropsParent.getInitialProps = async () => {
|
|
47
|
-
return new Promise((resolve) => {
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
resolve({
|
|
50
|
-
foo: 'parent',
|
|
51
|
-
});
|
|
52
|
-
}, 100);
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
const routerConfig = {
|
|
56
|
-
ssrProps: {},
|
|
57
|
-
routes: [
|
|
58
|
-
{
|
|
59
|
-
path: '/layout',
|
|
60
|
-
component: (props) => (React.createElement(React.Fragment, null,
|
|
61
|
-
React.createElement("h1", { "data-testid": "layout" }, "Layout"),
|
|
62
|
-
React.createElement("h2", { "data-testid": "routes" }, props.routes.map((r) => r.path).join(',')),
|
|
63
|
-
props.children)),
|
|
64
|
-
routes: [
|
|
65
|
-
{
|
|
66
|
-
path: '/layout',
|
|
67
|
-
component: (props) => (React.createElement(React.Fragment, null,
|
|
68
|
-
React.createElement("h1", { "data-testid": "test" }, "Foo"),
|
|
69
|
-
React.createElement("h2", { "data-testid": "routes-embed" }, props.routes.map((r) => r.path).join(',')))),
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
path: '/layout-without-component',
|
|
75
|
-
routes: [
|
|
76
|
-
{
|
|
77
|
-
path: '/layout-without-component/foo',
|
|
78
|
-
component: () => React.createElement("h1", { "data-testid": "test" }, "Foo"),
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
path: '/users/:id',
|
|
84
|
-
component: (props) => {
|
|
85
|
-
return React.createElement("h1", { "data-testid": "test" }, props.match.params.id);
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{ path: '/bar', component: () => React.createElement("h1", { "data-testid": "test" }, "Bar") },
|
|
89
|
-
{
|
|
90
|
-
path: '/bar-exact',
|
|
91
|
-
exact: true,
|
|
92
|
-
component: () => React.createElement("h1", { "data-testid": "test" }, "Bar Exact"),
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
path: '/bar-strict/',
|
|
96
|
-
strict: true,
|
|
97
|
-
component: () => React.createElement("h1", { "data-testid": "test" }, "Bar Strict"),
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
path: '/bar-sensitive',
|
|
101
|
-
sensitive: true,
|
|
102
|
-
component: () => React.createElement("h1", { "data-testid": "test" }, "Bar Sensitive"),
|
|
103
|
-
},
|
|
104
|
-
{ path: '/redirect', redirect: '/d' },
|
|
105
|
-
{ path: '/d', component: () => React.createElement("h1", { "data-testid": "test" }, "Redirect") },
|
|
106
|
-
{ path: '/get-initial-props', component: TestInitialProps },
|
|
107
|
-
{
|
|
108
|
-
path: '/get-initial-props-without-unmount',
|
|
109
|
-
component: TestInitialPropsWithoutUnmount,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
path: '/get-initial-props-with-mount',
|
|
113
|
-
component: TestInitialPropsWithMount,
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
path: '/get-initial-props-embed',
|
|
117
|
-
component: TestInitialPropsParent,
|
|
118
|
-
routes: [
|
|
119
|
-
{
|
|
120
|
-
path: '/get-initial-props-embed',
|
|
121
|
-
component: TestInitialProps,
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
path: '/props-route',
|
|
127
|
-
foo: 'bar',
|
|
128
|
-
component: (props) => (React.createElement("h1", { "data-testid": "test" }, `${props.route.path} ${props.route.foo}`)),
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
path: '/pass-props',
|
|
132
|
-
component: (props) => {
|
|
133
|
-
return React.Children.map(props.children, (child) => {
|
|
134
|
-
return React.cloneElement(child, { foo: 'bar' });
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
routes: [
|
|
138
|
-
{
|
|
139
|
-
path: '/pass-props',
|
|
140
|
-
component: (props) => React.createElement("h1", { "data-testid": "test" }, props.foo),
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
path: '/wrappers',
|
|
146
|
-
component: () => React.createElement("h1", null, "foo"),
|
|
147
|
-
wrappers: [
|
|
148
|
-
(props) => (React.createElement(React.Fragment, null,
|
|
149
|
-
React.createElement("h1", null,
|
|
150
|
-
"wrapper 1 ",
|
|
151
|
-
props.route.path),
|
|
152
|
-
props.children)),
|
|
153
|
-
(props) => (React.createElement(React.Fragment, null,
|
|
154
|
-
React.createElement("h1", null, "wrapper 2"),
|
|
155
|
-
props.children)),
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
{ component: () => React.createElement("h1", { "data-testid": "test" }, "Fallback") },
|
|
159
|
-
],
|
|
160
|
-
// plugin: new Plugin(),
|
|
161
|
-
};
|
|
162
|
-
let routes = renderRoutes(routerConfig);
|
|
163
|
-
beforeEach(() => {
|
|
164
|
-
window.g_useSSR = true;
|
|
165
|
-
window.g_initialProps = null;
|
|
166
|
-
mountCount = 0;
|
|
167
|
-
renderCount = 0;
|
|
168
|
-
});
|
|
169
|
-
afterEach(async () => {
|
|
170
|
-
delete window.g_useSSR;
|
|
171
|
-
delete window.g_initialProps;
|
|
172
|
-
await cleanup();
|
|
173
|
-
});
|
|
174
|
-
test('/layout', async () => {
|
|
175
|
-
const { container } = render(React.createElement(MemoryRouter, { initialEntries: ['/layout'] }, routes));
|
|
176
|
-
expect(container).toMatchSnapshot();
|
|
177
|
-
expect((await screen.findByTestId('layout')).innerHTML).toEqual('Layout');
|
|
178
|
-
expect((await screen.findByTestId('routes')).innerHTML).toContain('/layout,/layout-without-component,/users/:id');
|
|
179
|
-
expect((await screen.findByTestId('routes-embed')).innerHTML).toContain('/layout,/layout-without-component,/users/:id');
|
|
180
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Foo');
|
|
181
|
-
});
|
|
182
|
-
test('/layout-without-component', async () => {
|
|
183
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/layout-without-component/foo'] }, routes));
|
|
184
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Foo');
|
|
185
|
-
});
|
|
186
|
-
test('/bar', async () => {
|
|
187
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/bar'] }, routes));
|
|
188
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Bar');
|
|
189
|
-
});
|
|
190
|
-
test('/BAR', async () => {
|
|
191
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/BAR'] }, routes));
|
|
192
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Bar');
|
|
193
|
-
});
|
|
194
|
-
test('/bar-exact/foo', async () => {
|
|
195
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/bar-exact/foo'] }, routes));
|
|
196
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Fallback');
|
|
197
|
-
});
|
|
198
|
-
test('/bar-strict', async () => {
|
|
199
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/bar-strict'] }, routes));
|
|
200
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Fallback');
|
|
201
|
-
});
|
|
202
|
-
test('/BAR-sensitive', async () => {
|
|
203
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/BAR-sensitive'] }, routes));
|
|
204
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Fallback');
|
|
205
|
-
});
|
|
206
|
-
test('/users/123', async () => {
|
|
207
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/users/123'] }, routes));
|
|
208
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('123');
|
|
209
|
-
});
|
|
210
|
-
test('/redirect', async () => {
|
|
211
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/redirect'] }, routes));
|
|
212
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Redirect');
|
|
213
|
-
});
|
|
214
|
-
test('/props-route', async () => {
|
|
215
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/props-route'] }, routes));
|
|
216
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('/props-route bar');
|
|
217
|
-
});
|
|
218
|
-
test('/pass-props', async () => {
|
|
219
|
-
const { container } = render(React.createElement(MemoryRouter, { initialEntries: ['/pass-props'] }, routes));
|
|
220
|
-
await waitFor(() => getByText(container, 'bar'));
|
|
221
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('bar');
|
|
222
|
-
});
|
|
223
|
-
test('/get-initial-props-with-mount', async () => {
|
|
224
|
-
const newRoutes = renderRoutes(routerConfig);
|
|
225
|
-
expect(mountCount).toEqual(0);
|
|
226
|
-
expect(renderCount).toEqual(0);
|
|
227
|
-
const { container } = render(React.createElement(MemoryRouter, { initialEntries: ['/get-initial-props-with-mount'] }, newRoutes));
|
|
228
|
-
await waitFor(() => getByText(container, 'bar'));
|
|
229
|
-
expect(mountCount).toEqual(1);
|
|
230
|
-
expect(renderCount).toEqual(2);
|
|
231
|
-
});
|
|
232
|
-
test('/get-initial-props-embed', async () => {
|
|
233
|
-
const newRoutes = renderRoutes(routerConfig);
|
|
234
|
-
const { container } = render(React.createElement(MemoryRouter, { initialEntries: ['/get-initial-props-embed'] }, newRoutes));
|
|
235
|
-
await waitFor(() => getByText(container, 'bar'));
|
|
236
|
-
await waitFor(() => getByText(container, 'parent'));
|
|
237
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('bar');
|
|
238
|
-
expect((await screen.findByTestId('test-parent')).innerHTML).toEqual('parent');
|
|
239
|
-
});
|
|
240
|
-
test('/wrappers', () => {
|
|
241
|
-
const { container } = render(React.createElement(MemoryRouter, { initialEntries: ['/wrappers'] }, routes));
|
|
242
|
-
expect(container.innerHTML).toEqual('<h1>wrapper 1 /wrappers</h1><h1>wrapper 2</h1><h1>foo</h1>');
|
|
243
|
-
});
|
|
244
|
-
test('/fallback-20140924', async () => {
|
|
245
|
-
render(React.createElement(MemoryRouter, { initialEntries: ['/fallback-20140924'] }, routes));
|
|
246
|
-
expect((await screen.findByTestId('test')).innerHTML).toEqual('Fallback');
|
|
247
|
-
});
|
|
248
|
-
//# sourceMappingURL=render-routes.test.js.map
|