@eohjsc/react-native-smart-city 0.7.3-rc1 → 0.7.3-rc11

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 (139) hide show
  1. package/package.json +17 -15
  2. package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -6
  3. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +5 -5
  4. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +2 -2
  5. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +2 -2
  6. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +9 -10
  7. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +5 -5
  8. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +5 -5
  9. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +8 -8
  10. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +3 -3
  11. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
  12. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -1
  13. package/src/commons/ActionGroup/__test__/index.test.js +6 -6
  14. package/src/commons/ActionTemplate/__test__/index.test.js +4 -4
  15. package/src/commons/Automate/__test__/ItemAutomate.test.js +2 -2
  16. package/src/commons/ChartAggregationOption/__test__/FourButtonFilterHistory.test.js +2 -2
  17. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +8 -9
  18. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +7 -7
  19. package/src/commons/DateTimeRangeChange/DateTimeButton.js +1 -1
  20. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +1 -1
  21. package/src/commons/Device/FlatListItems.js +17 -16
  22. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -3
  23. package/src/commons/Device/HorizontalBarChart.js +54 -34
  24. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -3
  25. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +6 -6
  26. package/src/commons/FlatListDnD/__test__/index.test.js +4 -4
  27. package/src/commons/FlatListDnD/index.js +12 -9
  28. package/src/commons/Grid/GridItem.js +10 -2
  29. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +3 -3
  30. package/src/commons/Header/__test__/HeaderCT.test.js +3 -3
  31. package/src/commons/IconComponent/index.js +3 -3
  32. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +5 -5
  33. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +6 -4
  34. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +1 -1
  35. package/src/commons/Popover/__test__/index.test.js +3 -3
  36. package/src/commons/Processing/__test__/Connecting.test.js +4 -4
  37. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +5 -5
  38. package/src/commons/SubUnit/OneTap/index.js +9 -8
  39. package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -8
  40. package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +9 -13
  41. package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +5 -5
  42. package/src/hooks/IoT/__test__/useHomeAssistantConnection.test.js +12 -12
  43. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -3
  44. package/src/hooks/IoT/useRemoteControl.js +6 -6
  45. package/src/hooks/useMqtt.js +2 -2
  46. package/src/iot/RemoteControl/Internet.js +2 -2
  47. package/src/iot/RemoteControl/__test__/Internet.test.js +7 -7
  48. package/src/screens/AddLocationMaps/__test__/index.test.js +12 -12
  49. package/src/screens/AddNewGateway/ShareWifiPassword.js +16 -15
  50. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -7
  51. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +8 -8
  52. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +7 -7
  53. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +8 -8
  54. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +5 -5
  55. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +4 -4
  56. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -6
  57. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -6
  58. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +0 -4
  59. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +2 -2
  60. package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +6 -6
  61. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +19 -17
  62. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +19 -17
  63. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +18 -16
  64. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +43 -35
  65. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +13 -13
  66. package/src/screens/AllGateway/__test__/index.test.js +6 -6
  67. package/src/screens/AllGateway/components/Detail/__test__/index.test.js +3 -5
  68. package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +3 -3
  69. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +6 -6
  70. package/src/screens/AllGateway/hooks/__test__/index.test.js +2 -2
  71. package/src/screens/AllGateway/test-utils.js +3 -4
  72. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +7 -7
  73. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +3 -3
  74. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +35 -32
  75. package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
  76. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +12 -12
  77. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
  78. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
  79. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +12 -11
  80. package/src/screens/Automate/AddNewAction/__test__/SetupScriptDelay.test.js +9 -9
  81. package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +10 -10
  82. package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +4 -3
  83. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +13 -8
  84. package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +8 -8
  85. package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +6 -6
  86. package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +7 -7
  87. package/src/screens/Automate/EditActionsList/index.js +19 -17
  88. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +16 -7
  89. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +15 -7
  90. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
  91. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +1 -1
  92. package/src/screens/Automate/ScriptDetail/__test__/useStarredScript.test.js +6 -6
  93. package/src/screens/Automate/ScriptDetail/index.js +18 -18
  94. package/src/screens/Automate/SetSchedule/__test__/SelectWeekday.test.js +4 -4
  95. package/src/screens/Automate/SetSchedule/__test__/index.test.js +28 -18
  96. package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
  97. package/src/screens/Automate/SetSchedule/index.js +7 -7
  98. package/src/screens/ChangePosition/__test__/index.test.js +6 -6
  99. package/src/screens/ChangePosition/index.js +2 -1
  100. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +9 -9
  101. package/src/screens/Device/__test__/detail.test.js +12 -12
  102. package/src/screens/Device/__test__/mqttDetail.test.js +9 -9
  103. package/src/screens/Device/components/SensorDisplayItem.js +5 -5
  104. package/src/screens/Drawer/Drawer.test.js +2 -2
  105. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -7
  106. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +8 -8
  107. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +3 -3
  108. package/src/screens/HanetCamera/__test__/Detail.test.js +9 -9
  109. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -10
  110. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +9 -9
  111. package/src/screens/Notification/__test__/Notification.test.js +9 -9
  112. package/src/screens/Notification/components/NotificationItem.js +2 -3
  113. package/src/screens/Notification/styles/NotificationItemStyles.js +0 -1
  114. package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
  115. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
  116. package/src/screens/SelectUnit/__test__/index.test.js +7 -7
  117. package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +7 -7
  118. package/src/screens/SideMenuDetail/__test__/index.test.js +8 -8
  119. package/src/screens/SmartAccount/Connecting/index.js +5 -5
  120. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +8 -8
  121. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +7 -7
  122. package/src/screens/SmartAccount/__test__/Connecting.test.js +6 -6
  123. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +10 -10
  124. package/src/screens/SubUnit/AddSubUnit.js +2 -4
  125. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +9 -11
  126. package/src/screens/Template/EditTemplate.js +6 -4
  127. package/src/screens/Template/__test__/EditTemplate.test.js +7 -7
  128. package/src/screens/Template/__test__/detail.test.js +4 -4
  129. package/src/screens/Template/__test__/index.test.js +1 -1
  130. package/src/screens/Unit/Station/__test__/index.test.js +1 -1
  131. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +9 -9
  132. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -17
  133. package/src/screens/Unit/__test__/Summaries.test.js +7 -7
  134. package/src/screens/Unit/components/__test__/AutomateScript.test.js +3 -3
  135. package/src/screens/Unit/components/__test__/SharedUnit.test.js +8 -8
  136. package/src/screens/Unit/hook/__test__/useUnitConnectRemoteDevices.test.js +2 -2
  137. package/src/utils/I18n/translations/en.js +1 -1
  138. package/src/utils/I18n/translations/vi.js +1 -1
  139. package/src/utils/__test__/Utils.test.js +16 -16
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
1
  import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
