@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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import AddNewDevice from '../index';
6
6
  import GroupCheckBox from '../../../commons/GroupCheckBox';
@@ -11,6 +11,8 @@ import Routes from '../../../utils/Route';
11
11
  import { getTranslate } from '../../../utils/I18n';
12
12
  import { SCProvider } from '../../../context';
13
13
  import { mockSCStore } from '../../../context/mockStore';
14
+ import api from '../../../utils/Apis/axios';
15
+ import { Platform } from 'react-native';
14
16
 
15
17
  const wrapComponent = (route) => (
16
18
  <SCProvider initState={mockSCStore({})}>
@@ -18,7 +20,7 @@ const wrapComponent = (route) => (
18
20
  </SCProvider>
19
21
  );
20
22
 
21
- jest.mock('axios');
23
+ const mock = new MockAdapter(api.axiosInstance);
22
24
 
23
25
  jest.mock('react', () => {
24
26
  return { ...jest.requireActual('react'), memo: (x) => x };
@@ -42,7 +44,6 @@ describe('Test AddNewDevice', () => {
42
44
  let route;
43
45
 
44
46
  afterEach(() => {
45
- axios.get.mockClear();
46
47
  mockedNavigate.mockClear();
47
48
  });
48
49
 
@@ -78,23 +79,16 @@ describe('Test AddNewDevice', () => {
78
79
  });
79
80
 
80
81
  test('fetchDetails success', async () => {
81
- const response = {
82
- status: 200,
83
- data: {
84
- id: 1,
85
- name: 'Unit name',
86
- stations: [{ id: 2, name: 'Station name' }],
87
- },
88
- };
89
- axios.get.mockImplementation(async () => {
90
- return response;
82
+ mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, {
83
+ id: 1,
84
+ name: 'Unit name',
85
+ stations: [{ id: 2, name: 'Station name' }],
91
86
  });
92
87
 
93
88
  await act(async () => {
94
89
  tree = await create(wrapComponent(route));
95
90
  });
96
91
  const instance = tree.root;
97
- expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
98
92
 
99
93
  const groupCheckBox = instance.findByType(GroupCheckBox);
100
94
  expect(groupCheckBox.props.data).toEqual([
@@ -103,19 +97,11 @@ describe('Test AddNewDevice', () => {
103
97
  });
104
98
 
105
99
  test('fetchDetails fail', async () => {
106
- const response = {
107
- data: {},
108
- };
109
- axios.get.mockImplementation(async () => {
110
- return response;
111
- });
112
-
100
+ mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(400);
113
101
  await act(async () => {
114
102
  tree = await create(wrapComponent(route));
115
103
  });
116
104
  const instance = tree.root;
117
- expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
118
-
119
105
  const groupCheckBox = instance.findByType(GroupCheckBox);
120
106
  expect(groupCheckBox.props.data).toEqual([]);
121
107
  });
@@ -160,16 +146,10 @@ describe('Test AddNewDevice', () => {
160
146
  });
161
147
 
162
148
  test('ViewButtonBottom onRightClick with stationId', async () => {
163
- const response = {
164
- status: 200,
165
- data: {
166
- id: 1,
167
- name: 'Unit name',
168
- stations: [{ id: 2, name: 'Station name' }],
169
- },
170
- };
171
- axios.get.mockImplementation(async () => {
172
- return response;
149
+ mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, {
150
+ id: 1,
151
+ name: 'Unit name',
152
+ stations: [{ id: 2, name: 'Station name' }],
173
153
  });
174
154
 
175
155
  await act(async () => {
@@ -192,4 +172,25 @@ describe('Test AddNewDevice', () => {
192
172
  unit_name: 'Unit name',
193
173
  });
194
174
  });
175
+
176
+ test('handleOnSelect with id = -1', async () => {
177
+ Platform.OS = 'android';
178
+ mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, {
179
+ id: 1,
180
+ name: 'Unit name',
181
+ stations: [{ id: 2, name: 'Station name' }],
182
+ });
183
+
184
+ await act(async () => {
185
+ tree = await create(wrapComponent(route));
186
+ });
187
+ const instance = tree.root;
188
+
189
+ const groupCheckBox = instance.findByType(GroupCheckBox);
190
+ await act(async () => {
191
+ groupCheckBox.props.onSelect({ id: -1 }); // select stationId
192
+ });
193
+ const viewButtonBottom = instance.findByType(ViewButtonBottom);
194
+ expect(viewButtonBottom.props.rightDisabled).toBeTruthy();
195
+ });
195
196
  });
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
4
3
 
5
4
  import ConnectDevices from '../ConnectDevices';
6
5
  import { TESTID } from '../../../configs/Constants';
@@ -11,8 +10,6 @@ import { SCProvider } from '../../../context';
11
10
  import { mockSCStore } from '../../../context/mockStore';
12
11
  import { getTranslate } from '../../../utils/I18n';
13
12
 
14
- jest.mock('axios');
15
-
16
13
  const mockedNavigate = jest.fn();
17
14
  jest.mock('@react-navigation/native', () => {
18
15
  return {
@@ -34,7 +31,6 @@ describe('Test ConnectDevices', () => {
34
31
  let route;
35
32
 
36
33
  afterEach(() => {
37
- axios.get.mockClear();
38
34
  mockedNavigate.mockClear();
39
35
  });
40
36
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import { API } from '../../../configs';
6
6
  import ConnectingDevices from '../ConnectingDevices';
@@ -9,8 +9,9 @@ import Routes from '../../../utils/Route';
9
9
  import { SCProvider } from '../../../context';
10
10
  import { mockSCStore } from '../../../context/mockStore';
11
11
  import { getTranslate } from '../../../utils/I18n';
12
+ import api from '../../../utils/Apis/axios';
12
13
 
13
- jest.mock('axios');
14
+ const mock = new MockAdapter(api.axiosInstance);
14
15
 
15
16
  const mockedNavigate = jest.fn();
16
17
  jest.mock('@react-navigation/native', () => {
@@ -33,7 +34,6 @@ describe('Test ConnectingDevices', () => {
33
34
  let route;
34
35
 
35
36
  afterEach(() => {
36
- axios.get.mockClear();
37
37
  mockedNavigate.mockClear();
38
38
  });
39
39
 
@@ -62,16 +62,25 @@ describe('Test ConnectingDevices', () => {
62
62
  );
63
63
  });
64
64
 
65
- test('call setInterval api success', async () => {
66
- jest.useFakeTimers();
67
- const response = {
68
- status: 200,
69
- data: {},
70
- };
71
- axios.get.mockImplementation(async () => {
72
- return response;
65
+ test('create with out new sensor', () => {
66
+ act(() => {
67
+ tree = create(wrapComponent({}));
73
68
  });
69
+ const instance = tree.root;
70
+ const texts = instance.findAllByType(Text);
71
+ expect(texts).toHaveLength(4);
72
+ expect(texts[0].props.children).toEqual(
73
+ getTranslate('en', 'connecting_your_device')
74
+ );
75
+ expect(texts[1].props.children).toEqual(
76
+ getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
77
+ );
78
+ tree.unmount();
79
+ });
74
80
 
81
+ test('call setInterval api success', async () => {
82
+ jest.useFakeTimers();
83
+ mock.onGet(API.SENSOR.CHECK_CONNECTION(1)).reply(200);
75
84
  await act(async () => {
76
85
  tree = await create(wrapComponent(route));
77
86
  });
@@ -79,7 +88,6 @@ describe('Test ConnectingDevices', () => {
79
88
  await jest.runOnlyPendingTimers();
80
89
  });
81
90
  expect(setInterval).toHaveBeenCalled();
82
- expect(axios.get).toHaveBeenCalledWith(API.SENSOR.CHECK_CONNECTION(1), {});
83
91
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectDevices, {
84
92
  new_sensor: { id: 1 },
85
93
  });
@@ -87,14 +95,7 @@ describe('Test ConnectingDevices', () => {
87
95
 
88
96
  test('call setInterval api fail', async () => {
89
97
  jest.useFakeTimers();
90
- const response = {
91
- status: 400,
92
- data: {},
93
- };
94
- axios.get.mockImplementation(async () => {
95
- return response;
96
- });
97
-
98
+ mock.onGet(API.SENSOR.CHECK_CONNECTION(1)).reply(400);
98
99
  await act(async () => {
99
100
  tree = await create(wrapComponent(route));
100
101
  });
@@ -102,7 +103,6 @@ describe('Test ConnectingDevices', () => {
102
103
  await jest.runOnlyPendingTimers();
103
104
  });
104
105
  expect(setInterval).toHaveBeenCalled();
105
- expect(axios.get).toHaveBeenCalledWith(API.SENSOR.CHECK_CONNECTION(1), {});
106
106
  expect(mockedNavigate).not.toHaveBeenCalledWith(Routes.ConnectDevices, {
107
107
  new_sensor: { id: 1 },
108
108
  });
@@ -90,6 +90,7 @@ const AddNewDevice = memo(({ route }) => {
90
90
  <ScrollView
91
91
  style={styles.scrollContainer}
92
92
  showsVerticalScrollIndicator={false}
93
+ scrollIndicatorInsets={{ right: 1 }}
93
94
  >
94
95
  <Section type={'border'}>
95
96
  <GroupCheckBox data={stations} onSelect={handleOnSelect} />
@@ -224,7 +224,10 @@ const GatewayWifiList = memo(({ route }) => {
224
224
  {t('select_wifi')}
225
225
  </Text>
226
226
 
227
- <ScrollView style={styles.listContainer}>
227
+ <ScrollView
228
+ style={styles.listContainer}
229
+ scrollIndicatorInsets={{ right: 1 }}
230
+ >
228
231
  {!!list_wifi.length &&
229
232
  list_wifi.map((item, index) => (
230
233
  <TouchableOpacity
@@ -91,6 +91,7 @@ const AddNewGatewaySelectGateway = ({ route }) => {
91
91
  <ScrollView
92
92
  style={styles.scrollContainer}
93
93
  showsVerticalScrollIndicator={false}
94
+ scrollIndicatorInsets={{ right: 1 }}
94
95
  >
95
96
  <Section type={'border'}>
96
97
  {gateways.map((item, index) => (
@@ -147,6 +147,7 @@ const SetupGatewayWifi = memo(({ route }) => {
147
147
  <ScrollView
148
148
  style={styles.scrollContainer}
149
149
  showsVerticalScrollIndicator={false}
150
+ scrollIndicatorInsets={{ right: 1 }}
150
151
  >
151
152
  <Section type={'border'}>
152
153
  <Text style={styles.textWifi} bold color={Colors.Primary}>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import AddNewGateway from '../index';
6
6
  import GroupCheckBox from '../../../commons/GroupCheckBox';
@@ -10,6 +10,7 @@ import { TextInput } from 'react-native';
10
10
  import { getTranslate } from '../../../utils/I18n';
11
11
  import { SCProvider } from '../../../context';
12
12
  import { mockSCStore } from '../../../context/mockStore';
13
+ import api from '../../../utils/Apis/axios';
13
14
 
14
15
  const wrapComponent = (route) => (
15
16
  <SCProvider initState={mockSCStore({})}>
@@ -17,7 +18,7 @@ const wrapComponent = (route) => (
17
18
  </SCProvider>
18
19
  );
19
20
 
20
- jest.mock('axios');
21
+ const mock = new MockAdapter(api.axiosInstance);
21
22
 
22
23
  jest.mock('react', () => {
23
24
  return { ...jest.requireActual('react'), memo: (x) => x };
@@ -41,7 +42,6 @@ describe('Test AddNewGateway', () => {
41
42
  let route;
42
43
 
43
44
  afterEach(() => {
44
- axios.get.mockClear();
45
45
  mockedNavigate.mockClear();
46
46
  });
47
47
 
@@ -149,9 +149,7 @@ describe('Test AddNewGateway', () => {
149
149
  stations: [{ id: 2, name: 'Station name' }],
150
150
  },
151
151
  };
152
- axios.get.mockImplementation(async () => {
153
- return response;
154
- });
152
+ mock.onGet().reply(200, response.data);
155
153
 
156
154
  await act(async () => {
157
155
  tree = await create(wrapComponent(route));
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
4
3
 
5
4
  import { TESTID } from '../../../configs/Constants';
6
5
  import ConnectedGateway from '../ConnectedGateway';
@@ -8,8 +7,6 @@ import { SCProvider } from '../../../context';
8
7
  import { mockSCStore } from '../../../context/mockStore';
9
8
  import { getTranslate } from '../../../utils/I18n';
10
9
 
11
- jest.mock('axios');
12
-
13
10
  const mockedNavigate = jest.fn();
14
11
  jest.mock('@react-navigation/native', () => {
15
12
  return {
@@ -31,7 +28,6 @@ describe('Test ConnectedGateway', () => {
31
28
  let route;
32
29
 
33
30
  afterEach(() => {
34
- axios.get.mockClear();
35
31
  mockedNavigate.mockClear();
36
32
  });
37
33
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
3
+ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import ConnectingGateway from '../ConnectingGateway';
6
6
  import Text from '../../../commons/Text';
@@ -9,8 +9,9 @@ import Routes from '../../../utils/Route';
9
9
  import { getTranslate } from '../../../utils/I18n';
10
10
  import { SCProvider } from '../../../context';
11
11
  import { mockSCStore } from '../../../context/mockStore';
12
+ import api from '../../../utils/Apis/axios';
12
13
 
13
- jest.mock('axios');
14
+ const mock = new MockAdapter(api.axiosInstance);
14
15
 
15
16
  const mockedNavigate = jest.fn();
16
17
  jest.mock('@react-navigation/native', () => {
@@ -33,7 +34,6 @@ describe('Test ConnectingGateway', () => {
33
34
  let route;
34
35
 
35
36
  afterEach(() => {
36
- axios.get.mockClear();
37
37
  mockedNavigate.mockClear();
38
38
  });
39
39
 
@@ -64,14 +64,7 @@ describe('Test ConnectingGateway', () => {
64
64
 
65
65
  test('call setInterval api success', async () => {
66
66
  jest.useFakeTimers();
67
- const response = {
68
- status: 200,
69
- data: {},
70
- };
71
- axios.get.mockImplementation(async () => {
72
- return response;
73
- });
74
-
67
+ mock.onGet(API.CHIP.CHECK_FINALIZED()).reply(200, {});
75
68
  await act(async () => {
76
69
  tree = await create(wrapComponent(route));
77
70
  });
@@ -79,11 +72,6 @@ describe('Test ConnectingGateway', () => {
79
72
  await jest.runOnlyPendingTimers();
80
73
  });
81
74
  expect(setInterval).toHaveBeenCalled();
82
- expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED(), {
83
- params: {
84
- chip_id: 1,
85
- },
86
- });
87
75
  expect(mockedNavigate).not.toHaveBeenCalledWith(
88
76
  Routes.ConnectedGateway,
89
77
  route.params
@@ -92,14 +80,7 @@ describe('Test ConnectingGateway', () => {
92
80
 
93
81
  test('call setInterval api fail', async () => {
94
82
  jest.useFakeTimers();
95
- const response = {
96
- status: 400,
97
- data: {},
98
- };
99
- axios.get.mockImplementation(async () => {
100
- return response;
101
- });
102
-
83
+ mock.onGet(API.CHIP.CHECK_FINALIZED()).reply(400);
103
84
  await act(async () => {
104
85
  tree = await create(wrapComponent(route));
105
86
  });
@@ -107,11 +88,6 @@ describe('Test ConnectingGateway', () => {
107
88
  await jest.runOnlyPendingTimers();
108
89
  });
109
90
  expect(setInterval).toHaveBeenCalled();
110
- expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED(), {
111
- params: {
112
- chip_id: 1,
113
- },
114
- });
115
91
  expect(mockedNavigate).not.toHaveBeenCalledWith(
116
92
  Routes.ConnectedGateway,
117
93
  route.params
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
4
3
 
5
4
  import AddNewGatewaySelectGateway from '../SelectGateway';
6
5
  import { SCProvider } from '../../../context';
@@ -13,8 +12,6 @@ const wrapComponent = (route) => (
13
12
  </SCProvider>
14
13
  );
15
14
 
16
- jest.mock('axios');
17
-
18
15
  jest.mock('react', () => {
19
16
  return { ...jest.requireActual('react'), memo: (x) => x };
20
17
  });
@@ -38,7 +35,6 @@ describe('Test AddNewGatewaySelectGateway', () => {
38
35
  let route;
39
36
 
40
37
  afterEach(() => {
41
- axios.get.mockClear();
42
38
  mockedNavigate.mockClear();
43
39
  });
44
40
 
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import axios from 'axios';
4
3
 
5
4
  import { TESTID } from '../../../configs/Constants';
6
5
  import { SCProvider } from '../../../context';
@@ -16,8 +15,6 @@ const wrapComponent = (route) => (
16
15
  </SCProvider>
17
16
  );
18
17
 
19
- jest.mock('axios');
20
-
21
18
  jest.mock('react', () => {
22
19
  return { ...jest.requireActual('react'), memo: (x) => x };
23
20
  });
@@ -59,7 +56,6 @@ describe('Test SetupGatewayWifi', () => {
59
56
  let route;
60
57
 
61
58
  afterEach(() => {
62
- axios.get.mockClear();
63
59
  mockedNavigate.mockClear();
64
60
  });
65
61
 
@@ -75,6 +75,7 @@ const AddNewGateway = memo(({ route }) => {
75
75
  <ScrollView
76
76
  style={styles.scrollContainer}
77
77
  showsVerticalScrollIndicator={false}
78
+ scrollIndicatorInsets={{ right: 1 }}
78
79
  >
79
80
  <Section type={'border'}>
80
81
  {!wifiName && (
@@ -1,5 +1,5 @@
1
- import axios from 'axios';
2
1
  import React from 'react';
2
+ import MockAdapter from 'axios-mock-adapter';
3
3
  import { Platform, TextInput, TouchableOpacity } from 'react-native';
4
4
  import { act, create } from 'react-test-renderer';
5
5
 
@@ -9,13 +9,15 @@ import { SCProvider } from '../../../context';
9
9
  import { mockSCStore } from '../../../context/mockStore';
10
10
  import Routes from '../../../utils/Route';
11
11
  import { HeaderCustom } from '../../../commons/Header';
12
+ import api from '../../../utils/Apis/axios';
13
+ import { API } from '../../../configs';
12
14
 
13
15
  const wrapComponent = (route) => (
14
16
  <SCProvider initState={mockSCStore({})}>
15
17
  <AddNewOneTap route={route} />
16
18
  </SCProvider>
17
19
  );
18
- jest.mock('axios');
20
+ const mock = new MockAdapter(api.axiosInstance);
19
21
 
20
22
  jest.mock('react-redux', () => {
21
23
  return {
@@ -41,14 +43,13 @@ jest.mock('react', () => {
41
43
  };
42
44
  });
43
45
 
44
- jest.mock('axios');
45
46
  let tree;
46
47
 
47
48
  describe('test AddNewOneTap', () => {
48
49
  beforeEach(() => {
49
- axios.post.mockClear();
50
50
  mockedNavigate.mockClear();
51
51
  });
52
+
52
53
  test('create AddNewOneTap success', async () => {
53
54
  Platform.OS = 'ios';
54
55
  let route = {
@@ -71,9 +72,7 @@ describe('test AddNewOneTap', () => {
71
72
  },
72
73
  };
73
74
 
74
- axios.post.mockImplementation(async () => {
75
- return response;
76
- });
75
+ mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(200, response.data);
77
76
 
78
77
  await act(async () => {
79
78
  tree = await create(wrapComponent(route));
@@ -100,19 +99,14 @@ describe('test AddNewOneTap', () => {
100
99
  await item[0].props.onPress();
101
100
  });
102
101
  });
102
+
103
103
  test('create AddNewOneTap fail', async () => {
104
104
  Platform.OS = 'android';
105
105
  let route = {
106
106
  params: { type: 'one_tap' },
107
107
  };
108
108
 
109
- const response = {
110
- status: 400,
111
- };
112
-
113
- axios.post.mockImplementation(async () => {
114
- return response;
115
- });
109
+ mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(400);
116
110
 
117
111
  await act(async () => {
118
112
  tree = await create(wrapComponent(route));
@@ -144,15 +138,7 @@ describe('test AddNewOneTap', () => {
144
138
  isAutomateTab: false,
145
139
  },
146
140
  };
147
-
148
- const response = {
149
- status: 400,
150
- };
151
-
152
- axios.post.mockImplementation(async () => {
153
- return response;
154
- });
155
-
141
+ mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(400);
156
142
  await act(async () => {
157
143
  tree = await create(wrapComponent(route));
158
144
  });
@@ -165,7 +151,7 @@ describe('test AddNewOneTap', () => {
165
151
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
166
152
  id: 1,
167
153
  name: 'script test',
168
- type: 'one_tap',
154
+ type: undefined,
169
155
  havePermission: true,
170
156
  unit: { id: 1 },
171
157
  isMultiUnits: false,
@@ -25,6 +25,7 @@ const AddNewOneTap = memo(({ route }) => {
25
25
  isMultiUnits,
26
26
  automateId,
27
27
  scriptName,
28
+ oldType,
28
29
  } = route.params;
29
30
  const t = useTranslations();
30
31
  const { navigate, dispatch, goBack } = useNavigation();
@@ -91,7 +92,7 @@ const AddNewOneTap = memo(({ route }) => {
91
92
  navigate(Routes.ScriptDetail, {
92
93
  id: automateId,
93
94
  name: scriptName,
94
- type: type,
95
+ type: oldType,
95
96
  havePermission: true,
96
97
  unit,
97
98
  isMultiUnits,
@@ -120,7 +121,7 @@ const AddNewOneTap = memo(({ route }) => {
120
121
  }
121
122
  >
122
123
  <HeaderCustom isShowClose onClose={onClose} />
123
- <ScrollView>
124
+ <ScrollView scrollIndicatorInsets={{ right: 1 }}>
124
125
  <Text
125
126
  testID={TESTID.ADD_NEW_DEVICE_ADD}
126
127
  semibold
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
- import axios from 'axios';
4
+ import MockAdapter from 'axios-mock-adapter';
5
5
  import { useRoute } from '@react-navigation/native';
6
6
 
7
7
  import MultiUnits from '../MultiUnits';
@@ -13,8 +13,10 @@ import Routes from '../../../utils/Route';
13
13
  import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
14
14
  import { getTranslate } from '../../../utils/I18n';
15
15
  import { AUTOMATE_TYPE } from '../../../configs/Constants';
16
+ import api from '../../../utils/Apis/axios';
17
+ import { API } from '../../../configs';
16
18
 
17
- jest.mock('axios');
19
+ const mock = new MockAdapter(api.axiosInstance);
18
20
  const mockedNavigate = jest.fn();
19
21
  const mockSetState = jest.fn();
20
22
 
@@ -47,7 +49,6 @@ describe('Test MultiUnits', () => {
47
49
  let tree;
48
50
 
49
51
  beforeEach(() => {
50
- axios.get.mockClear();
51
52
  mockedNavigate.mockClear();
52
53
  mockSetState.mockClear();
53
54
  useRoute.mockClear();
@@ -93,9 +94,7 @@ describe('Test MultiUnits', () => {
93
94
  },
94
95
  ],
95
96
  };
96
- await axios.get.mockImplementation(async () => {
97
- return response;
98
- });
97
+ mock.onGet(API.AUTOMATE.GET_MULTI_UNITS()).reply(200, response.data);
99
98
  useRoute.mockReturnValue({
100
99
  params: {
101
100
  isMultiUnits: true,
@@ -189,9 +188,7 @@ describe('Test MultiUnits', () => {
189
188
  },
190
189
  ],
191
190
  };
192
- await axios.get.mockImplementation(async () => {
193
- return response;
194
- });
191
+ mock.onGet(API.AUTOMATE.GET_MULTI_UNITS()).reply(200, response.data);
195
192
  useRoute.mockReturnValue({
196
193
  params: {
197
194
  isMultiUnits: true,