@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.
Files changed (85) hide show
  1. package/android/build.gradle +24 -19
  2. package/package.json +12 -14
  3. package/src/commons/Action/ItemQuickAction.js +0 -1
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +4 -3
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  7. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +5 -4
  8. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
  9. package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -6
  10. package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
  11. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +17 -6
  12. package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -5
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
  14. package/src/commons/ActionGroup/StatesGridActionTemplate.js +20 -6
  15. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
  16. package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
  17. package/src/commons/ActionGroup/TimerActionTemplate.js +2 -3
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
  19. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +14 -37
  20. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +31 -71
  21. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
  22. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +17 -13
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +48 -44
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +22 -56
  25. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +21 -123
  26. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +16 -12
  27. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +38 -73
  28. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +15 -11
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +15 -11
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +31 -21
  32. package/src/commons/ActionGroup/__test__/index.test.js +21 -36
  33. package/src/commons/ActionGroup/index.js +7 -4
  34. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
  35. package/src/commons/Dashboard/MyUnit/index.js +2 -2
  36. package/src/commons/DateTimeRangeChange/index.js +3 -3
  37. package/src/commons/Device/HistoryChart.js +1 -1
  38. package/src/commons/Device/HorizontalBarChart.js +4 -3
  39. package/src/commons/Device/LinearChart.js +5 -3
  40. package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
  41. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
  42. package/src/commons/HeaderAni/index.js +2 -12
  43. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
  44. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +3 -5
  45. package/src/commons/Processing/index.js +0 -1
  46. package/src/commons/Processing/styles.js +0 -3
  47. package/src/commons/SubUnit/OneTap/ItemOneTap.js +0 -1
  48. package/src/commons/Unit/HeaderUnit/index.js +8 -15
  49. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
  50. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
  51. package/src/configs/AccessibilityLabel.js +0 -1
  52. package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
  53. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
  54. package/src/hooks/useMqtt.js +2 -5
  55. package/src/iot/mqtt.js +0 -2
  56. package/src/navigations/UnitStack.js +2 -2
  57. package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
  58. package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
  59. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
  60. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +2 -19
  61. package/src/screens/Automate/AddNewAction/__test__/{SetupConfigCondition.test.js → SetupSensor.test.js} +0 -97
  62. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
  63. package/src/screens/ChangePosition/__test__/index.test.js +32 -34
  64. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
  65. package/src/screens/Device/__test__/detail.test.js +45 -40
  66. package/src/screens/Device/__test__/sensorDisplayItem.test.js +2 -14
  67. package/src/screens/Device/components/ChartWrapper.js +12 -14
  68. package/src/screens/Device/components/SensorDisplayItem.js +2 -18
  69. package/src/screens/Device/components/VisualChart.js +3 -17
  70. package/src/screens/Device/components/__test__/VisualChart.test.js +15 -12
  71. package/src/screens/Device/detail.js +15 -34
  72. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
  73. package/src/screens/Device/styles.js +0 -3
  74. package/src/screens/Sharing/MemberList.js +3 -16
  75. package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
  76. package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
  77. package/src/screens/Unit/SelectAddToFavorites.js +0 -1
  78. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
  79. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
  80. package/src/utils/Apis/axios.js +0 -1
  81. package/src/utils/I18n/translations/en.js +0 -2
  82. package/src/utils/I18n/translations/vi.js +0 -2
  83. package/src/utils/Monitor.js +2 -2
  84. package/src/commons/Highcharts/index.js +0 -111
  85. package/src/commons/icon/index.js +0 -57
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { act, renderHook } from '@testing-library/react-hooks';
3
3
  import { useRemoteControl } from '../index';
4
4
  import {
5
- // BLUETOOOH_DEVICE_UNSTABLE,
5
+ BLUETOOOH_DEVICE_UNSTABLE,
6
6
  sendCommandOverBluetooth,
7
7
  SEND_COMMAND_OVER_BLUETOOTH_FAIL,
8
8
  } from '../../../iot/RemoteControl/Bluetooth';
