@applicaster/zapp-react-native-utils 12.0.0-rc.31 → 12.0.0-rc.32
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/navigationUtils/index.ts +8 -4
- package/package.json +2 -2
- package/reactHooks/navigation/__mocks__/useNavigation.ts +4 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +19 -4
- package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
- package/reactHooks/screen/useScreenContext.ts +1 -1
- package/reactHooks/useListenEventBusEvent.ts +1 -4
- package/testUtils/index.tsx +15 -2
package/navigationUtils/index.ts
CHANGED
|
@@ -114,7 +114,11 @@ export function getNavigationProps({
|
|
|
114
114
|
} | null {
|
|
115
115
|
const { activeRiver } = navigator;
|
|
116
116
|
const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
|
|
117
|
-
|
|
117
|
+
|
|
118
|
+
const navigation: ZappNavigation = R.find(
|
|
119
|
+
R.propEq("category", category),
|
|
120
|
+
navigations
|
|
121
|
+
);
|
|
118
122
|
|
|
119
123
|
if (!navigation) {
|
|
120
124
|
return null;
|
|
@@ -127,9 +131,9 @@ export function getNavigationProps({
|
|
|
127
131
|
title,
|
|
128
132
|
home,
|
|
129
133
|
styles,
|
|
130
|
-
assets,
|
|
131
|
-
nav_items,
|
|
132
|
-
rules,
|
|
134
|
+
assets: assets as ZappNavBarAssets,
|
|
135
|
+
nav_items: nav_items as any as NavBarItem[],
|
|
136
|
+
rules: rules as any as ZappNavBarRules,
|
|
133
137
|
};
|
|
134
138
|
}
|
|
135
139
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.32",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.0-rc.32",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -45,10 +45,19 @@ const videoItem = {
|
|
|
45
45
|
type: { value: "video" },
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const mockGetStackForPathname = jest.fn().mockReturnValue(homeStack);
|
|
49
|
+
|
|
48
50
|
const mainStackNavigator = {
|
|
49
|
-
getStackForPathname:
|
|
51
|
+
getStackForPathname: mockGetStackForPathname,
|
|
50
52
|
getModalState: () => {},
|
|
51
53
|
videoModalState: {},
|
|
54
|
+
canGoBack: jest.fn(),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const _createWrapper = (Wrapper, props) => {
|
|
58
|
+
return function CreatedWrapper({ children }: any) {
|
|
59
|
+
return <Wrapper {...props}>{children}</Wrapper>;
|
|
60
|
+
};
|
|
52
61
|
};
|
|
53
62
|
|
|
54
63
|
const videoModalNavigator = {
|
|
@@ -85,10 +94,16 @@ const store = mockStore({
|
|
|
85
94
|
contentTypes,
|
|
86
95
|
});
|
|
87
96
|
|
|
88
|
-
const mainStackWrapper = ({
|
|
97
|
+
const mainStackWrapper = ({
|
|
98
|
+
children,
|
|
99
|
+
navigator = {},
|
|
100
|
+
pathname = homeStack.route,
|
|
101
|
+
}) => (
|
|
89
102
|
<Provider store={store}>
|
|
90
|
-
<NavigationContext.Provider
|
|
91
|
-
|
|
103
|
+
<NavigationContext.Provider
|
|
104
|
+
value={{ ...mainStackNavigator, ...navigator, currentRoute: pathname }}
|
|
105
|
+
>
|
|
106
|
+
<PathnameContext.Provider value={pathname}>
|
|
92
107
|
{children}
|
|
93
108
|
</PathnameContext.Provider>
|
|
94
109
|
</NavigationContext.Provider>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
|
|
4
|
-
const mockData
|
|
4
|
+
const mockData = {
|
|
5
5
|
screen: {
|
|
6
6
|
id: "screen-id",
|
|
7
7
|
name: "screen",
|
|
@@ -40,3 +40,5 @@ const mockData: NavigationScreenData = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export const useScreenContext = jest.fn().mockReturnValue(mockData);
|
|
43
|
+
|
|
44
|
+
export const useNavbarState = () => ({ visible: true });
|
|
@@ -2,7 +2,7 @@ import { useContext, useMemo } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
|
|
4
4
|
import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
|
|
5
|
-
import { useNavigation } from "../navigation";
|
|
5
|
+
import { useNavigation } from "../navigation/useNavigation";
|
|
6
6
|
|
|
7
7
|
import { ScreenContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
|
|
8
8
|
|
|
@@ -13,10 +13,7 @@ export const useListenEventBusEvent = (
|
|
|
13
13
|
// TODO: remove after implementing ReactNativeEventBusBridge on iOS
|
|
14
14
|
if (Platform.OS === "android") {
|
|
15
15
|
// subscribe to DeviceEventEmitter using subsciption ID
|
|
16
|
-
const sub = DeviceEventEmitter.addListener(
|
|
17
|
-
subscriptionID,
|
|
18
|
-
handler
|
|
19
|
-
);
|
|
16
|
+
const sub = DeviceEventEmitter.addListener(subscriptionID, handler);
|
|
20
17
|
|
|
21
18
|
// ask native to start routing these events to RN
|
|
22
19
|
ReactNativeEventBusBridge.subscribe(subscriptionID, { [source]: events });
|
package/testUtils/index.tsx
CHANGED
|
@@ -6,8 +6,10 @@ import { View } from "react-native";
|
|
|
6
6
|
import { Provider } from "react-redux";
|
|
7
7
|
import thunk from "redux-thunk";
|
|
8
8
|
import configureStore from "redux-mock-store";
|
|
9
|
+
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
9
10
|
|
|
10
11
|
import { render } from "@testing-library/react-native";
|
|
12
|
+
import { AnalyticsProvider } from "../analyticsUtils";
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Function to be used in tandem with enzyme findWhere(node => node.prop('testID') === 'yourID')
|
|
@@ -69,9 +71,20 @@ const initialState = {
|
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
export const WrappedWithProviders = ({ children, store = {} }: any) => {
|
|
72
|
-
const _store = configureStore([thunk])({ ...initialState, store });
|
|
74
|
+
const _store = configureStore([thunk])({ ...initialState, ...store });
|
|
73
75
|
|
|
74
|
-
return
|
|
76
|
+
return (
|
|
77
|
+
<SafeAreaProvider
|
|
78
|
+
initialMetrics={{
|
|
79
|
+
insets: { top: 0, left: 0, right: 0, bottom: 0 },
|
|
80
|
+
frame: { x: 0, y: 0, width: 0, height: 0 },
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<Provider store={_store}>
|
|
84
|
+
<AnalyticsProvider>{children}</AnalyticsProvider>
|
|
85
|
+
</Provider>
|
|
86
|
+
</SafeAreaProvider>
|
|
87
|
+
);
|
|
75
88
|
};
|
|
76
89
|
|
|
77
90
|
/**
|