@eohjsc/react-native-smart-city 0.4.47 → 0.4.48
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/README.md +1 -5
- package/android/build.gradle +24 -19
- package/package.json +12 -15
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +7 -4
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +3 -6
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +1 -4
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +11 -1
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +6 -1
- package/src/commons/Dashboard/MyUnit/index.js +6 -8
- package/src/commons/DateTimeRangeChange/index.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.js +1 -5
- package/src/commons/Device/ItemAddNew/index.js +2 -6
- package/src/commons/Device/ItemDevice.js +1 -5
- package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
- package/src/commons/HeaderAni/index.js +2 -12
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
- package/src/commons/Modal/ModalCustom.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -10
- package/src/commons/Unit/HeaderUnit/index.js +7 -18
- package/src/commons/Unit/SharedUnit.js +43 -58
- package/src/commons/Unit/__test__/SharedUnit.test.js +100 -60
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
- package/src/commons/WrapParallaxScrollView/index.js +0 -4
- package/src/configs/AccessibilityLabel.js +0 -3
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
- package/src/navigations/AutomateStack.js +2 -5
- package/src/navigations/NotificationStack.js +2 -28
- package/src/navigations/SharedStack.js +2 -8
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
- package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +0 -1
- package/src/screens/Automate/ScriptDetail/index.js +7 -4
- package/src/screens/ChangePosition/__test__/index.test.js +32 -34
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
- package/src/screens/Device/__test__/detail.test.js +8 -67
- package/src/screens/Device/components/ChartWrapper.js +12 -14
- package/src/screens/Device/components/VisualChart.js +1 -7
- package/src/screens/Device/components/__test__/VisualChart.test.js +3 -0
- package/src/screens/Device/detail.js +34 -29
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
- package/src/screens/Device/styles.js +0 -3
- package/src/screens/Notification/__test__/Notification.test.js +8 -14
- package/src/screens/Notification/components/NotificationItem.js +0 -1
- package/src/screens/Notification/index.js +48 -42
- package/src/screens/Notification/styles/indexStyles.js +3 -6
- package/src/screens/SharedUnit/index.js +4 -1
- package/src/screens/Sharing/InfoMemberUnit.js +1 -3
- package/src/screens/Sharing/MemberList.js +3 -16
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +0 -2
- package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
- package/src/screens/Template/__test__/EditTemplate.test.js +1 -7
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
- package/src/screens/Unit/components/SharedUnit/index.js +9 -6
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +15 -19
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
- package/src/utils/Monitor.js +2 -2
- package/src/Images/Common/pushpin-full.svg +0 -3
- package/src/Images/Common/pushpin-outline.svg +0 -3
- package/src/Images/Common/star-full.svg +0 -3
- package/src/Images/Common/star-outline.svg +0 -3
package/README.md
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
## Getting started
|
|
4
4
|
|
|
5
5
|
1. Install package dependencies:
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
// Add this line to your 'index.js'
|
|
9
|
-
import 'react-native-get-random-values'
|
|
10
|
-
```
|
|
6
|
+
|
|
11
7
|
- Using [Yarn](https://yarnpkg.com/): `yarn add react-native-reanimated@^1.10.1`
|
|
12
8
|
|
|
13
9
|
2. Install:
|
package/android/build.gradle
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
// original location:
|
|
11
11
|
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
12
|
|
|
13
|
-
def DEFAULT_COMPILE_SDK_VERSION =
|
|
14
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '
|
|
15
|
-
def DEFAULT_MIN_SDK_VERSION =
|
|
16
|
-
def DEFAULT_TARGET_SDK_VERSION =
|
|
13
|
+
def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
14
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
|
|
15
|
+
def DEFAULT_MIN_SDK_VERSION = 16
|
|
16
|
+
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
17
17
|
|
|
18
18
|
def safeExtGet(prop, fallback) {
|
|
19
19
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
apply plugin: 'com.android.library'
|
|
23
|
-
apply plugin: 'maven
|
|
23
|
+
apply plugin: 'maven'
|
|
24
24
|
|
|
25
25
|
buildscript {
|
|
26
26
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
@@ -38,6 +38,9 @@ buildscript {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
apply plugin: 'com.android.library'
|
|
42
|
+
apply plugin: 'maven'
|
|
43
|
+
|
|
41
44
|
android {
|
|
42
45
|
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
43
46
|
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
@@ -103,17 +106,17 @@ def configureReactNativePom(def pom) {
|
|
|
103
106
|
afterEvaluate { project ->
|
|
104
107
|
// some Gradle build hooks ref:
|
|
105
108
|
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
task androidJavadoc(type: Javadoc) {
|
|
110
|
+
source = android.sourceSets.main.java.srcDirs
|
|
111
|
+
classpath += files(android.bootClasspath)
|
|
112
|
+
classpath += files(project.getConfigurations().getByName('compile').asList())
|
|
113
|
+
include '**/*.java'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
117
|
+
classifier = 'javadoc'
|
|
118
|
+
from androidJavadoc.destinationDir
|
|
119
|
+
}
|
|
117
120
|
|
|
118
121
|
task androidSourcesJar(type: Jar) {
|
|
119
122
|
classifier = 'sources'
|
|
@@ -132,13 +135,15 @@ afterEvaluate { project ->
|
|
|
132
135
|
|
|
133
136
|
artifacts {
|
|
134
137
|
archives androidSourcesJar
|
|
135
|
-
|
|
138
|
+
archives androidJavadocJar
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
task installArchives(type: Upload) {
|
|
139
142
|
configuration = configurations.archives
|
|
140
|
-
repositories.
|
|
141
|
-
|
|
143
|
+
repositories.mavenDeployer {
|
|
144
|
+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
|
|
145
|
+
repository url: "file://${projectDir}/../android/maven"
|
|
146
|
+
configureReactNativePom pom
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.48",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -65,9 +65,7 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@react-native-community/clipboard": "*",
|
|
67
67
|
"react": "*",
|
|
68
|
-
"react-native": "*"
|
|
69
|
-
"react-native-modal": "*",
|
|
70
|
-
"react-native-modal-datetime-picker": "*"
|
|
68
|
+
"react-native": "*"
|
|
71
69
|
},
|
|
72
70
|
"devDependencies": {
|
|
73
71
|
"@babel/core": "^7.12.9",
|
|
@@ -112,14 +110,15 @@
|
|
|
112
110
|
"@miblanchard/react-native-slider": "^2.2.0",
|
|
113
111
|
"@react-native-clipboard/clipboard": "^1.11.1",
|
|
114
112
|
"@react-native-community/async-storage": "^1.12.1",
|
|
115
|
-
"@react-native-community/cameraroll": "4.
|
|
113
|
+
"@react-native-community/cameraroll": "^4.0.0",
|
|
116
114
|
"@react-native-community/checkbox": "^0.5.5",
|
|
117
|
-
"@react-native-community/datetimepicker": "
|
|
115
|
+
"@react-native-community/datetimepicker": "https://github.com/hinh-eoh/datepicker",
|
|
118
116
|
"@react-native-community/geolocation": "^2.0.2",
|
|
119
117
|
"@react-native-community/masked-view": "^0.1.10",
|
|
120
118
|
"@react-native-community/netinfo": "^9.3.4",
|
|
121
119
|
"@react-native-community/segmented-control": "^2.1.1",
|
|
122
120
|
"@react-native-community/slider": "^3.0.3",
|
|
121
|
+
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
|
|
123
122
|
"@react-native-picker/picker": "^1.16.7",
|
|
124
123
|
"@react-navigation/bottom-tabs": "^5.8.0",
|
|
125
124
|
"@react-navigation/drawer": "^5.9.0",
|
|
@@ -130,7 +129,6 @@
|
|
|
130
129
|
"apisauce": "^2.1.5",
|
|
131
130
|
"axios": "^0.19.2",
|
|
132
131
|
"base-64": "^1.0.0",
|
|
133
|
-
"buffer": "^6.0.3",
|
|
134
132
|
"deprecated-react-native-prop-types": "^2.3.0",
|
|
135
133
|
"dotenv": "^8.2.0",
|
|
136
134
|
"google-libphonenumber": "^3.2.10",
|
|
@@ -138,8 +136,7 @@
|
|
|
138
136
|
"i18n-js": "^3.7.1",
|
|
139
137
|
"i18next": "^20.1.0",
|
|
140
138
|
"lodash": "^4.17.19",
|
|
141
|
-
"lottie-
|
|
142
|
-
"lottie-react-native": "5.1.4",
|
|
139
|
+
"lottie-react-native": "4.0.3",
|
|
143
140
|
"moment": "^2.27.0",
|
|
144
141
|
"moment-timezone": "^0.5.32",
|
|
145
142
|
"numeral": "^2.0.6",
|
|
@@ -147,7 +144,7 @@
|
|
|
147
144
|
"pluralize": "^8.0.0",
|
|
148
145
|
"postinstall": "^0.7.0",
|
|
149
146
|
"precompiled-mqtt": "^4.3.14-beta",
|
|
150
|
-
"pusher-js": "^
|
|
147
|
+
"pusher-js": "^7.4.0",
|
|
151
148
|
"pusher-js-auth": "^4.0.1",
|
|
152
149
|
"python-struct": "^1.1.3",
|
|
153
150
|
"querystring": "^0.2.0",
|
|
@@ -173,7 +170,7 @@
|
|
|
173
170
|
"react-native-draggable-flatlist": "^2.6.2",
|
|
174
171
|
"react-native-fast-image": "^8.3.2",
|
|
175
172
|
"react-native-geocoder": "^0.5.0",
|
|
176
|
-
"react-native-gesture-handler": "^
|
|
173
|
+
"react-native-gesture-handler": "^1.7.0",
|
|
177
174
|
"react-native-get-location": "^2.0.0",
|
|
178
175
|
"react-native-image-crop-picker": "^0.37.2",
|
|
179
176
|
"react-native-image-resizer": "^1.4.5",
|
|
@@ -183,8 +180,8 @@
|
|
|
183
180
|
"react-native-localize": "^1.4.1",
|
|
184
181
|
"react-native-maps": "0.27.1",
|
|
185
182
|
"react-native-maps-directions": "^1.8.0",
|
|
186
|
-
"react-native-modal": "^
|
|
187
|
-
"react-native-modal-datetime-picker": "
|
|
183
|
+
"react-native-modal": "^11.5.6",
|
|
184
|
+
"react-native-modal-datetime-picker": "^8.9.3",
|
|
188
185
|
"react-native-new-snap-carousel": "^3.9.3",
|
|
189
186
|
"react-native-onesignal": "^4.3.1",
|
|
190
187
|
"react-native-pager-view": "^5.4.1",
|
|
@@ -203,7 +200,7 @@
|
|
|
203
200
|
"react-native-udp": "^4.1.3",
|
|
204
201
|
"react-native-version-check": "^3.4.2",
|
|
205
202
|
"react-native-vlc-media-player": "^1.0.41",
|
|
206
|
-
"react-native-webview": "
|
|
203
|
+
"react-native-webview": "11.17.2",
|
|
207
204
|
"react-native-wheel-color-picker": "^1.2.0",
|
|
208
205
|
"react-native-wheel-scrollview-picker": "^1.2.2",
|
|
209
206
|
"react-native-wifi-reborn": "^4.5.0",
|
|
@@ -211,8 +208,8 @@
|
|
|
211
208
|
"string-format": "^2.0.0",
|
|
212
209
|
"sync-directory": "^5.1.7",
|
|
213
210
|
"timezone-mock": "^1.1.3",
|
|
214
|
-
"uuid": "^9.0.0",
|
|
215
211
|
"uuid-by-string": "^3.0.2",
|
|
212
|
+
"uuidv4": "^6.2.13",
|
|
216
213
|
"validator": "^13.1.1",
|
|
217
214
|
"victory-native": "^35.0.1"
|
|
218
215
|
},
|
|
@@ -49,10 +49,13 @@ const NumberUpDownActionTemplate = ({
|
|
|
49
49
|
|
|
50
50
|
const doActionAndWatchConfig = useCallback(
|
|
51
51
|
async (actionData, actionValue) => {
|
|
52
|
-
let data =
|
|
53
|
-
if (
|
|
54
|
-
data
|
|
55
|
-
|
|
52
|
+
let data = actionValue;
|
|
53
|
+
if (device_type !== DEVICE_TYPE.GOOGLE_HOME) {
|
|
54
|
+
data = { temperature: actionValue };
|
|
55
|
+
if (allow_config_store_value && config) {
|
|
56
|
+
data.config_id = config;
|
|
57
|
+
data.config_value = actionValue;
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
60
|
await doAction(actionData, data);
|
|
58
61
|
if (!is_managed_by_backend) {
|
|
@@ -111,8 +111,7 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
111
111
|
await act(async () => {
|
|
112
112
|
await wheelpicker.props.onStart();
|
|
113
113
|
});
|
|
114
|
-
|
|
115
|
-
expect(mockSetAction).not.toBeCalled();
|
|
114
|
+
expect(mockSetAction).toBeCalled();
|
|
116
115
|
});
|
|
117
116
|
|
|
118
117
|
it('test WheelColorPicker onChangeColorComplete', async () => {
|
|
@@ -129,15 +128,13 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
129
128
|
await act(async () => {
|
|
130
129
|
await wheelpicker.props.onStart();
|
|
131
130
|
});
|
|
132
|
-
|
|
133
|
-
expect(mockSetAction).toBeCalledTimes(0);
|
|
131
|
+
expect(mockSetAction).toBeCalledTimes(1);
|
|
134
132
|
expect(mockDoAction).toBeCalledTimes(0);
|
|
135
133
|
|
|
136
134
|
await act(async () => {
|
|
137
135
|
await wheelpicker.props.onChangeColorComplete('#ffffff');
|
|
138
136
|
});
|
|
139
|
-
|
|
140
|
-
expect(mockSetAction).toBeCalledTimes(0);
|
|
137
|
+
expect(mockSetAction).toBeCalledTimes(2);
|
|
141
138
|
expect(mockDoAction).toBeCalledTimes(1);
|
|
142
139
|
});
|
|
143
140
|
});
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
5
5
|
import TwoButtonTemplate from '../TwoButtonTemplate';
|
|
6
6
|
|
|
7
|
+
jest.mock('react', () => ({
|
|
8
|
+
...jest.requireActual('react'),
|
|
9
|
+
useState: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
7
12
|
jest.mock('@react-navigation/native', () => {
|
|
8
13
|
return {
|
|
9
14
|
...jest.requireActual('@react-navigation/native'),
|
|
@@ -68,7 +73,11 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
68
73
|
};
|
|
69
74
|
let wrapper;
|
|
70
75
|
|
|
76
|
+
const setState = jest.fn();
|
|
77
|
+
useState.mockImplementation((init) => [init, setState]);
|
|
78
|
+
|
|
71
79
|
const assertRender = async (state, text) => {
|
|
80
|
+
useState.mockImplementationOnce((init) => [state, setState]);
|
|
72
81
|
const mockDoAction = jest.fn();
|
|
73
82
|
await act(async () => {
|
|
74
83
|
wrapper = create(
|
|
@@ -92,6 +101,7 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
92
101
|
});
|
|
93
102
|
|
|
94
103
|
const assertActionCall = async (state, action_data) => {
|
|
104
|
+
useState.mockImplementationOnce((init) => [state, setState]);
|
|
95
105
|
const mockDoAction = jest.fn();
|
|
96
106
|
await act(async () => {
|
|
97
107
|
wrapper = create(
|
|
@@ -12,6 +12,7 @@ import { API } from '../../../../configs';
|
|
|
12
12
|
import { TouchableOpacity } from 'react-native';
|
|
13
13
|
import api from '../../../../utils/Apis/axios';
|
|
14
14
|
import SharedUnit from '../../../Unit/SharedUnit';
|
|
15
|
+
import { Action } from '../../../../context/actionType';
|
|
15
16
|
|
|
16
17
|
const mock = new MockAdapter(api.axiosInstance);
|
|
17
18
|
|
|
@@ -74,6 +75,10 @@ describe('Test MyPinnedSharedUnit', () => {
|
|
|
74
75
|
goToAllSharedUnits.props.onPress();
|
|
75
76
|
});
|
|
76
77
|
expect(mockedNavigate).toHaveBeenCalled();
|
|
78
|
+
expect(mockSetAction).toBeCalledWith(
|
|
79
|
+
Action.IS_CHECK_CLEAR_CACHE_UNITS,
|
|
80
|
+
false
|
|
81
|
+
);
|
|
77
82
|
});
|
|
78
83
|
|
|
79
84
|
it('render without item', async () => {
|
|
@@ -96,7 +96,12 @@ const MyPinnedSharedUnit = ({ refreshing }) => {
|
|
|
96
96
|
.filter((sharedUnit) => sharedUnit?.is_pin)
|
|
97
97
|
.map((item, index) => (
|
|
98
98
|
<View key={item.id}>
|
|
99
|
-
<SharedUnit
|
|
99
|
+
<SharedUnit
|
|
100
|
+
item={item}
|
|
101
|
+
index={index}
|
|
102
|
+
navigation={navigation}
|
|
103
|
+
isOptions={false}
|
|
104
|
+
/>
|
|
100
105
|
{index !== sharedUnits.length - 1 && (
|
|
101
106
|
<View style={styles.separator} />
|
|
102
107
|
)}
|
|
@@ -189,15 +189,13 @@ const MyUnit = ({ refreshing }) => {
|
|
|
189
189
|
|
|
190
190
|
useEffect(() => {
|
|
191
191
|
if (isDeleteUnitSuccessFully || previousMyUnits?.length > myUnits?.length) {
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
const to = setTimeout(() => {
|
|
193
|
+
carouselRef?.current?.snapToItem();
|
|
194
|
+
setAction(Action.RESET_DELETE_UNIT_ACTION);
|
|
195
|
+
}, 60);
|
|
196
|
+
return () => clearTimeout(to);
|
|
194
197
|
}
|
|
195
|
-
}, [
|
|
196
|
-
isDeleteUnitSuccessFully,
|
|
197
|
-
setAction,
|
|
198
|
-
previousMyUnits?.length,
|
|
199
|
-
myUnits?.length,
|
|
200
|
-
]);
|
|
198
|
+
}, [isDeleteUnitSuccessFully, setAction, previousMyUnits, myUnits]);
|
|
201
199
|
|
|
202
200
|
return (
|
|
203
201
|
<>
|
|
@@ -119,7 +119,7 @@ const DateTimeRangeChange = memo(
|
|
|
119
119
|
</View>
|
|
120
120
|
<DateTimePickerModal
|
|
121
121
|
isVisible={eventPicker.showModalStart}
|
|
122
|
-
date={startDate.
|
|
122
|
+
date={startDate.valueOf()}
|
|
123
123
|
mode={mode}
|
|
124
124
|
onConfirm={onConfirmStart}
|
|
125
125
|
onCancel={onCancel}
|
|
@@ -132,7 +132,7 @@ const DateTimeRangeChange = memo(
|
|
|
132
132
|
/>
|
|
133
133
|
<DateTimePickerModal
|
|
134
134
|
isVisible={eventPicker.showModalEnd}
|
|
135
|
-
date={endDate.
|
|
135
|
+
date={endDate.valueOf()}
|
|
136
136
|
mode={mode}
|
|
137
137
|
onConfirm={onConfirmEnd}
|
|
138
138
|
onCancel={onCancel}
|
|
@@ -142,7 +142,7 @@ const DateTimeRangeChange = memo(
|
|
|
142
142
|
cancelTextIOS={t('cancel')}
|
|
143
143
|
confirmTextIOS={t('confirm')}
|
|
144
144
|
maximumDate={new Date()}
|
|
145
|
-
minimumDate={startDate.
|
|
145
|
+
minimumDate={startDate.valueOf()}
|
|
146
146
|
/>
|
|
147
147
|
</View>
|
|
148
148
|
);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Platform,
|
|
4
3
|
StyleSheet,
|
|
5
4
|
TouchableOpacity,
|
|
6
5
|
TouchableWithoutFeedback,
|
|
@@ -59,10 +58,7 @@ const ItemHanetDevice = memo(
|
|
|
59
58
|
{title}
|
|
60
59
|
</Text>
|
|
61
60
|
<View style={styles.row}>
|
|
62
|
-
<IconOutline
|
|
63
|
-
name={Platform.OS === 'android' ? 'right-square' : 'right'}
|
|
64
|
-
size={12}
|
|
65
|
-
/>
|
|
61
|
+
<IconOutline name="right" size={12} />
|
|
66
62
|
</View>
|
|
67
63
|
</TouchableOpacity>
|
|
68
64
|
</View>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TouchableWithoutFeedback, View } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import Text from '../../Text';
|
|
5
5
|
|
|
@@ -16,11 +16,7 @@ const ItemAddNew = memo(({ title, onAddNew, wrapStyle }) => {
|
|
|
16
16
|
<View style={[styles.container, wrapStyle]}>
|
|
17
17
|
<View style={styles.boxIcon}>
|
|
18
18
|
<View style={styles.buttonPlus}>
|
|
19
|
-
<IconOutline
|
|
20
|
-
name={Platform.OS === 'android' ? 'plus-square' : 'plus'}
|
|
21
|
-
size={22}
|
|
22
|
-
color={Colors.Gray8}
|
|
23
|
-
/>
|
|
19
|
+
<IconOutline name="plus" size={22} color={Colors.Gray8} />
|
|
24
20
|
</View>
|
|
25
21
|
</View>
|
|
26
22
|
<View>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Platform,
|
|
4
3
|
StyleSheet,
|
|
5
4
|
TouchableOpacity,
|
|
6
5
|
TouchableWithoutFeedback,
|
|
@@ -160,10 +159,7 @@ const ItemDevice = memo(
|
|
|
160
159
|
>
|
|
161
160
|
{description || textConnected}
|
|
162
161
|
</Text>
|
|
163
|
-
<IconOutline
|
|
164
|
-
name={Platform.OS === 'android' ? 'right-square' : 'right'}
|
|
165
|
-
size={12}
|
|
166
|
-
/>
|
|
162
|
+
<IconOutline name="right" size={12} />
|
|
167
163
|
</View>
|
|
168
164
|
</TouchableOpacity>
|
|
169
165
|
</View>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import renderer, { act } from 'react-test-renderer';
|
|
4
3
|
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
@@ -13,7 +12,6 @@ const wrapComponent = ({ ...rest }) => (
|
|
|
13
12
|
</SCProvider>
|
|
14
13
|
);
|
|
15
14
|
|
|
16
|
-
// NOTE: Hinh will fix it later
|
|
17
15
|
describe('Test FlatListDnD', () => {
|
|
18
16
|
let tree;
|
|
19
17
|
let setData = jest.fn();
|
|
@@ -21,31 +19,31 @@ describe('Test FlatListDnD', () => {
|
|
|
21
19
|
let renderItem = () => <></>;
|
|
22
20
|
|
|
23
21
|
it('render FlatListDnD onDragEndCT', async () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
const onDragEndCT = jest.fn();
|
|
23
|
+
await act(async () => {
|
|
24
|
+
tree = renderer.create(
|
|
25
|
+
wrapComponent({ data, setData, onDragEndCT, renderItem })
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
const instance = tree.root;
|
|
29
|
+
const draggableFlatList = instance.findAllByType(DraggableFlatList);
|
|
30
|
+
expect(draggableFlatList.length).toBe(1);
|
|
31
|
+
await act(async () => {
|
|
32
|
+
draggableFlatList[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
|
|
33
|
+
});
|
|
34
|
+
expect(setData).toBeCalledWith([{ id: 2 }, { id: 1 }]);
|
|
37
35
|
});
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
it('render FlatListDnD onDragEnd', async () => {
|
|
38
|
+
await act(async () => {
|
|
39
|
+
tree = renderer.create(wrapComponent({ data, setData, renderItem }));
|
|
40
|
+
});
|
|
41
|
+
const instance = tree.root;
|
|
42
|
+
const draggableFlatList = instance.findAllByType(DraggableFlatList);
|
|
43
|
+
expect(draggableFlatList.length).toBe(1);
|
|
44
|
+
await act(async () => {
|
|
45
|
+
draggableFlatList[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
|
|
46
|
+
});
|
|
47
|
+
expect(setData).toBeCalledWith([{ id: 2 }, { id: 1 }]);
|
|
48
|
+
});
|
|
51
49
|
});
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import { TouchableOpacity } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
6
6
|
import GroupCheckBox from '..';
|
|
7
7
|
|
|
8
|
+
jest.mock('react', () => ({
|
|
9
|
+
...jest.requireActual('react'),
|
|
10
|
+
useState: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
8
13
|
describe('Test Group CheckBox', () => {
|
|
9
14
|
let tree;
|
|
15
|
+
const mockSetState = () => {
|
|
16
|
+
const setState = jest.fn();
|
|
17
|
+
useState.mockImplementation((init) => [init, setState]);
|
|
18
|
+
return setState;
|
|
19
|
+
};
|
|
10
20
|
|
|
11
21
|
const findGroupCheckBoxItem = (instance) => {
|
|
12
22
|
const item = instance.find(
|
|
@@ -24,6 +34,7 @@ describe('Test Group CheckBox', () => {
|
|
|
24
34
|
description: 'description',
|
|
25
35
|
},
|
|
26
36
|
];
|
|
37
|
+
mockSetState();
|
|
27
38
|
await act(async () => {
|
|
28
39
|
tree = await create(<GroupCheckBox data={data} />);
|
|
29
40
|
});
|
|
@@ -40,6 +51,7 @@ describe('Test Group CheckBox', () => {
|
|
|
40
51
|
},
|
|
41
52
|
];
|
|
42
53
|
const mockFunc = jest.fn();
|
|
54
|
+
const setState = mockSetState();
|
|
43
55
|
await act(async () => {
|
|
44
56
|
tree = await create(
|
|
45
57
|
<GroupCheckBox data={data} onSelect={mockFunc} multiple />
|
|
@@ -50,6 +62,9 @@ describe('Test Group CheckBox', () => {
|
|
|
50
62
|
await act(async () => {
|
|
51
63
|
item.props.onSelect(0);
|
|
52
64
|
});
|
|
65
|
+
expect(setState).toHaveBeenCalledTimes(2);
|
|
66
|
+
expect(setState).toHaveBeenNthCalledWith(1, [0]);
|
|
67
|
+
expect(setState).toHaveBeenNthCalledWith(2, [0]);
|
|
53
68
|
expect(mockFunc).toHaveBeenCalledWith([
|
|
54
69
|
{ description: 'description', source: 'source', title: 'testItem' },
|
|
55
70
|
]);
|
|
@@ -70,6 +85,7 @@ describe('Test Group CheckBox', () => {
|
|
|
70
85
|
},
|
|
71
86
|
];
|
|
72
87
|
const mockFunc = jest.fn();
|
|
88
|
+
const setState = mockSetState();
|
|
73
89
|
await act(async () => {
|
|
74
90
|
tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
|
|
75
91
|
});
|
|
@@ -78,6 +94,8 @@ describe('Test Group CheckBox', () => {
|
|
|
78
94
|
await act(async () => {
|
|
79
95
|
item.props.onSelect(0);
|
|
80
96
|
});
|
|
97
|
+
expect(setState).toHaveBeenNthCalledWith(1, [0]);
|
|
98
|
+
expect(setState).toHaveBeenNthCalledWith(2, [0]);
|
|
81
99
|
expect(mockFunc).toHaveBeenCalledWith({
|
|
82
100
|
description: 'description 1',
|
|
83
101
|
title: 'title 1',
|
|
@@ -96,6 +114,8 @@ describe('Test Group CheckBox', () => {
|
|
|
96
114
|
},
|
|
97
115
|
];
|
|
98
116
|
const mockFunc = jest.fn();
|
|
117
|
+
const setState = jest.fn();
|
|
118
|
+
useState.mockImplementation((init) => [[0], setState]);
|
|
99
119
|
await act(async () => {
|
|
100
120
|
tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
|
|
101
121
|
});
|
|
@@ -108,6 +128,7 @@ describe('Test Group CheckBox', () => {
|
|
|
108
128
|
await act(async () => {
|
|
109
129
|
items[1].props.onSelect(0);
|
|
110
130
|
});
|
|
131
|
+
expect(setState).toHaveBeenCalledWith([]); // called 1 time
|
|
111
132
|
expect(mockFunc).toHaveBeenCalledWith({
|
|
112
133
|
description: 'description 1',
|
|
113
134
|
title: 'title 1',
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
2
|
import { Icon } from '@ant-design/react-native';
|
|
3
|
-
import {
|
|
4
|
-
TouchableOpacity,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
Animated,
|
|
7
|
-
View,
|
|
8
|
-
Platform,
|
|
9
|
-
} from 'react-native';
|
|
3
|
+
import { TouchableOpacity, StyleSheet, Animated, View } from 'react-native';
|
|
10
4
|
import { useNavigation } from '@react-navigation/native';
|
|
11
5
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
12
6
|
|
|
@@ -101,11 +95,7 @@ const HeaderAni = memo(
|
|
|
101
95
|
onPress={onPressLeft}
|
|
102
96
|
accessibilityLabel={AccessibilityLabel.ICON_BACK}
|
|
103
97
|
>
|
|
104
|
-
<Icon
|
|
105
|
-
name={Platform.OS === 'android' ? 'left-square' : 'left'}
|
|
106
|
-
size={27}
|
|
107
|
-
color={Colors.Gray9}
|
|
108
|
-
/>
|
|
98
|
+
<Icon name={'left'} size={27} color={Colors.Gray9} />
|
|
109
99
|
</TouchableOpacity>
|
|
110
100
|
<View styles={styles.wrapRightComponent}>{rightComponent}</View>
|
|
111
101
|
</Animated.View>
|