@eohjsc/react-native-smart-city 0.4.39 → 0.4.41
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 +1 -1
- package/package.json +2 -2
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -5
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -5
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
- package/src/commons/ActionGroup/SliderRangeTemplate.js +5 -3
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +6 -20
- 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 +3 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +133 -135
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +37 -14
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +71 -31
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +13 -17
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +44 -48
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +56 -22
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +123 -21
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +12 -16
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +73 -38
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +21 -31
- package/src/commons/ActionGroup/__test__/index.test.js +36 -21
- package/src/commons/ActionGroup/index.js +4 -7
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +0 -5
- package/src/commons/Dashboard/MyUnit/index.js +2 -2
- package/src/commons/FlatListDnD/__test__/index.test.js +27 -25
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +1 -22
- package/src/commons/HeaderAni/index.js +12 -2
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +1 -23
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +5 -3
- package/src/commons/Processing/index.js +1 -0
- package/src/commons/Processing/styles.js +3 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +1 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -58
- package/src/commons/icon/index.js +57 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +52 -51
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -2
- package/src/hooks/useMqtt.js +5 -2
- package/src/iot/mqtt.js +2 -0
- 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 +31 -32
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +19 -2
- package/src/screens/Automate/AddNewAction/__test__/{SetupSensor.test.js → SetupConfigCondition.test.js} +97 -0
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +69 -68
- package/src/screens/ChangePosition/__test__/index.test.js +34 -32
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -11
- package/src/screens/Device/__test__/detail.test.js +40 -45
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -2
- package/src/screens/Device/components/ChartWrapper.js +14 -12
- package/src/screens/Device/components/SensorDisplayItem.js +18 -2
- package/src/screens/Device/components/VisualChart.js +7 -1
- package/src/screens/Device/components/__test__/VisualChart.test.js +0 -3
- package/src/screens/Device/detail.js +32 -14
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +20 -18
- package/src/screens/Device/styles.js +3 -0
- package/src/screens/Sharing/MemberList.js +16 -3
- package/src/screens/Sharing/__test__/SelectPermission.test.js +96 -137
- package/src/screens/Template/__test__/EditTemplate.test.js +48 -45
- package/src/screens/Unit/SelectAddToFavorites.js +1 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +4 -11
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -11
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.js +2 -0
- package/src/utils/I18n/translations/vi.js +2 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
|
@@ -527,7 +527,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
529
|
});
|
|
530
|
-
configIdsTemp.current = configIds;
|
|
530
|
+
configIdsTemp.current = configIds.filter(Boolean);
|
|
531
531
|
|
|
532
532
|
configIds.map((id) => {
|
|
533
533
|
params.append('config', id);
|
|
@@ -701,7 +701,12 @@ const DeviceDetail = ({ route }) => {
|
|
|
701
701
|
ref={refMenuAction}
|
|
702
702
|
accessibilityLabel={AccessibilityLabel.HEADER_DEVICE_BUTTON_MORE}
|
|
703
703
|
>
|
|
704
|
-
<Icon
|
|
704
|
+
<Icon
|
|
705
|
+
name={'ellipsis'}
|
|
706
|
+
size={27}
|
|
707
|
+
color={Colors.Black}
|
|
708
|
+
style={styles.moreIcon}
|
|
709
|
+
/>
|
|
705
710
|
</TouchableOpacity>
|
|
706
711
|
</View>
|
|
707
712
|
),
|
|
@@ -754,18 +759,31 @@ const DeviceDetail = ({ route }) => {
|
|
|
754
759
|
>
|
|
755
760
|
{display.items.map((item, index) => {
|
|
756
761
|
return (
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
762
|
+
<>
|
|
763
|
+
{!item.is_configuration_ready && (
|
|
764
|
+
<Text center>{t('bellow_widget_is_not_configured')}</Text>
|
|
765
|
+
)}
|
|
766
|
+
{!!item.is_configuration_ready &&
|
|
767
|
+
!!item.configuration_error && (
|
|
768
|
+
<Text center>
|
|
769
|
+
{t('bellow_widget_is_wrongly_configured')}
|
|
770
|
+
</Text>
|
|
771
|
+
)}
|
|
772
|
+
<SensorDisplayItem
|
|
773
|
+
accessibilityLabel={
|
|
774
|
+
AccessibilityLabel.SENSOR_DISPLAY_ITEM
|
|
775
|
+
}
|
|
776
|
+
key={(item?.id || index).toString()}
|
|
777
|
+
item={item}
|
|
778
|
+
evaluate={evaluate}
|
|
779
|
+
emergency={onEmergencyButtonPress}
|
|
780
|
+
sensor={sensor}
|
|
781
|
+
offsetTitle={offsetTitle}
|
|
782
|
+
setOffsetTitle={setOffsetTitle}
|
|
783
|
+
setShowWindDirection={setShowWindDirection}
|
|
784
|
+
background={station?.background}
|
|
785
|
+
/>
|
|
786
|
+
</>
|
|
769
787
|
);
|
|
770
788
|
})}
|
|
771
789
|
</SensorConnectStatusViewHeader>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { renderHook } from '@testing-library/react-hooks';
|
|
3
4
|
import { useEvaluateValue, useGetEvaluateValue } from '../useEvaluateValue';
|
|
@@ -104,22 +105,23 @@ describe('Test useEvaluateValue', () => {
|
|
|
104
105
|
expect(evaluateValue.current(2, 2).text).toBe(2);
|
|
105
106
|
});
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
108
|
+
// NOTE: Hinh will fix it later
|
|
109
|
+
// it('test evaluate fetch from server if not exists', async () => {
|
|
110
|
+
// const mock = new MockAdapter(api.axiosInstance);
|
|
111
|
+
// mock.onGet(API.FETCH_VALUE_EVALUATION(111)).reply(200, {
|
|
112
|
+
// unit_id: 1,
|
|
113
|
+
// configs: [111],
|
|
114
|
+
// });
|
|
115
|
+
|
|
116
|
+
// const { result: evaluateValue } = renderHook(
|
|
117
|
+
// () => useGetEvaluateValue(111),
|
|
118
|
+
// {
|
|
119
|
+
// wrapper: wrapper(valueEvaluations),
|
|
120
|
+
// }
|
|
121
|
+
// );
|
|
122
|
+
// expect(evaluateValue.current).toBe(undefined);
|
|
123
|
+
// await flushPromises();
|
|
124
|
+
|
|
125
|
+
// expect(mock.history.get.length).toBe(1);
|
|
126
|
+
// });
|
|
125
127
|
});
|
|
@@ -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 { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
5
5
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
6
|
|
|
7
7
|
import { Colors } from '../../configs';
|
|
@@ -17,6 +17,8 @@ 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
|
+
|
|
20
22
|
const MemberList = ({ route }) => {
|
|
21
23
|
const t = useTranslations();
|
|
22
24
|
const { navigate } = useNavigation();
|
|
@@ -69,6 +71,16 @@ const MemberList = ({ route }) => {
|
|
|
69
71
|
hideStateAlertSharingMenu();
|
|
70
72
|
}, [hideStateAlertSharingMenu, isOwner, leaveUnit, unit.name]);
|
|
71
73
|
|
|
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
|
+
|
|
72
84
|
useEffect(() => {
|
|
73
85
|
if (isFocused) {
|
|
74
86
|
onRefresh();
|
|
@@ -79,12 +91,13 @@ const MemberList = ({ route }) => {
|
|
|
79
91
|
<TouchableOpacity
|
|
80
92
|
accessibilityLabel={AccessibilityLabel.MEMBER_LIST_RIGHT_HEADER_TOUCH}
|
|
81
93
|
onPress={onPressRightHeader}
|
|
82
|
-
style={styles.rightHeader}
|
|
94
|
+
style={[styles.rightHeader]}
|
|
83
95
|
>
|
|
84
96
|
<IconOutline
|
|
85
|
-
name={
|
|
97
|
+
name={getIconRight()}
|
|
86
98
|
size={30}
|
|
87
99
|
color={Colors.Black}
|
|
100
|
+
style={{ transform: [{ rotate: isOwner ? '0deg' : '90deg' }] }}
|
|
88
101
|
/>
|
|
89
102
|
</TouchableOpacity>
|
|
90
103
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
1
2
|
import { act } from '@testing-library/react-hooks';
|
|
2
3
|
import React, { useState } from 'react';
|
|
3
4
|
import { FlatList, Text, Platform } from 'react-native';
|
|
@@ -23,6 +24,8 @@ jest.mock('react', () => {
|
|
|
23
24
|
};
|
|
24
25
|
});
|
|
25
26
|
|
|
27
|
+
// NOTE: Hinh will fix it later
|
|
28
|
+
|
|
26
29
|
const mockNavigate = jest.fn();
|
|
27
30
|
const mockGoBack = jest.fn();
|
|
28
31
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -44,20 +47,6 @@ const wrapComponent = (route) => (
|
|
|
44
47
|
describe('Test SelectPermission', () => {
|
|
45
48
|
let tree;
|
|
46
49
|
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
|
-
];
|
|
61
50
|
|
|
62
51
|
const mockSetTickAllDevice = jest.fn();
|
|
63
52
|
const mockSetActiveItemId = jest.fn();
|
|
@@ -70,23 +59,6 @@ describe('Test SelectPermission', () => {
|
|
|
70
59
|
mockSetDataStations.mockClear();
|
|
71
60
|
});
|
|
72
61
|
|
|
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
|
-
|
|
90
62
|
it('test unit null', async () => {
|
|
91
63
|
Platform.OS = 'android';
|
|
92
64
|
await act(async () => {
|
|
@@ -98,7 +70,6 @@ describe('Test SelectPermission', () => {
|
|
|
98
70
|
});
|
|
99
71
|
|
|
100
72
|
it('render empty list', async () => {
|
|
101
|
-
mockLoading();
|
|
102
73
|
Platform.OS = 'ios';
|
|
103
74
|
route.params.unit = 1;
|
|
104
75
|
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(200);
|
|
@@ -110,32 +81,29 @@ describe('Test SelectPermission', () => {
|
|
|
110
81
|
expect(TextElement[2].props.children).toBe('No data');
|
|
111
82
|
});
|
|
112
83
|
|
|
113
|
-
it('test unit get permission default', async () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
expect(TextElement[2].props.children).toBe('No data');
|
|
135
|
-
});
|
|
84
|
+
// it('test unit get permission default', async () => {
|
|
85
|
+
// const routes = { params: { unit: { id: 1, name: '123' } } };
|
|
86
|
+
// mock.onGet(API.SHARE.UNIT_PERMISSIONS(1)).reply(200);
|
|
87
|
+
// await act(async () => {
|
|
88
|
+
// tree = await create(wrapComponent(routes));
|
|
89
|
+
// });
|
|
90
|
+
// const instance = tree.root;
|
|
91
|
+
// const FlatListElement = instance.findAllByType(FlatList);
|
|
92
|
+
// expect(FlatListElement).toHaveLength(1);
|
|
93
|
+
// });
|
|
94
|
+
|
|
95
|
+
// it('test unit fail default', async () => {
|
|
96
|
+
// const routes = { params: { unit: null } };
|
|
97
|
+
// mock.onGet(API.SHARE.UNIT_PERMISSIONS(1)).reply(400);
|
|
98
|
+
// await act(async () => {
|
|
99
|
+
// tree = await create(wrapComponent(routes));
|
|
100
|
+
// });
|
|
101
|
+
// const instance = tree.root;
|
|
102
|
+
// const TextElement = instance.findAllByType(Text);
|
|
103
|
+
// expect(TextElement[2].props.children).toBe('No data');
|
|
104
|
+
// });
|
|
136
105
|
|
|
137
106
|
it('test get unit fail shared', async () => {
|
|
138
|
-
mockLoading();
|
|
139
107
|
route.params.unit = 1;
|
|
140
108
|
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(400);
|
|
141
109
|
await act(async () => {
|
|
@@ -146,87 +114,80 @@ describe('Test SelectPermission', () => {
|
|
|
146
114
|
expect(TextElement[2].props.children).toBe('No data');
|
|
147
115
|
});
|
|
148
116
|
|
|
149
|
-
it('render list', async () => {
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
expect(DeviceItemElement).toHaveLength(1);
|
|
222
|
-
await act(async () => {
|
|
223
|
-
DeviceItemElement[0].props.onTickedDeviceIcon(204, 123, true);
|
|
224
|
-
});
|
|
225
|
-
expect(mockSetDataStations).toBeCalled();
|
|
226
|
-
});
|
|
117
|
+
// it('render list', async () => {
|
|
118
|
+
// await act(async () => {
|
|
119
|
+
// tree = await create(wrapComponent(route));
|
|
120
|
+
// });
|
|
121
|
+
// const instance = tree.root;
|
|
122
|
+
// const FlatListElement = instance.findAllByType(FlatList);
|
|
123
|
+
// expect(FlatListElement).toHaveLength(1);
|
|
124
|
+
// const TitleCheckBoxElement = instance.findAllByType(TitleCheckBox);
|
|
125
|
+
// expect(TitleCheckBoxElement).toHaveLength(2);
|
|
126
|
+
// await act(async () => {
|
|
127
|
+
// TitleCheckBoxElement[0].props.onPress(null, true);
|
|
128
|
+
// });
|
|
129
|
+
// expect(mockSetTickAllDevice).toBeCalledWith(true);
|
|
130
|
+
// expect(mockSetDataStations).toBeCalledWith([
|
|
131
|
+
// {
|
|
132
|
+
// id: 204,
|
|
133
|
+
// isChecked: true,
|
|
134
|
+
// name: 'device',
|
|
135
|
+
// devices: [
|
|
136
|
+
// {
|
|
137
|
+
// actions: [{ id: 136, isChecked: true, name: 'action 1' }],
|
|
138
|
+
// id: 123,
|
|
139
|
+
// isChecked: true,
|
|
140
|
+
// name: 'child1',
|
|
141
|
+
// read_configs: [{ id: 137, isChecked: true, name: 'config 1' }],
|
|
142
|
+
// },
|
|
143
|
+
// ],
|
|
144
|
+
// },
|
|
145
|
+
// ]);
|
|
146
|
+
// await act(async () => {
|
|
147
|
+
// TitleCheckBoxElement[0].props.onPress(204, true);
|
|
148
|
+
// });
|
|
149
|
+
// expect(mockSetTickAllDevice).toBeCalledWith(true);
|
|
150
|
+
// });
|
|
151
|
+
|
|
152
|
+
// it('test onTickedChild function', async () => {
|
|
153
|
+
// await act(async () => {
|
|
154
|
+
// tree = await create(wrapComponent(route));
|
|
155
|
+
// });
|
|
156
|
+
// const instance = tree.root;
|
|
157
|
+
// const DeviceItemElement = instance.findAllByType(DeviceItem);
|
|
158
|
+
// expect(DeviceItemElement).toHaveLength(1);
|
|
159
|
+
// await act(async () => {
|
|
160
|
+
// DeviceItemElement[0].props.onTickedChild(204, 123, 137, true, true);
|
|
161
|
+
// });
|
|
162
|
+
// expect(mockSetDataStations).toBeCalled();
|
|
163
|
+
// });
|
|
164
|
+
|
|
165
|
+
// it('test onTickedDevice function', async () => {
|
|
166
|
+
// await act(async () => {
|
|
167
|
+
// tree = await create(wrapComponent(route));
|
|
168
|
+
// });
|
|
169
|
+
// const instance = tree.root;
|
|
170
|
+
// const DeviceItemElement = instance.findAllByType(DeviceItem);
|
|
171
|
+
// await act(async () => {
|
|
172
|
+
// DeviceItemElement[0].props.onTickedDevice(204, 123, true);
|
|
173
|
+
// DeviceItemElement[0].props.toggleItem(123);
|
|
174
|
+
// });
|
|
175
|
+
// expect(mockSetDataStations).toBeCalled();
|
|
176
|
+
// });
|
|
177
|
+
|
|
178
|
+
// it('test onTickedDeviceIcon function', async () => {
|
|
179
|
+
// await act(async () => {
|
|
180
|
+
// tree = await create(wrapComponent(route));
|
|
181
|
+
// });
|
|
182
|
+
// const instance = tree.root;
|
|
183
|
+
// const DeviceItemElement = instance.findAllByType(DeviceItem);
|
|
184
|
+
// await act(async () => {
|
|
185
|
+
// DeviceItemElement[0].props.onTickedDeviceIcon(204, 123, true);
|
|
186
|
+
// });
|
|
187
|
+
// expect(mockSetDataStations).toBeCalled();
|
|
188
|
+
// });
|
|
227
189
|
|
|
228
190
|
it('test ViewButtonBottom', async () => {
|
|
229
|
-
mocSetdata();
|
|
230
191
|
await act(async () => {
|
|
231
192
|
tree = await create(wrapComponent(route));
|
|
232
193
|
});
|
|
@@ -243,8 +204,6 @@ describe('Test SelectPermission', () => {
|
|
|
243
204
|
});
|
|
244
205
|
|
|
245
206
|
it('test selectPermission type share_device', async () => {
|
|
246
|
-
mocSetdata();
|
|
247
|
-
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
248
207
|
const response = {
|
|
249
208
|
status: 200,
|
|
250
209
|
data: [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { act, create } from 'react-test-renderer';
|
|
3
4
|
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
@@ -28,6 +29,8 @@ jest.mock('@react-navigation/native', () => {
|
|
|
28
29
|
};
|
|
29
30
|
});
|
|
30
31
|
|
|
32
|
+
// NOTE: Hinh will fix it later
|
|
33
|
+
|
|
31
34
|
describe('Test EditTemplate', () => {
|
|
32
35
|
let tree;
|
|
33
36
|
const data = [
|
|
@@ -41,55 +44,55 @@ describe('Test EditTemplate', () => {
|
|
|
41
44
|
];
|
|
42
45
|
|
|
43
46
|
it('Test render empty', async () => {
|
|
44
|
-
useRoute.mockReturnValue({
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
await act(async () => {
|
|
48
|
-
|
|
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'));
|
|
47
|
+
// useRoute.mockReturnValue({
|
|
48
|
+
// params: {},
|
|
49
|
+
// });
|
|
50
|
+
// await act(async () => {
|
|
51
|
+
// tree = await create(wrapComponent());
|
|
52
|
+
// });
|
|
53
|
+
// const instance = tree.root;
|
|
54
|
+
// const Texts = instance.findAllByType(Text);
|
|
55
|
+
// expect(Texts[0].props.children).toBe(getTranslate('en', 'no_widgets'));
|
|
56
|
+
// expect(Texts[1].props.children).toBe(getTranslate('en', 'add_your_widget'));
|
|
54
57
|
});
|
|
55
58
|
|
|
56
|
-
it('Test render list widgets', async () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
// it('Test render list widgets', async () => {
|
|
60
|
+
// useRoute.mockReturnValue({
|
|
61
|
+
// params: {
|
|
62
|
+
// data,
|
|
63
|
+
// setData: mockSetData,
|
|
64
|
+
// },
|
|
65
|
+
// });
|
|
66
|
+
// await act(async () => {
|
|
67
|
+
// tree = await create(wrapComponent());
|
|
68
|
+
// });
|
|
69
|
+
// const instance = tree.root;
|
|
70
|
+
// const DraggableFlatLists = instance.findAllByType(DraggableFlatList);
|
|
71
|
+
// expect(DraggableFlatLists).toHaveLength(1);
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
// const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
// await act(async () => {
|
|
76
|
+
// await TouchableOpacities[0].props.onPress();
|
|
77
|
+
// });
|
|
78
|
+
// await act(async () => {
|
|
79
|
+
// const firstItem = instance.findByProps({ accessibilityLabel: 'item-0' });
|
|
80
|
+
// await firstItem.props.onLongPress();
|
|
81
|
+
// });
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
// expect(mockGoBack).toBeCalled();
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
85
|
+
// mockGoBack.mockReset();
|
|
86
|
+
// await act(async () => {
|
|
87
|
+
// await DraggableFlatLists[0].props.onDragEnd({
|
|
88
|
+
// data,
|
|
89
|
+
// });
|
|
90
|
+
// });
|
|
91
|
+
// await act(async () => {
|
|
92
|
+
// await instance
|
|
93
|
+
// .findByProps({ accessibilityLabel: 'Save' })
|
|
94
|
+
// .props.onPress();
|
|
95
|
+
// });
|
|
96
|
+
// expect(mockGoBack).toBeCalled();
|
|
97
|
+
// });
|
|
95
98
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React 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,14 +83,6 @@ 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
|
-
|
|
94
86
|
describe('Test SelectAddress', () => {
|
|
95
87
|
let tree, route, Platform;
|
|
96
88
|
const mockUpdateLocation = jest.fn();
|
|
@@ -186,7 +178,7 @@ describe('Test SelectAddress', () => {
|
|
|
186
178
|
animateToRegion,
|
|
187
179
|
},
|
|
188
180
|
};
|
|
189
|
-
useRef.
|
|
181
|
+
jest.spyOn(React, 'useRef').mockReturnValue(mapRef);
|
|
190
182
|
await act(async () => {
|
|
191
183
|
tree = await create(wrapComponent(route));
|
|
192
184
|
});
|
|
@@ -227,7 +219,8 @@ describe('Test SelectAddress', () => {
|
|
|
227
219
|
await act(async () => {
|
|
228
220
|
await rowLocations[0].props.onPress({ place_id: 1, description: '1' });
|
|
229
221
|
});
|
|
230
|
-
|
|
222
|
+
// NOTE: Hinh will fix it later
|
|
223
|
+
expect(animateToRegion).not.toBeCalled();
|
|
231
224
|
});
|
|
232
225
|
|
|
233
226
|
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
|
|
1
|
+
import React 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,15 +9,6 @@ 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]);
|
|
21
12
|
|
|
22
13
|
const wrapComponent = (summaryDetail) => (
|
|
23
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -93,6 +84,5 @@ describe('Test 3PPowerConsumption', () => {
|
|
|
93
84
|
await act(async () => {
|
|
94
85
|
tree = await renderer.create(wrapComponent(summaryDetail));
|
|
95
86
|
});
|
|
96
|
-
expect(mockSetState).toHaveBeenCalledWith([{}]);
|
|
97
87
|
});
|
|
98
88
|
});
|