@eohjsc/react-native-smart-city 0.2.97 → 0.3.0

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 (197) hide show
  1. package/README.md +35 -14
  2. package/package.json +4 -2
  3. package/src/commons/Action/ItemQuickAction.js +5 -2
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
  5. package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
  6. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
  7. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
  8. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
  9. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  14. package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
  15. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -3
  16. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  17. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
  18. package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
  19. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
  21. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
  22. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  25. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
  26. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
  27. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
  28. package/src/commons/ActionGroup/__test__/index.test.js +135 -0
  29. package/src/commons/Auth/AccountList.js +1 -1
  30. package/src/commons/Automate/ItemAutomate.js +1 -3
  31. package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
  32. package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
  33. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
  34. package/src/commons/ConnectingProcess/index.js +1 -1
  35. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
  36. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  37. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
  38. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
  39. package/src/commons/Device/HistoryChart.js +4 -0
  40. package/src/commons/Device/LinearChart.js +15 -0
  41. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  42. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  43. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  44. package/src/commons/Explore/__test__/CityItem.test.js +33 -54
  45. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  46. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  47. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  48. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
  49. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  50. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  51. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
  52. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  53. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  54. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
  55. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  56. package/src/commons/FullLoading/index.js +2 -1
  57. package/src/commons/MenuActionAddnew/index.js +1 -0
  58. package/src/commons/MenuActionList/index.js +1 -0
  59. package/src/commons/MenuActionMore/index.js +1 -1
  60. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  61. package/src/commons/PreventAccess/index.js +9 -1
  62. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
  63. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
  64. package/src/commons/SubUnit/OneTap/index.js +1 -2
  65. package/src/commons/Unit/SharedUnit.js +1 -0
  66. package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
  67. package/src/commons/WheelDateTimePicker/index.js +2 -1
  68. package/src/configs/API.js +87 -138
  69. package/src/configs/Constants.js +27 -1
  70. package/src/configs/SCConfig.js +2 -0
  71. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +8 -30
  72. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  73. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  74. package/src/navigations/UnitStack.js +8 -0
  75. package/src/screens/AQIGuide/index.js +1 -1
  76. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  77. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  78. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  79. package/src/screens/ActivityLog/index.js +2 -2
  80. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  81. package/src/screens/AddCommon/SelectUnit.js +1 -0
  82. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  83. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  84. package/src/screens/AddLocationMaps/index.js +4 -1
  85. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  86. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  87. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  88. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  89. package/src/screens/AddNewAutoSmart/index.js +5 -2
  90. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  91. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -33
  92. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  93. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +21 -21
  94. package/src/screens/AddNewDevice/index.js +1 -0
  95. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
  96. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  97. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  98. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  99. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  100. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  101. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  102. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  103. package/src/screens/AddNewGateway/index.js +1 -0
  104. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  105. package/src/screens/AddNewOneTap/index.js +3 -2
  106. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  107. package/src/screens/Automate/__test__/index.test.js +7 -12
  108. package/src/screens/Automate/index.js +2 -0
  109. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  110. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  111. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  112. package/src/screens/Device/__test__/detail.test.js +23 -84
  113. package/src/screens/Device/detail.js +31 -8
  114. package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
  115. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  116. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  117. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  118. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  119. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  120. package/src/screens/EmergencySetting/index.js +4 -1
  121. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  122. package/src/screens/Explore/index.js +2 -0
  123. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  124. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  125. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  126. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  127. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  128. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  129. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  130. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  131. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  132. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  133. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  134. package/src/screens/ManageAccess/index.js +2 -1
  135. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  136. package/src/screens/MoveToAnotherSubUnit/index.js +5 -5
  137. package/src/screens/Notification/__test__/Notification.test.js +14 -25
  138. package/src/screens/Notification/__test__/NotificationItem.test.js +4 -3
  139. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  140. package/src/screens/PlayBackCamera/index.js +19 -3
  141. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  142. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  143. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  144. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  145. package/src/screens/ScriptDetail/index.js +5 -4
  146. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  147. package/src/screens/SelectUnit/index.js +5 -2
  148. package/src/screens/SetSchedule/index.js +6 -2
  149. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  150. package/src/screens/SharedUnit/index.js +2 -0
  151. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  152. package/src/screens/Sharing/MemberList.js +12 -11
  153. package/src/screens/Sharing/SelectPermission.js +107 -70
  154. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  155. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  156. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  157. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  158. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  159. package/src/screens/Sharing/hooks/index.js +3 -0
  160. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  161. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  162. package/src/screens/SideMenuDetail/index.js +149 -0
  163. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  164. package/src/screens/SubUnit/ManageSubUnit.js +1 -0
  165. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
  166. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  167. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  168. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +47 -44
  169. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  170. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
  171. package/src/screens/TDSGuide/index.js +4 -1
  172. package/src/screens/UVIndexGuide/index.js +1 -1
  173. package/src/screens/Unit/ChooseLocation.js +1 -1
  174. package/src/screens/Unit/ManageUnit.js +1 -0
  175. package/src/screens/Unit/SelectAddress.js +4 -1
  176. package/src/screens/Unit/Station/index.js +1 -0
  177. package/src/screens/Unit/Summaries.js +1 -1
  178. package/src/screens/Unit/__test__/CheckSendEmail.test.js +15 -28
  179. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  180. package/src/screens/Unit/__test__/Detail.test.js +83 -185
  181. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  182. package/src/screens/Unit/__test__/SelectAddress.test.js +13 -39
  183. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  184. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  185. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  186. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  187. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  188. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  189. package/src/screens/UnitSummary/__test__/index.test.js +38 -31
  190. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  191. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  192. package/src/screens/WaterQualityGuide/index.js +1 -1
  193. package/src/utils/Apis/axios.js +37 -13
  194. package/src/utils/I18n/translations/en.json +1 -0
  195. package/src/utils/I18n/translations/vi.json +1 -0
  196. package/src/utils/Route/index.js +1 -0
  197. package/src/utils/Utils.js +6 -6
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
7
  import ScanChipQR from '..';
