@eohjsc/react-native-smart-city 0.4.41 → 0.4.42
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/android/build.gradle +24 -19
- package/package.json +12 -14
- package/src/commons/Action/ItemQuickAction.js +0 -1
- package/src/commons/ActionGroup/ColorPickerTemplate.js +4 -3
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +5 -4
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -6
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +17 -6
- package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +20 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +14 -37
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +31 -71
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +17 -13
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +48 -44
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +22 -56
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +21 -123
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +16 -12
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +38 -73
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +15 -11
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +15 -11
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +31 -21
- package/src/commons/ActionGroup/__test__/index.test.js +21 -36
- package/src/commons/ActionGroup/index.js +7 -4
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
- package/src/commons/Dashboard/MyUnit/index.js +2 -2
- package/src/commons/DateTimeRangeChange/index.js +3 -3
- package/src/commons/Device/HistoryChart.js +1 -1
- package/src/commons/Device/HorizontalBarChart.js +4 -3
- package/src/commons/Device/LinearChart.js +5 -3
- 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/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +3 -5
- package/src/commons/Processing/index.js +0 -1
- package/src/commons/Processing/styles.js +0 -3
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +0 -1
- package/src/commons/Unit/HeaderUnit/index.js +8 -15
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
- package/src/configs/AccessibilityLabel.js +0 -1
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
- package/src/hooks/useMqtt.js +2 -5
- package/src/iot/mqtt.js +0 -2
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
- package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +2 -19
- package/src/screens/Automate/AddNewAction/__test__/{SetupConfigCondition.test.js → SetupSensor.test.js} +0 -97
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
- 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 +45 -40
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +2 -14
- package/src/screens/Device/components/ChartWrapper.js +12 -14
- package/src/screens/Device/components/SensorDisplayItem.js +2 -18
- package/src/screens/Device/components/VisualChart.js +3 -17
- package/src/screens/Device/components/__test__/VisualChart.test.js +15 -12
- package/src/screens/Device/detail.js +15 -34
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
- package/src/screens/Device/styles.js +0 -3
- package/src/screens/Sharing/MemberList.js +3 -16
- package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
- package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
- package/src/screens/Unit/SelectAddToFavorites.js +0 -1
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
- package/src/utils/Apis/axios.js +0 -1
- package/src/utils/I18n/translations/en.js +0 -2
- package/src/utils/I18n/translations/vi.js +0 -2
- package/src/utils/Monitor.js +2 -2
- package/src/commons/Highcharts/index.js +0 -111
- package/src/commons/icon/index.js +0 -57
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect } from 'react';
|
|
2
2
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
3
3
|
import { useNavigation, useIsFocused } from '@react-navigation/native';
|
|
4
|
-
import {
|
|
4
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
5
5
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
6
|
|
|
7
7
|
import { Colors } from '../../configs';
|
|
@@ -17,8 +17,6 @@ import { useSCContextSelector } from '../../context';
|
|
|
17
17
|
import { useBackendPermission } from '../../utils/Permission/backend';
|
|
18
18
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
19
19
|
|
|
20
|
-
const isAndroid = Platform.OS === 'android';
|
|
21
|
-
|
|
22
20
|
const MemberList = ({ route }) => {
|
|
23
21
|
const t = useTranslations();
|
|
24
22
|
const { navigate } = useNavigation();
|
|
@@ -71,16 +69,6 @@ const MemberList = ({ route }) => {
|
|
|
71
69
|
hideStateAlertSharingMenu();
|
|
72
70
|
}, [hideStateAlertSharingMenu, isOwner, leaveUnit, unit.name]);
|
|
73
71
|
|
|
74
|
-
const getIconRight = useCallback(() => {
|
|
75
|
-
if (isOwner) {
|
|
76
|
-
if (isAndroid) {
|
|
77
|
-
return 'plus-square';
|
|
78
|
-
}
|
|
79
|
-
return 'plus';
|
|
80
|
-
}
|
|
81
|
-
return 'ellipsis';
|
|
82
|
-
}, [isOwner]);
|
|
83
|
-
|
|
84
72
|
useEffect(() => {
|
|
85
73
|
if (isFocused) {
|
|
86
74
|
onRefresh();
|
|
@@ -91,13 +79,12 @@ const MemberList = ({ route }) => {
|
|
|
91
79
|
<TouchableOpacity
|
|
92
80
|
accessibilityLabel={AccessibilityLabel.MEMBER_LIST_RIGHT_HEADER_TOUCH}
|
|
93
81
|
onPress={onPressRightHeader}
|
|
94
|
-
style={
|
|
82
|
+
style={styles.rightHeader}
|
|
95
83
|
>
|
|
96
84
|
<IconOutline
|
|
97
|
-
name={
|
|
85
|
+
name={isOwner ? 'plus' : 'more'}
|
|
98
86
|
size={30}
|
|
99
87
|
color={Colors.Black}
|
|
100
|
-
style={{ transform: [{ rotate: isOwner ? '0deg' : '90deg' }] }}
|
|
101
88
|
/>
|
|
102
89
|
</TouchableOpacity>
|
|
103
90
|
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
1
|
import { act } from '@testing-library/react-hooks';
|
|
3
2
|
import React, { useState } from 'react';
|
|
4
3
|
import { FlatList, Text, Platform } from 'react-native';
|
|
@@ -24,8 +23,6 @@ jest.mock('react', () => {
|
|
|
24
23
|
};
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
// NOTE: Hinh will fix it later
|
|
28
|
-
|
|
29
26
|
const mockNavigate = jest.fn();
|
|
30
27
|
const mockGoBack = jest.fn();
|
|
31
28
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -47,6 +44,20 @@ const wrapComponent = (route) => (
|
|
|
47
44
|
describe('Test SelectPermission', () => {
|
|
48
45
|
let tree;
|
|
49
46
|
let route = { params: { unit: { id: 1, name: 'unit 1' } } };
|
|
47
|
+
let listDevices = [
|
|
48
|
+
{
|
|
49
|
+
id: 204,
|
|
50
|
+
name: 'device',
|
|
51
|
+
devices: [
|
|
52
|
+
{
|
|
53
|
+
id: 123,
|
|
54
|
+
actions: [{ id: 136, name: 'action 1' }],
|
|
55
|
+
read_configs: [{ id: 137, name: 'config 1' }],
|
|
56
|
+
name: 'child1',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
50
61
|
|
|
51
62
|
const mockSetTickAllDevice = jest.fn();
|
|
52
63
|
const mockSetActiveItemId = jest.fn();
|
|
@@ -59,6 +70,23 @@ describe('Test SelectPermission', () => {
|
|
|
59
70
|
mockSetDataStations.mockClear();
|
|
60
71
|
});
|
|
61
72
|
|
|
73
|
+
function mockLoading() {
|
|
74
|
+
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
75
|
+
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
76
|
+
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
77
|
+
useState.mockImplementationOnce((init) => [false, mockSetState]); // loading
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function mocSetdata() {
|
|
81
|
+
useState.mockImplementationOnce((init) => [
|
|
82
|
+
listDevices,
|
|
83
|
+
mockSetDataStations,
|
|
84
|
+
]);
|
|
85
|
+
useState.mockImplementationOnce((init) => [init, mockSetTickAllDevice]);
|
|
86
|
+
useState.mockImplementationOnce((init) => [init, mockSetActiveItemId]);
|
|
87
|
+
useState.mockImplementationOnce((init) => [false, mockSetState]); // loading
|
|
88
|
+
}
|
|
89
|
+
|
|
62
90
|
it('test unit null', async () => {
|
|
63
91
|
Platform.OS = 'android';
|
|
64
92
|
await act(async () => {
|
|
@@ -70,6 +98,7 @@ describe('Test SelectPermission', () => {
|
|
|
70
98
|
});
|
|
71
99
|
|
|
72
100
|
it('render empty list', async () => {
|
|
101
|
+
mockLoading();
|
|
73
102
|
Platform.OS = 'ios';
|
|
74
103
|
route.params.unit = 1;
|
|
75
104
|
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(200);
|
|
@@ -81,29 +110,32 @@ describe('Test SelectPermission', () => {
|
|
|
81
110
|
expect(TextElement[2].props.children).toBe('No data');
|
|
82
111
|
});
|
|
83
112
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
it('test unit get permission default', async () => {
|
|
114
|
+
mocSetdata();
|
|
115
|
+
const routes = { params: { unit: { id: 1, name: '123' } } };
|
|
116
|
+
mock.onGet(API.SHARE.UNIT_PERMISSIONS(1)).reply(200);
|
|
117
|
+
await act(async () => {
|
|
118
|
+
tree = await create(wrapComponent(routes));
|
|
119
|
+
});
|
|
120
|
+
const instance = tree.root;
|
|
121
|
+
const FlatListElement = instance.findAllByType(FlatList);
|
|
122
|
+
expect(FlatListElement).toHaveLength(1);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('test unit fail default', async () => {
|
|
126
|
+
mockLoading();
|
|
127
|
+
const routes = { params: { unit: null } };
|
|
128
|
+
mock.onGet(API.SHARE.UNIT_PERMISSIONS(1)).reply(400);
|
|
129
|
+
await act(async () => {
|
|
130
|
+
tree = await create(wrapComponent(routes));
|
|
131
|
+
});
|
|
132
|
+
const instance = tree.root;
|
|
133
|
+
const TextElement = instance.findAllByType(Text);
|
|
134
|
+
expect(TextElement[2].props.children).toBe('No data');
|
|
135
|
+
});
|
|
105
136
|
|
|
106
137
|
it('test get unit fail shared', async () => {
|
|
138
|
+
mockLoading();
|
|
107
139
|
route.params.unit = 1;
|
|
108
140
|
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(400);
|
|
109
141
|
await act(async () => {
|
|
@@ -114,80 +146,87 @@ describe('Test SelectPermission', () => {
|
|
|
114
146
|
expect(TextElement[2].props.children).toBe('No data');
|
|
115
147
|
});
|
|
116
148
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
149
|
+
it('render list', async () => {
|
|
150
|
+
mocSetdata();
|
|
151
|
+
await act(async () => {
|
|
152
|
+
tree = await create(wrapComponent(route));
|
|
153
|
+
});
|
|
154
|
+
const instance = tree.root;
|
|
155
|
+
const FlatListElement = instance.findAllByType(FlatList);
|
|
156
|
+
expect(FlatListElement).toHaveLength(1);
|
|
157
|
+
const TitleCheckBoxElement = instance.findAllByType(TitleCheckBox);
|
|
158
|
+
expect(TitleCheckBoxElement).toHaveLength(2);
|
|
159
|
+
await act(async () => {
|
|
160
|
+
TitleCheckBoxElement[0].props.onPress(null, true);
|
|
161
|
+
});
|
|
162
|
+
expect(mockSetTickAllDevice).toBeCalledWith(true);
|
|
163
|
+
expect(mockSetDataStations).toBeCalledWith([
|
|
164
|
+
{
|
|
165
|
+
id: 204,
|
|
166
|
+
isChecked: true,
|
|
167
|
+
name: 'device',
|
|
168
|
+
devices: [
|
|
169
|
+
{
|
|
170
|
+
actions: [{ id: 136, isChecked: true, name: 'action 1' }],
|
|
171
|
+
id: 123,
|
|
172
|
+
isChecked: true,
|
|
173
|
+
name: 'child1',
|
|
174
|
+
read_configs: [{ id: 137, isChecked: true, name: 'config 1' }],
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
]);
|
|
179
|
+
await act(async () => {
|
|
180
|
+
TitleCheckBoxElement[0].props.onPress(204, true);
|
|
181
|
+
});
|
|
182
|
+
expect(mockSetTickAllDevice).toBeCalledWith(true);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('test onTickedChild function', async () => {
|
|
186
|
+
mocSetdata();
|
|
187
|
+
await act(async () => {
|
|
188
|
+
tree = await create(wrapComponent(route));
|
|
189
|
+
});
|
|
190
|
+
const instance = tree.root;
|
|
191
|
+
const DeviceItemElement = instance.findAllByType(DeviceItem);
|
|
192
|
+
expect(DeviceItemElement).toHaveLength(1);
|
|
193
|
+
await act(async () => {
|
|
194
|
+
DeviceItemElement[0].props.onTickedChild(204, 123, 137, true, true);
|
|
195
|
+
});
|
|
196
|
+
expect(mockSetDataStations).toBeCalled();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('test onTickedDevice function', async () => {
|
|
200
|
+
mocSetdata();
|
|
201
|
+
await act(async () => {
|
|
202
|
+
tree = await create(wrapComponent(route));
|
|
203
|
+
});
|
|
204
|
+
const instance = tree.root;
|
|
205
|
+
const DeviceItemElement = instance.findAllByType(DeviceItem);
|
|
206
|
+
expect(DeviceItemElement).toHaveLength(1);
|
|
207
|
+
await act(async () => {
|
|
208
|
+
DeviceItemElement[0].props.onTickedDevice(204, 123, true);
|
|
209
|
+
DeviceItemElement[0].props.toggleItem(123);
|
|
210
|
+
});
|
|
211
|
+
expect(mockSetDataStations).toBeCalled();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('test onTickedDeviceIcon function', async () => {
|
|
215
|
+
mocSetdata();
|
|
216
|
+
await act(async () => {
|
|
217
|
+
tree = await create(wrapComponent(route));
|
|
218
|
+
});
|
|
219
|
+
const instance = tree.root;
|
|
220
|
+
const DeviceItemElement = instance.findAllByType(DeviceItem);
|
|
221
|
+
expect(DeviceItemElement).toHaveLength(1);
|
|
222
|
+
await act(async () => {
|
|
223
|
+
DeviceItemElement[0].props.onTickedDeviceIcon(204, 123, true);
|
|
224
|
+
});
|
|
225
|
+
expect(mockSetDataStations).toBeCalled();
|
|
226
|
+
});
|
|
189
227
|
|
|
190
228
|
it('test ViewButtonBottom', async () => {
|
|
229
|
+
mocSetdata();
|
|
191
230
|
await act(async () => {
|
|
192
231
|
tree = await create(wrapComponent(route));
|
|
193
232
|
});
|
|
@@ -204,6 +243,8 @@ describe('Test SelectPermission', () => {
|
|
|
204
243
|
});
|
|
205
244
|
|
|
206
245
|
it('test selectPermission type share_device', async () => {
|
|
246
|
+
mocSetdata();
|
|
247
|
+
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
207
248
|
const response = {
|
|
208
249
|
status: 200,
|
|
209
250
|
data: [
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { act, create } from 'react-test-renderer';
|
|
4
3
|
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
@@ -29,8 +28,6 @@ jest.mock('@react-navigation/native', () => {
|
|
|
29
28
|
};
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
// NOTE: Hinh will fix it later
|
|
33
|
-
|
|
34
31
|
describe('Test EditTemplate', () => {
|
|
35
32
|
let tree;
|
|
36
33
|
const data = [
|
|
@@ -44,55 +41,55 @@ describe('Test EditTemplate', () => {
|
|
|
44
41
|
];
|
|
45
42
|
|
|
46
43
|
it('Test render empty', async () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
useRoute.mockReturnValue({
|
|
45
|
+
params: {},
|
|
46
|
+
});
|
|
47
|
+
await act(async () => {
|
|
48
|
+
tree = await create(wrapComponent());
|
|
49
|
+
});
|
|
50
|
+
const instance = tree.root;
|
|
51
|
+
const Texts = instance.findAllByType(Text);
|
|
52
|
+
expect(Texts[0].props.children).toBe(getTranslate('en', 'no_widgets'));
|
|
53
|
+
expect(Texts[1].props.children).toBe(getTranslate('en', 'add_your_widget'));
|
|
57
54
|
});
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
it('Test render list widgets', async () => {
|
|
57
|
+
useRoute.mockReturnValue({
|
|
58
|
+
params: {
|
|
59
|
+
data,
|
|
60
|
+
setData: mockSetData,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
await act(async () => {
|
|
64
|
+
tree = await create(wrapComponent());
|
|
65
|
+
});
|
|
66
|
+
const instance = tree.root;
|
|
67
|
+
const DraggableFlatLists = instance.findAllByType(DraggableFlatList);
|
|
68
|
+
expect(DraggableFlatLists).toHaveLength(1);
|
|
72
69
|
|
|
73
|
-
|
|
70
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
await act(async () => {
|
|
73
|
+
await TouchableOpacities[0].props.onPress();
|
|
74
|
+
});
|
|
75
|
+
await act(async () => {
|
|
76
|
+
const firstItem = instance.findByProps({ accessibilityLabel: 'item-0' });
|
|
77
|
+
await firstItem.props.onLongPress();
|
|
78
|
+
});
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
expect(mockGoBack).toBeCalled();
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
mockGoBack.mockReset();
|
|
83
|
+
await act(async () => {
|
|
84
|
+
await DraggableFlatLists[0].props.onDragEnd({
|
|
85
|
+
data,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
await act(async () => {
|
|
89
|
+
await instance
|
|
90
|
+
.findByProps({ accessibilityLabel: 'Save' })
|
|
91
|
+
.props.onPress();
|
|
92
|
+
});
|
|
93
|
+
expect(mockGoBack).toBeCalled();
|
|
94
|
+
});
|
|
98
95
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
2
|
import { Alert } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import MockAdapter from 'axios-mock-adapter';
|
|
@@ -83,6 +83,14 @@ jest.mock('react-native-permissions', () => {
|
|
|
83
83
|
return require('react-native-permissions/mock');
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
jest.mock('react', () => {
|
|
87
|
+
return {
|
|
88
|
+
...jest.requireActual('react'),
|
|
89
|
+
memo: (x) => x,
|
|
90
|
+
useRef: jest.fn(),
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
|
|
86
94
|
describe('Test SelectAddress', () => {
|
|
87
95
|
let tree, route, Platform;
|
|
88
96
|
const mockUpdateLocation = jest.fn();
|
|
@@ -178,7 +186,7 @@ describe('Test SelectAddress', () => {
|
|
|
178
186
|
animateToRegion,
|
|
179
187
|
},
|
|
180
188
|
};
|
|
181
|
-
|
|
189
|
+
useRef.mockImplementation(() => mapRef);
|
|
182
190
|
await act(async () => {
|
|
183
191
|
tree = await create(wrapComponent(route));
|
|
184
192
|
});
|
|
@@ -219,8 +227,7 @@ describe('Test SelectAddress', () => {
|
|
|
219
227
|
await act(async () => {
|
|
220
228
|
await rowLocations[0].props.onPress({ place_id: 1, description: '1' });
|
|
221
229
|
});
|
|
222
|
-
|
|
223
|
-
expect(animateToRegion).not.toBeCalled();
|
|
230
|
+
expect(animateToRegion).toBeCalled();
|
|
224
231
|
});
|
|
225
232
|
|
|
226
233
|
it('test get lat lng of location failed', async () => {
|
package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
import { AccessibilityLabel } from '../../../../../configs/Constants';
|
|
4
4
|
import { API, Colors } from '../../../../../configs';
|
|
@@ -9,6 +9,15 @@ import MockAdapter from 'axios-mock-adapter';
|
|
|
9
9
|
import api from '../../../../../utils/Apis/axios';
|
|
10
10
|
|
|
11
11
|
const mock = new MockAdapter(api.axiosInstance);
|
|
12
|
+
const mockSetState = jest.fn();
|
|
13
|
+
|
|
14
|
+
jest.mock('react', () => {
|
|
15
|
+
return {
|
|
16
|
+
...jest.requireActual('react'),
|
|
17
|
+
useState: jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
useState.mockImplementation((init) => [init, mockSetState]);
|
|
12
21
|
|
|
13
22
|
const wrapComponent = (summaryDetail) => (
|
|
14
23
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -84,5 +93,6 @@ describe('Test 3PPowerConsumption', () => {
|
|
|
84
93
|
await act(async () => {
|
|
85
94
|
tree = await renderer.create(wrapComponent(summaryDetail));
|
|
86
95
|
});
|
|
96
|
+
expect(mockSetState).toHaveBeenCalledWith([{}]);
|
|
87
97
|
});
|
|
88
98
|
});
|
package/src/utils/Apis/axios.js
CHANGED
|
@@ -1425,6 +1425,4 @@ export default {
|
|
|
1425
1425
|
actions: 'actions',
|
|
1426
1426
|
value_must_be_less_than_8_character:
|
|
1427
1427
|
'Value must be less than or equal to 8 characters',
|
|
1428
|
-
bellow_widget_is_not_configured: 'Bellow widget is not configured',
|
|
1429
|
-
bellow_widget_is_wrongly_configured: 'Bellow widget is wrongly configured',
|
|
1430
1428
|
};
|
|
@@ -1436,6 +1436,4 @@ export default {
|
|
|
1436
1436
|
you_can_only_add_more: 'Bạn chỉ có thể thêm {number}',
|
|
1437
1437
|
actions: 'hành động',
|
|
1438
1438
|
value_must_be_less_than_8_character: 'Giá trị phải ít hơn hoặc bằng 8 kí tự',
|
|
1439
|
-
bellow_widget_is_not_configured: 'Tiện ích bên dưới chưa được cấu hình',
|
|
1440
|
-
bellow_widget_is_wrongly_configured: 'Tiện ích bên dưới được cấu hình sai',
|
|
1441
1439
|
};
|
package/src/utils/Monitor.js
CHANGED
|
@@ -2,8 +2,8 @@ import { getPusher, destroyPusher } from './Pusher';
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
4
4
|
export const watchNotificationData = (user, callback) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const channel = getPusher().subscribe(`private-user-${user.id}`);
|
|
6
|
+
channel.bind('new-notification', callback);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const unwatchNotificationData = (user) => {
|