@@ -35,7 +35,6 @@ describe('Test useRemoteControl', () => {
35
35
  sendCommandOverBluetooth.mockClear();
36
36
  sendCommandOverHomeAssistant.mockClear();
37
37
  sendCommandOverInternet.mockClear();
38
- jest.useFakeTimers();
39
38
 
40
39
  sensor = {
41
40
  id: 1,
@@ -255,58 +254,58 @@ describe('Test useRemoteControl', () => {
255
254
  expect(sendCommandOverBluetooth).not.toBeCalled();
256
255
  });
257
256
 
258
- // it('test send remote command via bluetooth case when bluetooh device unstable', async () => {
259
- // action.command_prefer_over_bluetooth = true;
260
- // action.command_prefer_over_internet = false;
261
- // const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
262
- // wrapper,
263
- // });
257
+ it('test send remote command via bluetooth case when bluetooh device unstable', async () => {
258
+ action.command_prefer_over_bluetooth = true;
259
+ action.command_prefer_over_internet = false;
260
+ const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
261
+ wrapper,
262
+ });
264
263
 
265
- // sendCommandOverBluetooth.mockImplementation(() => {
266
- // return BLUETOOOH_DEVICE_UNSTABLE;
267
- // });
268
- // await act(async () => {
269
- // await sendRemoteCommand.current(sensor, action, data, userId);
270
- // });
271
- // await flushPromises();
272
- // expect(sendCommandOverBluetooth).toBeCalledWith(
273
- // sensor,
274
- // action,
275
- // data,
276
- // userId
277
- // );
278
- // expect(sendCommandOverBluetooth).toBeCalledTimes(6);
279
- // });
264
+ sendCommandOverBluetooth.mockImplementation(() => {
265
+ return BLUETOOOH_DEVICE_UNSTABLE;
266
+ });
267
+ await act(async () => {
268
+ await sendRemoteCommand.current(sensor, action, data, userId);
269
+ });
270
+ await flushPromises();
271
+ expect(sendCommandOverBluetooth).toBeCalledWith(
272
+ sensor,
273
+ action,
274
+ data,
275
+ userId
276
+ );
277
+ expect(sendCommandOverBluetooth).toBeCalledTimes(6);
278
+ });
280
279
 
281
280
  // eslint-disable-next-line max-len
282
- // it('test send remote command via bluetooth case when bluetooh device unstable 5 times will switch send internet', async () => {
283
- // action.command_prefer_over_bluetooth = true;
284
- // action.command_prefer_over_internet = false;
285
- // const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
286
- // wrapper,
287
- // });
281
+ it('test send remote command via bluetooth case when bluetooh device unstable 5 times will switch send internet', async () => {
282
+ action.command_prefer_over_bluetooth = true;
283
+ action.command_prefer_over_internet = false;
284
+ const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
285
+ wrapper,
286
+ });
288
287
 
289
- // sendCommandOverBluetooth.mockImplementation(() => {
290
- // return BLUETOOOH_DEVICE_UNSTABLE;
291
- // });
292
- // sendCommandOverInternet.mockImplementation(async () => true);
293
- // await act(async () => {
294
- // await sendRemoteCommand.current(sensor, action, data, userId);
295
- // });
296
- // await flushPromises();
297
- // expect(sendCommandOverBluetooth).toBeCalledWith(
298
- // sensor,
299
- // action,
300
- // data,
301
- // userId
302
- // );
303
- // expect(sendCommandOverInternet).toBeCalledWith(
304
- // sensor,
305
- // action,
306
- // data,
307
- // 'bluetooth'
308
- // );
309
- // expect(sendCommandOverBluetooth).toBeCalledTimes(6);
310
- // expect(sendCommandOverInternet).toBeCalledTimes(1);
311
- // });
288
+ sendCommandOverBluetooth.mockImplementation(() => {
289
+ return BLUETOOOH_DEVICE_UNSTABLE;
290
+ });
291
+ sendCommandOverInternet.mockImplementation(async () => true);
292
+ await act(async () => {
293
+ await sendRemoteCommand.current(sensor, action, data, userId);
294
+ });
295
+ await flushPromises();
296
+ expect(sendCommandOverBluetooth).toBeCalledWith(
297
+ sensor,
298
+ action,
299
+ data,
300
+ userId
301
+ );
302
+ expect(sendCommandOverInternet).toBeCalledWith(
303
+ sensor,
304
+ action,
305
+ data,
306
+ 'bluetooth'
307
+ );
308
+ expect(sendCommandOverBluetooth).toBeCalledTimes(6);
309
+ expect(sendCommandOverInternet).toBeCalledTimes(1);
310
+ });
312
311
  });