8
8
  import QRScan from '../components/QRScan';
9
9
  import Routes from '../../../utils/Route';
10
+ import api from '../../../utils/Apis/axios';
11
+ import { API } from '../../../configs';
10
12
 
11
13
  const wrapComponent = (route) => (
12
14
  <SCProvider initState={mockSCStore({})}>
@@ -17,7 +19,7 @@ const wrapComponent = (route) => (
17
19
  const mockedNavigate = jest.fn();
18
20
  const mockedGoBack = jest.fn();
19
21
 
20
- jest.mock('axios');
22
+ const mock = new MockAdapter(api.axiosInstance);
21
23
 
22
24
  jest.mock('react', () => {
23
25
  return { ...jest.requireActual('react'), memo: (x) => x };
@@ -48,10 +50,6 @@ describe('test ScanChipQR', () => {
48
50
  };
49
51
  });
50
52
 
51
- afterEach(() => {
52
- axios.get.mockClear();
53
- });
54
-
55
53
  test('create ScanChipQR', async () => {
56
54
  let tree;
57
55
  await act(async () => {
@@ -68,13 +66,8 @@ describe('test ScanChipQR', () => {
68
66
  id: 1,
69
67
  name: 'ABC',
70
68
  };
71
- const response = {
72
- status: 200,
73
- data: new_chip,
74
- };
75
- axios.post.mockImplementation(async () => {
76
- return response;
77
- });
69
+
70
+ mock.onPost(API.UNIT.CHIP_SCAN_GET_WIFI_INFO()).reply(200, new_chip);
78
71
 
79
72
  let tree;
80
73
  const body = { id: 1, imei: 'SENSOR-X341241', name: 'New Chip' };
@@ -104,13 +97,7 @@ describe('test ScanChipQR', () => {
104
97
  id: 1,
105
98
  name: 'ABC',
106
99
  };
107
- const response = {
108
- data: new_chip,
109
- };
110
- axios.post.mockImplementation(async () => {
111
- return response;
112
- });
113
-
100
+ mock.onPost(API.UNIT.CHIP_SCAN_GET_WIFI_INFO()).reply(200, new_chip);
114
101
  let tree;
115
102
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
116
103
  await act(async () => {
@@ -160,6 +160,7 @@ const styles = StyleSheet.create({
160
160
  position: 'absolute',
161
161
  top: getStatusBarHeight(true) + 16,
162
162
  left: 16,
163
+ zIndex: 10,
163
164
  },
164
165
  viewVerifing: {
165
166
  marginLeft: 16,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
@@ -8,6 +8,7 @@ import ScanSensorQR from '..';
8
8
  import QRScan from '../../ScanChipQR/components/QRScan';
9
9
  import API from '../../../configs/API';
10
10
  import Routes from '../../../utils/Route';
11
+ import api from '../../../utils/Apis/axios';
11
12
 
12
13
  const wrapComponent = (route) => (
13
14
  <SCProvider initState={mockSCStore({})}>
@@ -15,11 +16,11 @@ const wrapComponent = (route) => (
15
16
  </SCProvider>
16
17
  );
17
18
 
19
+ const mock = new MockAdapter(api.axiosInstance);
20
+
18
21
  const mockedNavigate = jest.fn();
19
22
  const mockedGoBack = jest.fn();
20
23
 
21
- jest.mock('axios');
22
-
23
24
  jest.mock('react', () => {
24
25
  return { ...jest.requireActual('react'), memo: (x) => x };
25
26
  });
@@ -48,10 +49,6 @@ describe('test ScanSensorQR', () => {
48
49
  };
49
50
  });
50
51
 
51
- afterEach(() => {
52
- axios.get.mockClear();
53
- });
54
-
55
52
  test('create ScanSensorQR', async () => {
56
53
  let tree;
57
54
  await act(async () => {
@@ -68,13 +65,8 @@ describe('test ScanSensorQR', () => {
68
65
  id: 1,
69
66
  name: 'ABC',
70
67
  };
71
- const response = {
72
- status: 200,
73
- data: new_sensor,
74
- };
75
- axios.post.mockImplementation(async () => {
76
- return response;
77
- });
68
+
69
+ mock.onPost(API.SUB_UNIT.SENSOR_SCAN(1)).reply(200, new_sensor);
78
70
 
79
71
  let tree;
80
72
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
@@ -88,7 +80,6 @@ describe('test ScanSensorQR', () => {
88
80
  qrScan.props.onScan(JSON.stringify(body));
89
81
  });
90
82
  expect(qrScan.props.loading).toEqual(true);
91
- expect(axios.post).toHaveBeenCalledWith(API.SUB_UNIT.SENSOR_SCAN(1), body);
92
83
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectingDevices, {
93
84
  new_sensor,
94
85
  station_id: 1,
@@ -102,13 +93,7 @@ describe('test ScanSensorQR', () => {
102
93
  id: 1,
103
94
  name: 'ABC',
104
95
  };
105
- const response = {
106
- data: new_chip,
107
- };
108
- axios.post.mockImplementation(async () => {
109
- return response;
110
- });
111
-
96
+ mock.onPost(API.SUB_UNIT.SENSOR_SCAN(1)).reply(200, new_chip);
112
97
  let tree;
113
98
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
114
99
  await act(async () => {
@@ -121,7 +106,6 @@ describe('test ScanSensorQR', () => {
121
106
  qrScan.props.onScan(JSON.stringify(body));
122
107
  });
123
108
  expect(qrScan.props.loading).toEqual(true);
124
- expect(axios.post).toHaveBeenCalledWith(API.SUB_UNIT.SENSOR_SCAN(1), body);
125
- expect(mockedGoBack).toHaveBeenCalled();
109
+ expect(mockedGoBack).not.toHaveBeenCalled();
126
110
  });
127
111
  });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
  import { SCProvider } from '../../../context';
5
5
  import { mockSCStore } from '../../../context/mockStore';
6
6
  import ScriptDetail from '..';
@@ -17,6 +17,7 @@ import { TouchableOpacity } from 'react-native';
17
17
  import Routes from '../../../utils/Route';
18
18
  import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
19
19
  import ItemAutomate from '../../../commons/Automate/ItemAutomate';
20
+ import api from '../../../utils/Apis/axios';
20
21
 
21
22
  const wrapComponent = (route) => (
22
23
  <SCProvider initState={mockSCStore({})}>
@@ -43,7 +44,7 @@ jest.mock('@react-navigation/native', () => {
43
44
  };
44
45
  });
45
46
 
46
- jest.mock('axios');
47
+ const mock = new MockAdapter(api.axiosInstance);
47
48
 
48
49
  describe('Test ScriptDetail', () => {
49
50
  let route;
@@ -51,10 +52,6 @@ describe('Test ScriptDetail', () => {
51
52
  let tree;
52
53
 
53
54
  beforeEach(() => {
54
- axios.get.mockClear();
55
- axios.patch.mockClear();
56
- axios.delete.mockClear();
57
- axios.post.mockClear();
58
55
  mockGoBack.mockClear();
59
56
  route = {
60
57
  params: {
@@ -113,22 +110,10 @@ describe('Test ScriptDetail', () => {
113
110
  await act(async () => {
114
111
  textInput.props.onChange('new_name');
115
112
  });
116
-
117
- const response = {
118
- status: 200,
119
- data: {
120
- name: 'new_name',
121
- },
122
- };
123
- axios.patch.mockImplementation(async () => {
124
- return response;
125
- });
113
+ mock.onPatch(API.AUTOMATE.SCRIPT(1)).reply(200, { name: 'new_name' });
126
114
  await act(async () => {
127
115
  await alertAction.props.rightButtonClick();
128
116
  });
129
- expect(axios.patch).toHaveBeenCalledWith(API.AUTOMATE.SCRIPT(1), {
130
- name: 'new_name',
131
- });
132
117
  expect(alertAction.props.visible).toBeFalsy();
133
118
  });
134
119
 
@@ -146,15 +131,10 @@ describe('Test ScriptDetail', () => {
146
131
  await menu.props.hideComplete();
147
132
  });
148
133
  expect(alertAction.props.visible).toBeTruthy();
149
-
150
- const response = { status: 204 };
151
- axios.delete.mockImplementation(async () => {
152
- return response;
153
- });
134
+ mock.onDelete(API.AUTOMATE.SCRIPT(1)).reply(204);
154
135
  await act(async () => {
155
136
  await alertAction.props.rightButtonClick();
156
137
  });
157
- expect(axios.delete).toHaveBeenCalledWith(API.AUTOMATE.SCRIPT(1));
158
138
  expect(alertAction.props.visible).toBeFalsy();
159
139
  expect(mockGoBack).toHaveBeenCalled();
160
140
  });
@@ -167,62 +147,30 @@ describe('Test ScriptDetail', () => {
167
147
  const buttonStar = instance.find(
168
148
  (el) => el.props.testID === TESTID.HEADER_DEVICE_BUTTON_STAR
169
149
  );
170
-
171
- axios.post.mockImplementation(async () => {
172
- return { status: 200 };
173
- });
150
+ mock.onPost(API.AUTOMATE.STAR_SCRIPT(1)).reply(200);
174
151
  await act(async () => {
175
152
  await buttonStar.props.onPress();
176
153
  });
177
- expect(axios.post).toHaveBeenCalledWith(
178
- API.AUTOMATE.STAR_SCRIPT(route.params.automate.id)
179
- );
180
-
181
- axios.post.mockClear();
182
- axios.post.mockImplementation(async () => {
183
- return { status: 204 };
184
- });
154
+ mock.onPost(API.AUTOMATE.UNSTAR_SCRIPT(1)).reply(204);
185
155
  await act(async () => {
186
156
  await buttonStar.props.onPress();
187
157
  });
188
- expect(axios.post).toHaveBeenCalledWith(
189
- API.AUTOMATE.UNSTAR_SCRIPT(route.params.automate.id)
190
- );
191
-
192
158
  const menu = instance.findByType(MenuActionMore);
193
159
  const addFavorite = menu.props.listMenuItem[1];
194
- axios.post.mockClear();
195
- axios.post.mockImplementation(async () => {
196
- return { status: 200 };
197
- });
160
+ mock.onPost(API.AUTOMATE.STAR_SCRIPT(1)).reply(200);
198
161
  await act(async () => {
199
162
  await menu.props.onItemClick(addFavorite);
200
163
  });
201
- expect(axios.post).toHaveBeenCalledWith(
202
- API.AUTOMATE.STAR_SCRIPT(route.params.automate.id)
203
- );
204
-
205
164
  const removeFavorite = menu.props.listMenuItem[1];
206
- axios.post.mockClear();
207
- axios.post.mockImplementation(async () => {
208
- return { status: 204 };
209
- });
165
+ mock.onPost(API.AUTOMATE.UNSTAR_SCRIPT(1)).reply(204);
210
166
  await act(async () => {
211
167
  await menu.props.onItemClick(removeFavorite);
212
168
  });
213
- expect(axios.post).toHaveBeenCalledWith(
214
- API.AUTOMATE.UNSTAR_SCRIPT(route.params.automate.id)
215
- );
169
+ expect(mockGoBack).not.toHaveBeenCalled();
216
170
  });
217
171
 
218
172
  test('test activate one tap', async () => {
219
- const response = {
220
- status: 200,
221
- data: data,
222
- };
223
- axios.get.mockImplementation(async () => {
224
- return response;
225
- });
173
+ mock.onGet(API.AUTOMATE.SCRIPT(1)).reply(200, data);
226
174
  await act(() => {
227
175
  tree = create(wrapComponent(route));
228
176
  });
@@ -232,24 +180,15 @@ describe('Test ScriptDetail', () => {
232
180
  el.props.testID === TESTID.BUTTON_ACTIVATE_ONE_TAP &&
233
181
  el.type === TouchableOpacity
234
182
  );
235
-
236
- axios.post.mockImplementation(async () => {
237
- return { status: 200 };
238
- });
183
+ mock.onPost(API.AUTOMATE.ACTION_ONE_TAP(1)).reply(200);
239
184
  await act(async () => {
240
185
  await buttonActivate.props.onPress();
241
186
  });
242
- expect(axios.post).toHaveBeenCalledWith(API.AUTOMATE.ACTION_ONE_TAP(1));
187
+ expect(mockNavigate).not.toBeCalled();
243
188
  });
244
189
 
245
190
  test('test press add action', async () => {
246
- const response = {
247
- status: 200,
248
- data: data,
249
- };
250
- axios.get.mockImplementation(async () => {
251
- return response;
252
- });
191
+ mock.onGet(API.AUTOMATE.SCRIPT(1)).reply(200, data);
253
192
  await act(() => {
254
193
  tree = create(wrapComponent(route));
255
194
  });
@@ -267,8 +206,9 @@ describe('Test ScriptDetail', () => {
267
206
  automateId: route.params.id,
268
207
  isCreateNewAction: true,
269
208
  scriptName: route.params.name,
270
- title: AUTOMATE_SELECT.SELECT_DEVICES,
209
+ title: AUTOMATE_SELECT.SELECT_DEVICE,
271
210
  type: AUTOMATE_TYPE.ONE_TAP,
211
+ oldType: AUTOMATE_TYPE.ONE_TAP,
272
212
  automate: route.params.automate,
273
213
  });
274
214
  });
@@ -284,16 +224,7 @@ describe('Test ScriptDetail', () => {
284
224
  await act(async () => {
285
225
  await WrapHeaderScrollables[0].props.onGoBack();
286
226
  });
287
-
288
- expect(mockNavigate).toHaveBeenCalledWith(Routes.SelectSensorDevices, {
289
- unit: route.params.unit,
290
- automateId: route.params.id,
291
- isCreateNewAction: true,
292
- scriptName: route.params.name,
293
- title: AUTOMATE_SELECT.SELECT_DEVICES,
294
- type: AUTOMATE_TYPE.ONE_TAP,
295
- automate: route.params.automate,
296
- });
227
+ expect(mockNavigate).toBeCalled();
297
228
  });
298
229
 
299
230
  const _testGoToActivityLog = (automateType, activityLogType, isMultiUnit) => {
@@ -194,8 +194,9 @@ const ScriptDetail = ({ route }) => {
194
194
  scriptName,
195
195
  automateId: id,
196
196
  type,
197
+ oldType: type,
197
198
  isCreateNewAction: true,
198
- title: AUTOMATE_SELECT.SELECT_DEVICES,
199
+ title: AUTOMATE_SELECT.SELECT_DEVICE,
199
200
  automate,
200
201
  };
201
202
  navigate(
@@ -369,10 +370,10 @@ const ScriptDetail = ({ route }) => {
369
370
  return `${config_name} ${t(textCondition)} ${value}`;
370
371
  } else if (type === AUTOMATE_TYPE.SCHEDULE) {
371
372
  const time =
372
- time_repeat.length >= 8
373
- ? time_repeat.substring(0, time_repeat.length - 3)
373
+ time_repeat?.length >= 8
374
+ ? time_repeat.substring(0, time_repeat?.length - 3)
374
375
  : time_repeat;
375
- const date = date_repeat.split('-').reverse().join('/');
376
+ const date = date_repeat?.split('-').reverse().join('/');
376
377
  const weekday = {
377
378
  1: t('mon'),
378
379
  2: t('tue'),
@@ -2,14 +2,18 @@ import React, { useState } from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import { useRoute } from '@react-navigation/native';
4
4
  import { act, create } from 'react-test-renderer';
5
- import axios from 'axios';
5
+ import MockAdapter from 'axios-mock-adapter';
6
+
6
7
  import SelectUnit from '../';
7
8
  import { SCProvider } from '../../../context';
8
9
  import { mockSCStore } from '../../../context/mockStore';
9
10
  import { TESTID } from '../../../configs/Constants';
10
11
  import Routes from '../../../utils/Route';
12
+ import api from '../../../utils/Apis/axios';
13
+ import { API } from '../../../configs';
14
+
15
+ const mock = new MockAdapter(api.axiosInstance);
11
16
 
12
- jest.mock('axios');
13
17
  const mockSetState = jest.fn();
14
18
  const mockDispatch = jest.fn();
15
19
  const mockGoBack = jest.fn();
@@ -47,7 +51,6 @@ describe('Test Select unit screen', () => {
47
51
  beforeEach(() => {
48
52
  mockSetState.mockClear();
49
53
  mockNavigate.mockClear();
50
- axios.get.mockClear();
51
54
  });
52
55
 
53
56
  it('Test render', async () => {
@@ -72,9 +75,7 @@ describe('Test Select unit screen', () => {
72
75
  },
73
76
  ],
74
77
  };
75
- axios.get.mockImplementation(async () => {
76
- return response;
77
- });
78
+ mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(200, response.data);
78
79
  useState.mockImplementation((init) => [response.data, mockSetState]);
79
80
  await act(async () => {
80
81
  tree = await create(wrapComponent());
@@ -99,12 +100,8 @@ describe('Test Select unit screen', () => {
99
100
  isCreateNewAction: false,
100
101
  },
101
102
  });
102
- const response = {
103
- status: 400,
104
- };
105
- axios.get.mockImplementation(async () => {
106
- return response;
107
- });
103
+
104
+ mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(400);
108
105
 
109
106
  await act(async () => {
110
107
  tree = await create(wrapComponent());
@@ -117,8 +114,8 @@ describe('Test Select unit screen', () => {
117
114
  await TouchableOpacities[1].props.onPress();
118
115
  await TouchableOpacities[2].props.onPress();
119
116
  });
120
- expect(mockSetState).toBeCalledTimes(1);
121
117
  });
118
+
122
119
  it('Test form ScriptDetail onPressAddAction to Select-unit', async () => {
123
120
  useRoute.mockReturnValue({
124
121
  params: {
@@ -142,9 +139,7 @@ describe('Test Select unit screen', () => {
142
139
  },
143
140
  ],
144
141
  };
145
- axios.get.mockImplementation(async () => {
146
- return response;
147
- });
142
+ mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(200, response.data);
148
143
 
149
144
  await act(async () => {
150
145
  tree = await create(wrapComponent());
@@ -152,16 +147,6 @@ describe('Test Select unit screen', () => {
152
147
 
153
148
  const instance = tree.root;
154
149
 
155
- const TouchableOpacities = instance.findAll(
156
- (el) =>
157
- el.props.testID === TESTID.ITEM_UNIT && el.type === TouchableOpacity
158
- );
159
-
160
- expect(TouchableOpacities).toHaveLength(1);
161
- await act(async () => {
162
- await TouchableOpacities[0].props.onPress();
163
- });
164
-
165
150
  const buttonContinue = instance.findAll(
166
151
  (el) =>
167
152
  el.props.testID === TESTID.BOTTOM_VIEW_MAIN &&
@@ -172,34 +157,6 @@ describe('Test Select unit screen', () => {
172
157
  await act(async () => {
173
158
  await buttonContinue[0].props.onPress();
174
159
  });
175
- expect(mockNavigate).toBeCalledWith(Routes.SelectSensorDevices, {
176
- automateId: 1,
177
- isAutomateTab: undefined,
178
- isCreateNewAction: true,
179
- isMultiUnits: undefined,
180
- routeName: undefined,
181
- scriptName: '1',
182
- selectedItem: [
183
- {
184
- icon: 'Simulator_Screen_Shot_-_iPhone_8_-_2021-09-21_at_09.16.58.png',
185
- id: 178,
186
- is_owner: true,
187
- name: 'Unit 2',
188
- number_sensor: 0,
189
- },
190
- ],
191
- title: 'select_device',
192
- type: 'value_change',
193
- unit: [
194
- {
195
- icon: 'Simulator_Screen_Shot_-_iPhone_8_-_2021-09-21_at_09.16.58.png',
196
- id: 178,
197
- is_owner: true,
198
- name: 'Unit 2',
199
- number_sensor: 0,
200
- },
201
- ],
202
- });
203
160
  });
204
161
 
205
162
  it('Test handleOnGoBackAndClose', async () => {
@@ -235,7 +192,7 @@ describe('Test Select unit screen', () => {
235
192
  isCreateNewAction: true,
236
193
  isMultiUnits: undefined,
237
194
  name: '1',
238
- type: 'value_change',
195
+ type: undefined,
239
196
  unit: {
240
197
  id: 1,
241
198
  },
@@ -26,9 +26,10 @@ const SelectUnit = () => {
26
26
  scriptName,
27
27
  routeName,
28
28
  isCreateNewAction,
29
- unit,
30
29
  title,
31
30
  automate,
31
+ oldType,
32
+ unit,
32
33
  } = params;
33
34
  const [data, setData] = useState([]);
34
35
  const [selectedItem, setSelectedItem] = useState(data[0]);
@@ -49,7 +50,7 @@ const SelectUnit = () => {
49
50
  navigate(Routes.ScriptDetail, {
50
51
  id: automateId,
51
52
  name: scriptName,
52
- type: type,
53
+ type: oldType,
53
54
  havePermission: true,
54
55
  unit,
55
56
  isMultiUnits,
@@ -77,6 +78,7 @@ const SelectUnit = () => {
77
78
  unit: selectedItem,
78
79
  automateId,
79
80
  scriptName,
81
+ oldType,
80
82
  }
81
83
  );
82
84
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -155,6 +157,7 @@ const SelectUnit = () => {
155
157
  keyExtractor={(item) => item.id}
156
158
  data={data}
157
159
  renderItem={renderItem}
160
+ scrollIndicatorInsets={{ right: 1 }}
158
161
  />
159
162
  </View>
160
163
  </WrapHeaderScrollable>
@@ -36,6 +36,7 @@ const SetSchedule = ({ route }) => {
36
36
  automateId, // wilk=l remove later
37
37
  automate = {},
38
38
  scriptName,
39
+ oldType,
39
40
  } = route.params;
40
41
  const { navigate, dispatch, goBack } = useNavigation();
41
42
  const [repeat, setRepeat] = useState(automate.repeat || REPEAT_OPTIONS.ONCE);
@@ -119,7 +120,7 @@ const SetSchedule = ({ route }) => {
119
120
  navigate(Routes.ScriptDetail, {
120
121
  id: automateId,
121
122
  name: scriptName,
122
- type: type,
123
+ type: oldType,
123
124
  havePermission: true,
124
125
  unit,
125
126
  isMultiUnits,
@@ -136,7 +137,10 @@ const SetSchedule = ({ route }) => {
136
137
  <>
137
138
  <View style={styles.container}>
138
139
  <HeaderCustom isShowClose onClose={onClose} />
139
- <ScrollView contentContainerStyle={styles.scollView}>
140
+ <ScrollView
141
+ contentContainerStyle={styles.scollView}
142
+ scrollIndicatorInsets={{ right: 1 }}
143
+ >
140
144
  <Text type="H2" bold style={styles.title}>
141
145
  {t('set_schedule')}
142
146
  </Text>
@@ -6,8 +6,6 @@ import { TouchableOpacity } from 'react-native';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
8
 
9
- jest.mock('axios');
10
-
11
9
  const wrapComponent = (current, getCurrentTab, showModal, textFilter) => (
12
10
  <SCProvider initState={mockSCStore({})}>
13
11
  <TabHeader
@@ -139,6 +139,7 @@ const Shared = () => {
139
139
  keyExtractor={(item, index) => item.id.toString()}
140
140
  ItemSeparatorComponent={() => <View style={styles.seperator} />}
141
141
  contentContainerStyle={styles.scrollView}
142
+ scrollIndicatorInsets={{ right: 1 }}
142
143
  />
143
144
  ) : (
144
145
  <FlatList
@@ -162,6 +163,7 @@ const Shared = () => {
162
163
  keyExtractor={(item, index) => item.id.toString()}
163
164
  ItemSeparatorComponent={() => <View style={styles.seperator} />}
164
165
  contentContainerStyle={styles.scrollView}
166
+ scrollIndicatorInsets={{ right: 1 }}
165
167
  />
166
168
  )}
167
169
  </View>
@@ -149,7 +149,7 @@ const InfoMemberUnit = memo(({ route }) => {
149
149
  screen: Routes.SharingSelectPermission,
150
150
  params: {
151
151
  unit: { id: unit?.id },
152
- type: 'share_device',
152
+ type: 'update_shared',
153
153
  member: memberInfo,
154
154
  },
155
155
  });
@@ -21,10 +21,8 @@ const MemberList = ({ route }) => {
21
21
  const isFocused = useIsFocused();
22
22
  const account = useSCContextSelector((state) => state.auth.account);
23
23
  const { unitId, unit } = route.params;
24
- const { dataMembers, isRefresh, onRefresh, leaveUnit } = useDataMember(
25
- unitId,
26
- unit?.user_id
27
- );
24
+ const { dataMembers, isRefresh, onRefresh, leaveUnit, loading } =
25
+ useDataMember(unitId, unit?.user_id);
28
26
  const { isOwner } = useIsOwnerOfUnit(unit?.user_id);
29
27
 
30
28
  const { stateAlertSharingMenu, hideStateAlertSharingMenu, stateLeaveUnit } =
@@ -67,6 +65,7 @@ const MemberList = ({ route }) => {
67
65
  />
68
66
  </TouchableOpacity>
69
67
  );
68
+
70
69
  return (
71
70
  <View style={styles.container}>
72
71
  <WrapHeaderScrollable
@@ -77,13 +76,15 @@ const MemberList = ({ route }) => {
77
76
  headerAniStyle={styles.headerAniStyle}
78
77
  styleScrollView={{ backgroundColor: Colors.White }}
79
78
  >
80
- <SharingMembers
81
- testID={TESTID.SHARING_MEMBER}
82
- dataMember={dataMembers}
83
- unit={unit}
84
- ownerId={unit.user_id}
85
- currentUserId={account.user.id}
86
- />
79
+ {!loading && (
80
+ <SharingMembers
81
+ testID={TESTID.SHARING_MEMBER}
82
+ dataMember={dataMembers}
83
+ unit={unit}
84
+ ownerId={unit.user_id}
85
+ currentUserId={account.user.id}
86
+ />
87
+ )}
87
88
  </WrapHeaderScrollable>
88
89
  <AlertAction
89
90
  visible={stateAlertSharingMenu.visible}