3
3
  import { Platform, TextInput, TouchableOpacity } from 'react-native';
4
4
  import { act, create } from 'react-test-renderer';
5
5
 
6
- import AddNewOneTap from '../index';
6
+ import { useNavigation, useRoute } from '@react-navigation/native';
7
+ import { API } from '../../../../configs';
7
8
  import { AccessibilityLabel } from '../../../../configs/Constants';
8
9
  import { SCProvider } from '../../../../context';
9
10
  import { mockSCStore } from '../../../../context/mockStore';
10
- import Routes from '../../../../utils/Route';
11
11
  import api from '../../../../utils/Apis/axios';
12
- import { API } from '../../../../configs';
13
- import { useNavigation, useRoute } from '@react-navigation/native';
12
+ import Routes from '../../../../utils/Route';
13
+ import AddNewOneTap from '../index';
14
14
 
15
15
  const wrapComponent = (route) => {
16
16
  useRoute.mockReturnValue(route);
@@ -114,7 +114,7 @@ describe('test OneTap', () => {
114
114
  await act(async () => {
115
115
  await item[0].props.onPress();
116
116
  });
117
- expect(global.mockedNavigate).not.toBeCalled();
117
+ expect(global.mockedNavigate).not.toHaveBeenCalled();
118
118
  });
119
119
 
120
120
  it('test onClose have automateId', async () => {
@@ -122,8 +122,13 @@ describe('test OneTap', () => {
122
122
  let route = {
123
123
  params: {
124
124
  closeScreen: Routes.ScriptDetail,
125
+ automate: {
126
+ unit: 1,
127
+ },
128
+ unitId: 1,
125
129
  },
126
130
  };
131
+
127
132
  mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(400);
128
133
  await act(async () => {
129
134
  tree = await create(wrapComponent(route));
@@ -136,6 +141,10 @@ describe('test OneTap', () => {
136
141
  await act(async () => {
137
142
  header.props.onPress();
138
143
  });
139
- expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail);
144
+ expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
145
+ unitId: 1,
146
+ automate: { unit: 1 },
147
+ closeScreen: Routes.ScriptDetail,
148
+ });
140
149
  });
141
150
  });
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
1
  import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
3
3
  import { Platform, TextInput, TouchableOpacity } from 'react-native';
4
4
  import { act, create } from 'react-test-renderer';
5
5
 
6
- import ScenarioName from '../ScenarioName';
6
+ import { useNavigation, useRoute } from '@react-navigation/native';
7
+ import { API } from '../../../../configs';
7
8
  import { AccessibilityLabel } from '../../../../configs/Constants';
8
9
  import { SCProvider } from '../../../../context';
9
10
  import { mockSCStore } from '../../../../context/mockStore';
10
- import Routes from '../../../../utils/Route';
11
11
  import api from '../../../../utils/Apis/axios';
12
- import { API } from '../../../../configs';
13
- import { useNavigation, useRoute } from '@react-navigation/native';
12
+ import Routes from '../../../../utils/Route';
13
+ import ScenarioName from '../ScenarioName';
14
14
 
15
15
  const wrapComponent = (route) => {
16
16
  useRoute.mockReturnValue(route);
@@ -103,7 +103,7 @@ describe('test OneTap', () => {
103
103
  await act(async () => {
104
104
  await item[0].props.onPress();
105
105
  });
106
- expect(global.mockedNavigate).not.toBeCalled();
106
+ expect(global.mockedNavigate).not.toHaveBeenCalled();
107
107
  });
108
108
 
109
109
  it('test onClose have automateId', async () => {
@@ -111,6 +111,10 @@ describe('test OneTap', () => {
111
111
  let route = {
112
112
  params: {
113
113
  closeScreen: Routes.ScriptDetail,
114
+ automate: {
115
+ unit: 1,
116
+ },
117
+ unitId: 1,
114
118
  },
115
119
  };
116
120
  mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(400);
@@ -125,6 +129,10 @@ describe('test OneTap', () => {
125
129
  await act(async () => {
126
130
  header.props.onPress();
127
131
  });
128
- expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail);
132
+ expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
133
+ unitId: 1,
134
+ automate: { unit: 1 },
135
+ closeScreen: 'ScriptDetail',
136
+ });
129
137
  });
130
138
  });
@@ -14,14 +14,11 @@ const RenameScript = ({ automate, setAutomate, isVisible, setIsVisible }) => {
14
14
  const transY = useKeyboardAnimated();
15
15
 
16
16
  const renameScript = useCallback(async () => {
17
- const { success, data: script } = await axiosPatch(
18
- API.AUTOMATE.SCRIPT(automate.id),
19
- {
20
- name: inputName,
21
- }
22
- );
17
+ const { success } = await axiosPatch(API.AUTOMATE.SCRIPT(automate.id), {
18
+ name: inputName,
19
+ });
23
20
  if (success) {
24
- setAutomate((prev) => ({ ...prev, name: script.name }));
21
+ setAutomate((prev) => ({ ...prev, name: inputName }));
25
22
  ToastBottomHelper.success(t('rename_successfully'));
26
23
  } else {
27
24
  ToastBottomHelper.error(t('rename_failed'));
@@ -344,7 +344,7 @@ describe('Test ScriptDetail', () => {
344
344
  const instance = tree.root;
345
345
  const switchButton = instance.findByType(Switch);
346
346
  await act(async () => {
347
- await switchButton.props.onChange(false);
347
+ await switchButton.props.onValueChange(false);
348
348
  });
349
349
  const buttonAddScript = instance.findAll(
350
350
  (el) =>
@@ -1,12 +1,12 @@
1
- import React from 'react';
2
1
  import { act, renderHook } from '@testing-library/react-hooks';
3
- import { SCProvider } from '../../../../context';
4
- import { mockSCStore } from '../../../../context/mockStore';
5
- import { useStarredScript } from '../hooks/useStarredScript';
6
2
  import MockAdapter from 'axios-mock-adapter';
7
- import api from '../../../../utils/Apis/axios';
3
+ import React from 'react';
8
4
  import { API } from '../../../../configs';
5
+ import { SCProvider } from '../../../../context';
9
6
  import { Action } from '../../../../context/actionType';
7
+ import { mockSCStore } from '../../../../context/mockStore';
8
+ import api from '../../../../utils/Apis/axios';
9
+ import { useStarredScript } from '../hooks/useStarredScript';
10
10
 
11
11
  const mockedSetAction = jest.fn();
12
12
  const mock = new MockAdapter(api.axiosInstance);
@@ -42,6 +42,6 @@ describe('Test useStarredScript', () => {
42
42
  await act(async () => {
43
43
  await result.current.unstarScript();
44
44
  });
45
- expect(mockedSetAction).toBeCalledWith(Action.UNSTAR_SCRIPTS, [2]);
45
+ expect(mockedSetAction).toHaveBeenCalledWith(Action.UNSTAR_SCRIPTS, [2]);
46
46
  });
47
47
  });
@@ -5,35 +5,35 @@ import React, {
5
5
  useRef,
6
6
  useState,
7
7
  } from 'react';
8
- import { Image, Platform, TouchableOpacity, View, Switch } from 'react-native';
8
+ import { Image, Platform, Switch, TouchableOpacity, View } from 'react-native';
9
9
  import { PopoverMode } from 'react-native-popover-view';
10
10
  import AntDesign from 'react-native-vector-icons/AntDesign';
11
11
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
12
12
 
13
- import { useTranslations } from '../../../hooks/Common/useTranslations';
14
- import styles from './Styles/indexStyles';
15
- import Text from '../../../commons/Text';
16
- import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
17
- import { API, Colors } from '../../../configs';
18
- import { usePopover } from '../../../hooks/Common';
19
- import { useStarredScript } from './hooks/useStarredScript';
20
- import MenuActionMore from '../../../commons/MenuActionMore';
13
+ import { useIsFocused, useNavigation } from '@react-navigation/native';
21
14
  import Add from '../../../../assets/images/Add.svg';
22
- import Notify from '../../../../assets/images/Notify.svg';
23
15
  import Delay from '../../../../assets/images/Delay.svg';
24
- import { useIsFocused, useNavigation } from '@react-navigation/native';
25
- import { axiosGet, axiosPost } from '../../../utils/Apis/axios';
26
- import Routes from '../../../utils/Route';
27
- import { ToastBottomHelper } from '../../../utils/Utils';
16
+ import Notify from '../../../../assets/images/Notify.svg';
28
17
  import ItemAutomate from '../../../commons/Automate/ItemAutomate';
18
+ import IconComponent from '../../../commons/IconComponent';
19
+ import MenuActionMore from '../../../commons/MenuActionMore';
20
+ import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
21
+ import Text from '../../../commons/Text';
29
22
  import withPreventDoubleClick from '../../../commons/WithPreventDoubleClick';
23
+ import { API, Colors } from '../../../configs';
30
24
  import { AccessibilityLabel, AUTOMATE_TYPE } from '../../../configs/Constants';
31
- import RenameScript from './Components/RenameScript';
32
- import DeleteScript from './Components/DeleteScript';
33
25
  import Images from '../../../configs/Images';
26
+ import { usePopover } from '../../../hooks/Common';
27
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
28
+ import { axiosGet, axiosPost } from '../../../utils/Apis/axios';
34
29
  import { useBackendPermission } from '../../../utils/Permission/backend';
35
- import IconComponent from '../../../commons/IconComponent';
30
+ import Routes from '../../../utils/Route';
31
+ import { ToastBottomHelper } from '../../../utils/Utils';
36
32
  import AddActionScript from './Components/AddActionScript';
33
+ import DeleteScript from './Components/DeleteScript';
34
+ import RenameScript from './Components/RenameScript';
35
+ import { useStarredScript } from './hooks/useStarredScript';
36
+ import styles from './Styles/indexStyles';
37
37
 
38
38
  const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
39
39
 
@@ -228,7 +228,7 @@ const ScriptDetail = ({ route }) => {
228
228
  <Text type="H3" semibold>
229
229
  {t('enable_this_script')}
230
230
  </Text>
231
- <Switch checked={enableScript} onChange={onChangeSwitch} />
231
+ <Switch value={enableScript} onValueChange={onChangeSwitch} />
232
232
  </View>
233
233
  )}
234
234
  <Text type="H3" semibold>
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { create, act } from 'react-test-renderer';
2
+ import { TouchableOpacity } from 'react-native';
3
+ import { act, create } from 'react-test-renderer';
3
4
  import { SCProvider } from '../../../../context';
4
5
  import { mockSCStore } from '../../../../context/mockStore';
5
- import { TouchableOpacity } from 'react-native';
6
6
  import SelectWeekday from '../components/SelectWeekday';
7
7
 
8
8
  const wrapComponent = (props) => (
@@ -28,7 +28,7 @@ it('test select', async () => {
28
28
  await act(async () => {
29
29
  await items[0].props.onPress();
30
30
  });
31
- expect(mockSetWeekday).toBeCalledWith(['1']);
31
+ expect(mockSetWeekday).toHaveBeenCalledWith(['1']);
32
32
 
33
33
  mockSetWeekday.mockClear();
34
34
  props = {
@@ -44,5 +44,5 @@ it('test select', async () => {
44
44
  await act(async () => {
45
45
  await items[0].props.onPress();
46
46
  });
47
- expect(mockSetWeekday).toBeCalledWith(['0', '1']);
47
+ expect(mockSetWeekday).toHaveBeenCalledWith(['0', '1']);
48
48
  });
@@ -1,34 +1,37 @@
1
+ import { useNavigation, useRoute } from '@react-navigation/native';
2
+ import moment from 'moment';
1
3
  import React from 'react';
2
4
  import { act, create } from 'react-test-renderer';
5
+ import BottomButtonView from '../../../../commons/BottomButtonView';
6
+ import Calendar from '../../../../commons/Calendar';
7
+ import WheelDateTimePicker from '../../../../commons/WheelDateTimePicker';
8
+ import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
3
9
  import { SCProvider } from '../../../../context';
4
10
  import { mockSCStore } from '../../../../context/mockStore';
5
- import SetSchedule from '../index';
6
- import RowItem from '../components/RowItem';
7
- import WheelDateTimePicker from '../../../../commons/WheelDateTimePicker';
11
+ import Routes from '../../../../utils/Route';
8
12
  import RepeatOptionsPopup, {
9
13
  REPEAT_OPTIONS,
10
14
  } from '../components/RepeatOptionsPopup';
11
- import Calendar from '../../../../commons/Calendar';
12
- import BottomButtonView from '../../../../commons/BottomButtonView';
13
- import Routes from '../../../../utils/Route';
15
+ import RowItem from '../components/RowItem';
14
16
  import SelectWeekday from '../components/SelectWeekday';
15
- import moment from 'moment';
16
- import { useNavigation } from '@react-navigation/native';
17
- import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
17
+ import SetSchedule from '../index';
18
18
 
19
- const wrapComponent = (route) => (
20
- <SCProvider initState={mockSCStore({})}>
21
- <SetSchedule route={route} />
22
- </SCProvider>
23
- );
19
+ const wrapComponent = (route) => {
20
+ useRoute.mockReturnValue(route);
21
+ return (
22
+ <SCProvider initState={mockSCStore({})}>
23
+ <SetSchedule route={route} />
24
+ </SCProvider>
25
+ );
26
+ };
24
27
 
25
28
  describe('Test SetSchedule', () => {
26
29
  let tree;
27
30
  let route = {
28
31
  params: {
29
- type: 'schedule',
30
- unit: { id: 1 },
31
- isAutomateTab: true,
32
+ automate: { type: 'schedule', unit: 1 },
33
+ unitId: 1,
34
+ closeScreen: 'UnitDetail',
32
35
  },
33
36
  };
34
37
 
@@ -70,7 +73,11 @@ describe('Test SetSchedule', () => {
70
73
  await act(async () => {
71
74
  await header.props.onPress();
72
75
  });
73
- expect(global.mockedNavigate).toBeCalledWith(undefined);
76
+ expect(global.mockedNavigate).toHaveBeenCalledWith('UnitDetail', {
77
+ automate: { type: 'schedule', unit: 1 },
78
+ closeScreen: 'UnitDetail',
79
+ unitId: 1,
80
+ });
74
81
  });
75
82
 
76
83
  it('test repeat options popup', async () => {
@@ -137,7 +144,10 @@ describe('Test SetSchedule', () => {
137
144
  repeat: 'once',
138
145
  time_repeat: '12:00:00',
139
146
  weekday_repeat: [],
147
+ type: 'schedule',
148
+ unit: 1,
140
149
  },
150
+ closeScreen: 'UnitDetail',
141
151
  });
142
152
  });
143
153
  });
@@ -1,9 +1,9 @@
1
+ import { IconOutline } from '@ant-design/icons-react-native';
1
2
  import React from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
3
- import AntDesign from 'react-native-vector-icons/AntDesign';
3
+ import { TouchableOpacity, View } from 'react-native';
4
4
  import Text from '../../../../commons/Text';
5
- import styles from '../styles/RowItemStyles';
6
5
  import { Colors } from '../../../../configs';
6
+ import styles from '../styles/RowItemStyles';
7
7
 
8
8
  const RowItem = ({ title, value, icon = null, arrow = false, onPress }) => {
9
9
  return (
@@ -17,8 +17,8 @@ const RowItem = ({ title, value, icon = null, arrow = false, onPress }) => {
17
17
  </Text>
18
18
  </View>
19
19
  <View style={[styles.itemRight, arrow && styles.center]}>
20
- {arrow && <AntDesign name="right" color={Colors.Gray7} />}
21
- {icon && <AntDesign name={icon} size={17} color={Colors.Black} />}
20
+ {arrow && <IconOutline name="right" color={Colors.Gray7} />}
21
+ {icon && <IconOutline name={icon} size={17} color={Colors.Black} />}
22
22
  </View>
23
23
  </TouchableOpacity>
24
24
  );
@@ -1,19 +1,19 @@
1
- import React, { memo, useCallback, useState } from 'react';
2
- import { ScrollView } from 'react-native';
3
1
  import { useNavigation } from '@react-navigation/native';
4
2
  import moment from 'moment';
5
- import WheelDateTimePicker from '../../../commons/WheelDateTimePicker';
3
+ import React, { memo, useCallback, useState } from 'react';
4
+ import { ScrollView } from 'react-native';
6
5
  import Calendar from '../../../commons/Calendar';
6
+ import WheelDateTimePicker from '../../../commons/WheelDateTimePicker';
7
+ import { useBoolean } from '../../../hooks/Common';
8
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
9
+ import Routes from '../../../utils/Route';
10
+ import NewActionWrapper from '../AddNewAction/NewActionWrapper';
7
11
  import RepeatOptionsPopup, {
8
12
  REPEAT_OPTIONS,
9
13
  } from './components/RepeatOptionsPopup';
10
14
  import RowItem from './components/RowItem';
11
15
  import SelectWeekday from './components/SelectWeekday';
12
- import { useBoolean } from '../../../hooks/Common';
13
- import { useTranslations } from '../../../hooks/Common/useTranslations';
14
16
  import styles from './styles/indexStyles';
15
- import Routes from '../../../utils/Route';
16
- import NewActionWrapper from '../AddNewAction/NewActionWrapper';
17
17
 
18
18
  const SetSchedule = ({ route }) => {
19
19
  const t = useTranslations();
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
- import { act, create } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
4
1
  import { useRoute } from '@react-navigation/native';
2
+ import MockAdapter from 'axios-mock-adapter';
3
+ import React from 'react';
5
4
  import DraggableFlatList from 'react-native-draggable-flatlist';
5
+ import { act, create } from 'react-test-renderer';
6
6
 
7
7
  import ChangePosition from '../';
8
+ import BottomButtonView from '../../../commons/BottomButtonView';
9
+ import { API } from '../../../configs';
8
10
  import { SCProvider } from '../../../context';
9
11
  import { mockSCStore } from '../../../context/mockStore';
10
12
  import api from '../../../utils/Apis/axios';
11
- import { API } from '../../../configs';
12
13
  import { ToastBottomHelper } from '../../../utils/Utils';
13
- import BottomButtonView from '../../../commons/BottomButtonView';
14
14
 
15
15
  const mock = new MockAdapter(api.axiosInstance);
16
16
  const mockSetDisplay = jest.fn();
@@ -60,6 +60,6 @@ describe('Test ChangePosition', () => {
60
60
  expect(global.mockedGoBack).toHaveBeenCalled();
61
61
  expect(mockFetchData).toHaveBeenCalled();
62
62
  expect(mockSetDisplay).toHaveBeenCalled();
63
- expect(spyToastSuccess).toBeCalledWith('Updated widget successfully');
63
+ expect(spyToastSuccess).toHaveBeenCalledWith('Updated widget successfully');
64
64
  });
65
65
  });
@@ -49,7 +49,8 @@ const ChangePosition = () => {
49
49
  }
50
50
  };
51
51
 
52
- const renderItem = ({ item, index, drag, isActive }) => {
52
+ const renderItem = ({ item, getIndex, drag, isActive }) => {
53
+ const index = getIndex();
53
54
  return (
54
55
  <View style={styles.widgetItem}>
55
56
  <View style={[styles.itemOrder, isActive ? styles.isDragging : {}]}>
@@ -1,18 +1,18 @@
1
+ import MockAdapter from 'axios-mock-adapter';
1
2
  import React from 'react';
2
3
  import { TouchableOpacity } from 'react-native';
3
- import { create, act } from 'react-test-renderer';
4
- import MockAdapter from 'axios-mock-adapter';
4
+ import { act, create } from 'react-test-renderer';
5
5
 
6
- import { SCProvider } from '../../../../context';
7
- import { mockSCStore } from '../../../../context/mockStore';
6
+ import { useRoute } from '@react-navigation/native';
7
+ import Toast from 'react-native-toast-message';
8
8
  import EditDevice from '..';
9
9
  import AlertAction from '../../../../commons/AlertAction';
10
10
  import _TextInput from '../../../../commons/Form/TextInput';
11
- import { AccessibilityLabel } from '../../../../configs/Constants';
12
11
  import { API } from '../../../../configs';
13
- import { useRoute } from '@react-navigation/native';
12
+ import { AccessibilityLabel } from '../../../../configs/Constants';
13
+ import { SCProvider } from '../../../../context';
14
+ import { mockSCStore } from '../../../../context/mockStore';
14
15
  import api from '../../../../utils/Apis/axios';
15
- import Toast from 'react-native-toast-message';
16
16
  import { getTranslate } from '../../../../utils/I18n';
17
17
 
18
18
  const wrapComponent = (route) => (
@@ -96,7 +96,7 @@ describe('Test EditDevice', () => {
96
96
  await act(async () => {
97
97
  await alertAction.props.rightButtonClick();
98
98
  });
99
- expect(Toast.show).toBeCalledWith({
99
+ expect(Toast.show).toHaveBeenCalledWith({
100
100
  type: 'error',
101
101
  position: 'bottom',
102
102
  text1: getTranslate('en', 'rename_failed'),
@@ -148,7 +148,7 @@ describe('Test EditDevice', () => {
148
148
  await act(async () => {
149
149
  await alertAction.props.rightButtonClick();
150
150
  });
151
- expect(Toast.show).toBeCalledWith({
151
+ expect(Toast.show).toHaveBeenCalledWith({
152
152
  type: 'error',
153
153
  position: 'bottom',
154
154
  text1: getTranslate('en', 'remove_failed'),
@@ -1,24 +1,24 @@
1
+ import { NavigationContext, useNavigation } from '@react-navigation/native';
2
+ import MockAdapter from 'axios-mock-adapter';
1
3
  import React from 'react';
2
4
  import { Alert, ScrollView } from 'react-native';
3
5
  import { act, create } from 'react-test-renderer';
4
- import MockAdapter from 'axios-mock-adapter';
5
- import { NavigationContext, useNavigation } from '@react-navigation/native';
6
6
 
7
- import DeviceDetail from '../detail';
8
- import { API } from '../../../configs';
7
+ import AntDesign from 'react-native-vector-icons/AntDesign';
8
+ import { AlertAction, ButtonPopup, MenuActionMore } from '../../../commons';
9
+ import CurrentRainSensor from '../../../commons/Device/RainningSensor/CurrentRainSensor';
9
10
  import { AlertSendConfirm } from '../../../commons/EmergencyButton/AlertSendConfirm';
10
11
  import { AlertSent } from '../../../commons/EmergencyButton/AlertSent';
11
- import { AlertAction, ButtonPopup, MenuActionMore } from '../../../commons';
12
- import { AccessibilityLabel } from '../../../configs/Constants';
13
12
  import Text from '../../../commons/Text';
14
- import AntDesign from 'react-native-vector-icons/AntDesign';
15
- import CurrentRainSensor from '../../../commons/Device/RainningSensor/CurrentRainSensor';
16
- import { getTranslate } from '../../../utils/I18n';
13
+ import { API } from '../../../configs';
14
+ import { AccessibilityLabel } from '../../../configs/Constants';
17
15
  import { SCProvider } from '../../../context';
18
16
  import { mockSCStore } from '../../../context/mockStore';
19
- import Routes from '../../../utils/Route';
20
- import api from '../../../utils/Apis/axios';
21
17
  import { useWatchConfigs } from '../../../hooks/IoT';
18
+ import api from '../../../utils/Apis/axios';
19
+ import { getTranslate } from '../../../utils/I18n';
20
+ import Routes from '../../../utils/Route';
21
+ import DeviceDetail from '../detail';
22
22
 
23
23
  const mock = new MockAdapter(api.axiosInstance);
24
24
 
@@ -755,7 +755,7 @@ describe('test DeviceDetail', () => {
755
755
  await act(async () => {
756
756
  await create(wrapComponent(store, account, route));
757
757
  });
758
- expect(mockAlertShow).not.toBeCalled();
758
+ expect(mockAlertShow).not.toHaveBeenCalled();
759
759
  });
760
760
 
761
761
  it('Test fetchUnitDetail', async () => {
@@ -1,22 +1,22 @@
1
+ import { NavigationContext } from '@react-navigation/native';
2
+ import MockAdapter from 'axios-mock-adapter';
3
+ import mqtt from 'precompiled-mqtt/dist/mqtt.browser';
1
4
  import React from 'react';
2
5
  import { Alert } from 'react-native';
3
6
  import { act, create } from 'react-test-renderer';
4
- import MockAdapter from 'axios-mock-adapter';
5
- import mqtt from 'precompiled-mqtt/dist/mqtt.browser';
6
- import { NavigationContext } from '@react-navigation/native';
7
7
 
8
- import DeviceDetail from '../detail';
8
+ import QualityIndicatorItem from '../../../commons/Device/WaterQualitySensor/QualityIndicatorsItem';
9
9
  import { API } from '../../../configs';
10
10
  import { SCProvider } from '../../../context';
11
11
  import { mockSCStore } from '../../../context/mockStore';
12
+ import { watchMultiConfigs } from '../../../iot/Monitor';
13
+ import { setConfigGlobalState } from '../../../iot/states';
12
14
  import api from '../../../utils/Apis/axios';
13
15
  import {
14
- gatewayDataFactory,
15
16
  configDataFactory,
17
+ gatewayDataFactory,
16
18
  } from '../../../utils/FactoryGateway';
17
- import QualityIndicatorItem from '../../../commons/Device/WaterQualitySensor/QualityIndicatorsItem';
18
- import { watchMultiConfigs } from '../../../iot/Monitor';
19
- import { setConfigGlobalState } from '../../../iot/states';
19
+ import DeviceDetail from '../detail';
20
20
 
21
21
  const mock = new MockAdapter(api.axiosInstance);
22
22
 
@@ -194,7 +194,7 @@ describe('test DeviceDetail', () => {
194
194
  await act(async () => {
195
195
  tree.unmount();
196
196
  });
197
- expect(client.end).toBeCalled();
197
+ expect(client.end).toHaveBeenCalled();
198
198
  });
199
199
 
200
200
  const _receiveDataOnDeviceDetail = async (widgetConfigs, topic, message) => {
@@ -13,19 +13,19 @@ import ListQualityIndicator from '../../../commons/Device/WaterQualitySensor/Lis
13
13
  import Compass from '../../../commons/Device/WindDirection/Compass';
14
14
  import Anemometer from '../../../commons/Device/WindSpeed/Anemometer';
15
15
  import MediaPlayerDetail from '../../../commons/MediaPlayerDetail';
16
+ import IFrame from '../../../commons/Widgets/IFrame/IFrame';
17
+ import IFrameWithConfig from '../../../commons/Widgets/IFrameWithConfig/IFrameWithConfig';
18
+ import { Device } from '../../../configs';
16
19
  import { AccessibilityLabel, WIDGET_TYPE } from '../../../configs/Constants';
17
20
  import { useSCContextSelector } from '../../../context';
18
21
  import { useRemoteControl } from '../../../hooks/IoT';
19
22
  import { useConfigGlobalState } from '../../../iot/states';
20
23
  import SmartIr from '../../../screens/SmartIr';
24
+ import { standardizeCameraScreenSize } from '../../../utils/Utils';
21
25
  import { useEvaluateValue } from '../hooks/useEvaluateValue';
22
26
  import styles from '../styles';
23
- import VisualChart from './VisualChart';
24
- import { standardizeCameraScreenSize } from '../../../utils/Utils';
25
- import { Device } from '../../../configs';
26
27
  import DonutCharts from './DonutChart';
27
- import IFrame from '../../../commons/Widgets/IFrame/IFrame';
28
- import IFrameWithConfig from '../../../commons/Widgets/IFrameWithConfig/IFrameWithConfig';
28
+ import VisualChart from './VisualChart';
29
29
 
30
30
  const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
31
31
  Device.screenWidth - 32
@@ -1,10 +1,10 @@
1
+ import { useNavigation } from '@react-navigation/native';
1
2
  import React from 'react';
2
3
  import renderer, { act } from 'react-test-renderer';
3
4
  import AccessibilityLabel from '../../configs/AccessibilityLabel';
4
5
  import { SCProvider } from '../../context';
5
6
  import { mockSCStore } from '../../context/mockStore';
6
7
  import Drawer, { Row } from './index';
7
- import { useNavigation } from '@react-navigation/native';
8
8
 
9
9
  const wrapComponent = (initState = mockSCStore({})) => (
10
10
  <SCProvider initState={initState}>
@@ -35,7 +35,7 @@ describe('Drawer', () => {
35
35
  await act(async () => {
36
36
  await rows[2].props.onPress();
37
37
  });
38
- expect(dispatch).toBeCalledWith({
38
+ expect(dispatch).toHaveBeenCalledWith({
39
39
  payload: { index: 0, routes: [{ name: 'Main' }] },
40
40
  type: 'RESET',
41
41
  });
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
- import { act, create } from 'react-test-renderer';
3
1
  import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
4
3
  import Toast from 'react-native-toast-message';
4
+ import { act, create } from 'react-test-renderer';
5
5
 
6
- import { EmergencyContactsSelectContacts } from '../EmergencyContactsSelectContacts';
6
+ import { ViewButtonBottom } from '../../../commons';
7
+ import { API } from '../../../configs';
7
8
  import { AccessibilityLabel } from '../../../configs/Constants';
8
9
  import { SCProvider } from '../../../context';
9
10
  import { mockSCStore } from '../../../context/mockStore';
10
- import { API } from '../../../configs';
11
- import { ViewButtonBottom } from '../../../commons';
12
11
  import api from '../../../utils/Apis/axios';
13
12
  import { getTranslate } from '../../../utils/I18n';
13
+ import { EmergencyContactsSelectContacts } from '../EmergencyContactsSelectContacts';
14
14
 
15
15
  const mock = new MockAdapter(api.axiosInstance);
16
16
 
@@ -79,7 +79,7 @@ describe('test EmergencyContactsSelectContacts', () => {
79
79
  await act(async () => {
80
80
  viewButtonBottom.props.onRightClick();
81
81
  });
82
- expect(Toast.show).toBeCalledWith({
82
+ expect(Toast.show).toHaveBeenCalledWith({
83
83
  type: 'success',
84
84
  position: 'bottom',
85
85
  text1: getTranslate('en', 'saving_contact_successful'),
@@ -98,7 +98,7 @@ describe('test EmergencyContactsSelectContacts', () => {
98
98
  await act(async () => {
99
99
  viewButtonBottom.props.onRightClick();
100
100
  });
101
- expect(Toast.show).toBeCalledWith({
101
+ expect(Toast.show).toHaveBeenCalledWith({
102
102
  type: 'error',
103
103
  position: 'bottom',
104
104
  text1: getTranslate('en', 'create_contact_failed'),