@@ -40,8 +40,7 @@ describe('Test useWatchConfigs', () => {
40
40
  renderHook(() => useWatchConfigs([1]), {
41
41
  wrapper,
42
42
  });
43
- // NOTE: Hinh will fix it later
44
- expect(watchMultiConfigs).not.toBeCalledWith([1]);
45
- expect(unwatchMultiConfigs).not.toBeCalledWith([1]);
43
+ expect(watchMultiConfigs).toBeCalledWith([1]);
44
+ expect(unwatchMultiConfigs).toBeCalledWith([1]);
46
45
  });
47
46
  });
@@ -47,11 +47,8 @@ const connectChipMqtt = (chip) => {
47
47
  client.subscribe(`eoh/chip/${code}/#`);
48
48
  });
49
49
  client.on('message', (topic, payload, packet) => {
50
- try {
51
- const payloadObject = JSON.parse(payload.toString());
52
- handleMqttMessage(topic, payloadObject, code, chip, configById);
53
- // eslint-disable-next-line no-empty
54
- } catch {}
50
+ const payloadObject = JSON.parse(payload.toString());
51
+ handleMqttMessage(topic, payloadObject, code, chip, configById);
55
52
  });
56
53
 
57
54
  return client;
package/src/iot/mqtt.js CHANGED
@@ -24,9 +24,7 @@ const uint_32 = (bytes_str, config_data = null) => {
24
24
  let bits = 32;
25
25
  let value = Number.parseInt(bytes_str, 16);
26
26
 
27
- // eslint-disable-next-line no-bitwise
28
27
  if (value & (1 << (bits - 1))) {
29
- // eslint-disable-next-line no-bitwise
30
28
  value -= 1 << bits;
31
29
  }
32
30
 
@@ -1,5 +1,5 @@
1
1
  import React, { memo, useContext, useEffect } from 'react';
2
- import { AppState, Platform, View } from 'react-native';
2
+ import { AppState, View } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import { createStackNavigator } from '@react-navigation/stack';
5
5
  import { BleManager } from 'react-native-ble-plx';
@@ -172,7 +172,7 @@ export const UnitStack = memo((props) => {
172
172
  headerTitleAlign: 'center',
173
173
  headerBackImage: () => (
174
174
  <IconOutline
175
- name={Platform.OS === 'android' ? 'left-square' : 'left'}
175
+ name="left"
176
176
  size={27}
177
177
  color={Colors.Black}
178
178
  style={styles.icLeft}
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useState, useMemo } from 'react';
2
2
  import { useNavigation } from '@react-navigation/native';
3
3
  import { Alert } from 'react-native';
4
- import { v4 as uuidv4 } from 'uuid';
4
+ import uuid from 'uuid';
5
5
 
6
6
  import Processing from '../../commons/Processing';
7
7
  import Routes from '../../utils/Route';
@@ -43,7 +43,7 @@ const ConnectingDevice = ({
43
43
  );
44
44
 
45
45
  const channelName = useMemo(() => {
46
- return 'cache-' + uuidv4();
46
+ return 'cache-' + uuid.v4();
47
47
  }, []);
48
48
 
49
49
  const onPressContinue = useCallback(() => {
@@ -15,7 +15,7 @@ import {
15
15
  import dgram from 'react-native-udp';
16
16
  import { useNavigation, useIsFocused } from '@react-navigation/native';
17
17
  import LottieView from 'lottie-react-native';
18
- import { v4 as uuidv4 } from 'uuid';
18
+ import uuid from 'uuid';
19
19
 
20
20
  import { ToastBottomHelper } from '../../utils/Utils';
21
21
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -76,7 +76,7 @@ const ShareWifiPassword = ({ route }) => {
76
76
  const [dataGateway, setDataGateway] = useState({ gateway: [], error: '' });
77
77
 
78
78
  const code = useMemo(() => {
79
- return uuidv4();
79
+ return uuid.v4();
80
80
  }, []);
81
81
 
82
82
  const hidePopupPassword = useCallback(() => {
@@ -17,7 +17,7 @@ import api from '../../../../utils/Apis/axios';
17
17
  import { API } from '../../../../configs';
18
18
  import { PERMISSION_TYPE } from '../../../../configs/Constants';
19
19
  import Detail from '../../components/Detail';
20
- // import ModalPopupCT from '../../../../commons/ModalPopupCT';
20
+ import ModalPopupCT from '../../../../commons/ModalPopupCT';
21
21
  import { fetchGatewayCT, flushPromises } from '../../test-utils';
22
22
 
23
23
  const mock = new MockAdapter(api.axiosInstance);
@@ -133,6 +133,8 @@ describe('Test DeviceModbusDetail', () => {
133
133
  const menuActionMore = detail?.findAllByType(MenuActionMore);
134
134
  expect(menuActionMore[0].props.isVisible).toEqual(true);
135
135
 
136
+ await flushPromises();
137
+
136
138
  await act(async () => {
137
139
  await menuActionMore[0].props.listMenuItem[0].doAction();
138
140
  });
@@ -143,39 +145,38 @@ describe('Test DeviceModbusDetail', () => {
143
145
  });
144
146
  });
145
147
 
146
- // NOTE: Hinh will fix it later
147
- // it('test render DeviceModbusDetail onPress more and onPress Delete modbus', async () => {
148
- // await act(async () => {
149
- // tree = await create(wrapComponent());
150
- // });
151
- // await flushPromises();
152
- // const instance = tree.root;
153
- // const detail = instance?.findByType(Detail);
154
- // await headerCustomOnPressMore(detail);
155
- // const menuActionMore = detail?.findByType(MenuActionMore);
156
- // expect(menuActionMore.props.isVisible).toEqual(true);
148
+ it('test render DeviceModbusDetail onPress more and onPress Delete modbus', async () => {
149
+ await act(async () => {
150
+ tree = await create(wrapComponent());
151
+ });
152
+ await flushPromises();
153
+ const instance = tree.root;
154
+ const detail = instance?.findByType(Detail);
155
+ await headerCustomOnPressMore(detail);
156
+ const menuActionMore = detail?.findByType(MenuActionMore);
157
+ expect(menuActionMore.props.isVisible).toEqual(true);
157
158
 
158
- // await act(async () => {
159
- // menuActionMore.props.listMenuItem[1].doAction();
160
- // });
161
- // await flushPromises();
159
+ await act(async () => {
160
+ menuActionMore.props.listMenuItem[1].doAction();
161
+ });
162
+ await flushPromises();
162
163
 
163
- // const modal = instance.findByType(ModalPopupCT);
164
- // mock.onDelete(API.DEV_MODE.ZIGBEE.DEVICE_DETAIL(1, 1)).reply(200);
165
- // await act(async () => {
166
- // await modal.props.onPressConfirm();
167
- // });
168
- // await flushPromises();
164
+ const modal = instance.findByType(ModalPopupCT);
165
+ mock.onDelete(API.DEV_MODE.ZIGBEE.DEVICE_DETAIL(1, 1)).reply(200);
166
+ await act(async () => {
167
+ await modal.props.onPressConfirm();
168
+ });
169
+ await flushPromises();
169
170
 
170
- // expect(mockPop).toBeCalledWith(1);
171
- // expect(Toast.show).toBeCalledWith({
172
- // position: 'bottom',
173
- // text1: 'Delete successfully!',
174
- // text2: undefined,
175
- // type: 'success',
176
- // visibilityTime: 1000,
177
- // });
178
- // });
171
+ expect(mockPop).toBeCalledWith(1);
172
+ expect(Toast.show).toBeCalledWith({
173
+ position: 'bottom',
174
+ text1: 'Delete successfully!',
175
+ text2: undefined,
176
+ type: 'success',
177
+ visibilityTime: 1000,
178
+ });
179
+ });
179
180
 
180
181
  it('test render DeviceZigbeeDetail onPress TabPanel config write', async () => {
181
182
  mock.onGet(API.DEV_MODE.MODBUS.REGISTER(1, 1)).reply(200, [
@@ -47,7 +47,7 @@ const SetupConfigCondition = () => {
47
47
  },
48
48
  ];
49
49
  }
50
- if (item.evaluate_template === 'range') {
50
+ if (item.evaluate_configuration.ranges) {
51
51
  return item.evaluate_configuration.ranges.map((range, index) => ({
52
52
  title: range.evaluate?.text,
53
53
  condition: 'value_evaluation',
@@ -55,24 +55,8 @@ const SetupConfigCondition = () => {
55
55
  value: index,
56
56
  }));
57
57
  }
58
- if (item.evaluate_template === 'boolean') {
59
- return [
60
- {
61
- title: item.evaluate_configuration?.on?.text,
62
- condition: 'value_evaluation',
63
- config: item.id,
64
- value: 0,
65
- },
66
- {
67
- title: item.evaluate_configuration?.off?.text,
68
- condition: 'value_evaluation',
69
- config: item.id,
70
- value: 1,
71
- },
72
- ];
73
- }
74
58
  return [];
75
- }, [item.evaluate_configuration, item.evaluate_template, item.id, t]);
59
+ }, [item.evaluate_configuration, item.id, t]);
76
60
 
77
61
  const onOpenModal = useCallback(() => {
78
62
  setIsShowModal(true);
@@ -147,7 +131,6 @@ const SetupConfigCondition = () => {
147
131
  <TouchableOpacity
148
132
  onPress={onOpenModal}
149
133
  style={[styles.itemCondition, styles.shadowView]}
150
- accessibilityLabel="open-modal"
151
134
  >
152
135
  <Text type="Body" color={Colors.Gray7}>
153
136
  {t('condition')}
@@ -8,8 +8,6 @@ import SetupConfigCondition from '../SetupConfigCondition';
8
8
  import { useNavigation, useRoute } from '@react-navigation/native';
9
9
  import _TextInput from '../../../../commons/Form/TextInput';
10
10
  import { ToastBottomHelper } from '../../../../utils/Utils';
11
- import { ModalCustom } from '../../../../commons/Modal';
12
- import { Text } from '../../../../commons';
13
11
 
14
12
  jest.mock('react', () => {
15
13
  return {
@@ -31,7 +29,6 @@ describe('Test SetupConfigCondition', () => {
31
29
 
32
30
  let tree;
33
31
  beforeEach(() => {
34
- tree = null;
35
32
  mockGoBack.mockReset();
36
33
  useRoute.mockClear();
37
34
  spyToastError.mockClear();
@@ -83,99 +80,6 @@ describe('Test SetupConfigCondition', () => {
83
80
  expect(mockGoBack).toBeCalled();
84
81
  });
85
82
 
86
- it('render range value evaluation', async () => {
87
- useRoute.mockReturnValue({
88
- params: {
89
- item: {
90
- id: 1,
91
- decimal_behind: 0,
92
- title: 'is below (<)',
93
- sensor_type: 'air_quality',
94
- evaluate_configuration: {
95
- ranges: [
96
- {
97
- evaluate: {
98
- text: 'Case 1',
99
- },
100
- },
101
- {
102
- evaluate: {
103
- text: 'Case 2',
104
- },
105
- },
106
- {
107
- evaluate: {
108
- text: 'Case 3',
109
- },
110
- },
111
- ],
112
- },
113
- evaluate_template: 'range',
114
- },
115
- sensorData: [],
116
- },
117
- });
118
- await act(async () => {
119
- tree = await create(wrapComponent());
120
- });
121
- const instance = tree.root;
122
-
123
- await act(async () => {
124
- instance
125
- .findByProps({ accessibilityLabel: 'open-modal' })
126
- .props.onPress();
127
- });
128
-
129
- const modalCustom = instance.find(
130
- (el) => el.type === ModalCustom && el.props.isVisible
131
- );
132
- const texts = modalCustom.findAllByType(Text);
133
- expect(texts).toHaveLength(3);
134
- expect(texts[0].props.children).toEqual('Case 1');
135
- expect(texts[1].props.children).toEqual('Case 2');
136
- expect(texts[2].props.children).toEqual('Case 3');
137
- });
138
-
139
- it('render boolean value evaluation', async () => {
140
- useRoute.mockReturnValue({
141
- params: {
142
- item: {
143
- id: 1,
144
- title: 'is below (<)',
145
- sensor_type: 'air_quality',
146
- evaluate_configuration: {
147
- on: {
148
- text: 'Case On',
149
- },
150
- off: {
151
- text: 'Case Off',
152
- },
153
- },
154
- evaluate_template: 'boolean',
155
- },
156
- sensorData: [],
157
- },
158
- });
159
- await act(async () => {
160
- tree = await create(wrapComponent());
161
- });
162
- const instance = tree.root;
163
-
164
- await act(async () => {
165
- instance
166
- .findByProps({ accessibilityLabel: 'open-modal' })
167
- .props.onPress();
168
- });
169
-
170
- const modalCustom = instance.find(
171
- (el) => el.type === ModalCustom && el.props.isVisible
172
- );
173
- const texts = modalCustom.findAllByType(Text);
174
- expect(texts).toHaveLength(2);
175
- expect(texts[0].props.children).toEqual('Case On');
176
- expect(texts[1].props.children).toEqual('Case Off');
177
- });
178
-
179
83
  const testConditionValue = async (value, message) => {
180
84
  useRoute.mockReturnValue({
181
85
  params: {
@@ -213,7 +117,6 @@ describe('Test SetupConfigCondition', () => {
213
117
  it('Test render when have input not number', async () => {
214
118
  await testConditionValue('abc', 'Please enter a number');
215
119
  });
216
-
217
120
  it('Test render when have input value must be 6 digits or less', async () => {
218
121
  await testConditionValue(
219
122
  '123456789',
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  import React from 'react';
3
2
  import DraggableFlatList from 'react-native-draggable-flatlist';
4
3
  import { create, act } from 'react-test-renderer';
@@ -38,78 +37,78 @@ describe('EditActionsList', () => {
38
37
  mockedNavigate.mockClear();
39
38
  });
40
39
  it('render EditActionsList', async () => {
41
- // await act(async () => {
42
- // tree = await create(wrapComponent());
43
- // });
44
- // const instance = tree.root;
45
- // const draggableFlatList = instance.findAllByType(DraggableFlatList);
46
- // const modalBottom = instance.findAllByType(ModalBottom);
47
- // expect(draggableFlatList).toHaveLength(1);
48
- // expect(modalBottom).toHaveLength(1);
40
+ await act(async () => {
41
+ tree = await create(wrapComponent());
42
+ });
43
+ const instance = tree.root;
44
+ const draggableFlatList = instance.findAllByType(DraggableFlatList);
45
+ const modalBottom = instance.findAllByType(ModalBottom);
46
+ expect(draggableFlatList).toHaveLength(1);
47
+ expect(modalBottom).toHaveLength(1);
48
+ });
49
+ it('EditActionsList onPress cancel', async () => {
50
+ await act(async () => {
51
+ tree = await create(wrapComponent());
52
+ });
53
+ const instance = tree.root;
54
+ const buttonCancel = instance.find(
55
+ (el) =>
56
+ el.props.accessibilityLabel ===
57
+ AccessibilityLabel.BUTTON_CANCEL_EDIT_ACTION_LIST &&
58
+ el.type === TouchableOpacity
59
+ );
60
+ expect(buttonCancel).toBeDefined();
61
+ await act(async () => {
62
+ buttonCancel.props.onPress();
63
+ });
64
+ expect(mockedNavigate).toHaveBeenCalled();
49
65
  });
50
- // it('EditActionsList onPress cancel', async () => {
51
- // await act(async () => {
52
- // tree = await create(wrapComponent());
53
- // });
54
- // const instance = tree.root;
55
- // const buttonCancel = instance.find(
56
- // (el) =>
57
- // el.props.accessibilityLabel ===
58
- // AccessibilityLabel.BUTTON_CANCEL_EDIT_ACTION_LIST &&
59
- // el.type === TouchableOpacity
60
- // );
61
- // expect(buttonCancel).toBeDefined();
62
- // await act(async () => {
63
- // buttonCancel.props.onPress();
64
- // });
65
- // expect(mockedNavigate).toHaveBeenCalled();
66
- // });
67
- // it('EditActionsList onPress save', async () => {
68
- // mock.onPut(API.AUTOMATE.ORDER_SCRIPT_ACTION(1)).reply(200);
69
- // await act(async () => {
70
- // tree = await create(wrapComponent());
71
- // });
72
- // const instance = tree.root;
73
- // const buttonSave = instance.find(
74
- // (el) =>
75
- // el.props.accessibilityLabel ===
76
- // AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST &&
77
- // el.type === TouchableOpacity
78
- // );
79
- // expect(buttonSave).toBeDefined();
66
+ it('EditActionsList onPress save', async () => {
67
+ mock.onPut(API.AUTOMATE.ORDER_SCRIPT_ACTION(1)).reply(200);
68
+ await act(async () => {
69
+ tree = await create(wrapComponent());
70
+ });
71
+ const instance = tree.root;
72
+ const buttonSave = instance.find(
73
+ (el) =>
74
+ el.props.accessibilityLabel ===
75
+ AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST &&
76
+ el.type === TouchableOpacity
77
+ );
78
+ expect(buttonSave).toBeDefined();
80
79
 
81
- // await act(async () => {
82
- // buttonSave.props.onPress();
83
- // });
80
+ await act(async () => {
81
+ buttonSave.props.onPress();
82
+ });
84
83
 
85
- // expect(mock.history.put).toHaveLength(1);
86
- // });
84
+ expect(mock.history.put).toHaveLength(1);
85
+ });
87
86
 
88
- // it('EditActionsList has remove button', async () => {
89
- // await act(async () => {
90
- // tree = await create(wrapComponent());
91
- // });
92
- // const instance = tree.root;
93
- // const buttonRemove = instance.find(
94
- // (el) =>
95
- // el.props.accessibilityLabel ===
96
- // AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST &&
97
- // el.type === TouchableOpacity
98
- // );
99
- // expect(buttonRemove).toBeDefined();
100
- // });
87
+ it('EditActionsList has remove button', async () => {
88
+ await act(async () => {
89
+ tree = await create(wrapComponent());
90
+ });
91
+ const instance = tree.root;
92
+ const buttonRemove = instance.find(
93
+ (el) =>
94
+ el.props.accessibilityLabel ===
95
+ AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST &&
96
+ el.type === TouchableOpacity
97
+ );
98
+ expect(buttonRemove).toBeDefined();
99
+ });
101
100
 
102
- // it('EditActionsList modal onPress remove', async () => {
103
- // await act(async () => {
104
- // tree = await create(wrapComponent());
105
- // });
106
- // const instance = tree.root;
107
- // const modalBottom = instance.findAllByType(ModalBottom);
108
- // await act(async () => {
109
- // modalBottom[0].props.onRemove();
110
- // });
101
+ it('EditActionsList modal onPress remove', async () => {
102
+ await act(async () => {
103
+ tree = await create(wrapComponent());
104
+ });
105
+ const instance = tree.root;
106
+ const modalBottom = instance.findAllByType(ModalBottom);
107
+ await act(async () => {
108
+ modalBottom[0].props.onRemove();
109
+ });
111
110
 
112
- // mock.onDelete(API.AUTOMATE.DELETE_SCRIPT_ACTION(1, 1)).reply(200);
113
- // expect(mock.history.delete).toHaveLength(1);
114
- // });
111
+ mock.onDelete(API.AUTOMATE.DELETE_SCRIPT_ACTION(1, 1)).reply(200);
112
+ expect(mock.history.delete).toHaveLength(1);
113
+ });
115
114
  });