@eohjsc/react-native-smart-city 0.3.4 → 0.3.7

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 (293) hide show
  1. package/README.md +15 -36
  2. package/package.json +5 -9
  3. package/react-native-smart-city.podspec +0 -1
  4. package/src/commons/Action/ItemQuickAction.js +4 -16
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
  8. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
  9. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
  14. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  15. package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
  16. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
  17. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
  18. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
  19. package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
  20. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
  21. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
  22. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
  23. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
  24. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  25. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
  26. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
  27. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
  28. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
  29. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
  30. package/src/commons/ActionGroup/__test__/index.test.js +4 -142
  31. package/src/commons/Auth/AccountList.js +1 -1
  32. package/src/commons/Automate/ItemAutomate.js +3 -1
  33. package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
  34. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
  35. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
  36. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
  37. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
  38. package/src/commons/ConnectingProcess/index.js +25 -75
  39. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
  40. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  41. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
  42. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  43. package/src/commons/Device/HistoryChart.js +3 -7
  44. package/src/commons/Device/ItemDevice.js +12 -19
  45. package/src/commons/Device/LinearChart.js +0 -15
  46. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
  47. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
  48. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  49. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
  50. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
  51. package/src/commons/Explore/__test__/CityItem.test.js +54 -33
  52. package/src/commons/Form/CurrencyInput.js +1 -15
  53. package/src/commons/Form/TextInputPassword.js +1 -1
  54. package/src/commons/FullLoading/index.js +1 -2
  55. package/src/commons/Header/HeaderCustom.js +1 -2
  56. package/src/commons/HeaderAni/index.js +1 -6
  57. package/src/commons/HorizontalPicker/index.js +2 -2
  58. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
  59. package/src/commons/MediaPlayerDetail/index.js +47 -25
  60. package/src/commons/MenuActionAddnew/index.js +0 -1
  61. package/src/commons/MenuActionList/index.js +0 -1
  62. package/src/commons/MenuActionMore/index.js +1 -1
  63. package/src/commons/PreventAccess/index.js +1 -9
  64. package/src/commons/Sharing/MemberList.js +2 -10
  65. package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
  66. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
  67. package/src/commons/SubUnit/Favorites/index.js +3 -2
  68. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
  69. package/src/commons/SubUnit/OneTap/index.js +2 -1
  70. package/src/commons/SubUnit/ShortDetail.js +9 -25
  71. package/src/commons/SubUnit/__test__/Item.test.js +1 -0
  72. package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
  73. package/src/commons/Unit/SharedUnit.js +0 -1
  74. package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
  75. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
  76. package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
  77. package/src/commons/WheelDateTimePicker/index.js +3 -4
  78. package/src/configs/API.js +143 -87
  79. package/src/configs/Constants.js +2 -57
  80. package/src/configs/SCConfig.js +0 -4
  81. package/src/context/actionType.ts +0 -8
  82. package/src/context/mockStore.ts +0 -10
  83. package/src/context/reducer.ts +2 -38
  84. package/src/hooks/Common/index.js +0 -2
  85. package/src/hooks/Common/useGetIdUser.js +5 -1
  86. package/src/hooks/Common/useSensorsStatus.js +4 -4
  87. package/src/hooks/useReceiveNotifications.js +5 -9
  88. package/src/iot/Monitor.js +2 -3
  89. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  90. package/src/iot/RemoteControl/GoogleHome.js +49 -75
  91. package/src/iot/RemoteControl/Internet.js +1 -1
  92. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
  93. package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
  94. package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
  95. package/src/iot/RemoteControl/index.js +52 -52
  96. package/src/navigations/UnitStack.js +20 -11
  97. package/src/screens/AQIGuide/index.js +1 -1
  98. package/src/screens/ActivityLog/FilterPopup.js +0 -2
  99. package/src/screens/ActivityLog/__test__/index.test.js +23 -38
  100. package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
  101. package/src/screens/ActivityLog/hooks/index.js +1 -1
  102. package/src/screens/ActivityLog/index.js +2 -2
  103. package/src/screens/AddCommon/SelectSubUnit.js +0 -1
  104. package/src/screens/AddCommon/SelectUnit.js +0 -1
  105. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
  106. package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
  107. package/src/screens/AddLocationMaps/index.js +5 -9
  108. package/src/screens/AddNewAction/SelectAction.js +8 -8
  109. package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
  110. package/src/screens/AddNewAction/SetupSensor.js +7 -7
  111. package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
  112. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
  113. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
  114. package/src/screens/AddNewAutoSmart/index.js +2 -5
  115. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  116. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
  117. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
  118. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  119. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  120. package/src/screens/AddNewDevice/index.js +0 -1
  121. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
  122. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
  123. package/src/screens/AddNewGateway/SelectGateway.js +0 -1
  124. package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
  125. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
  126. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
  127. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
  128. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
  129. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
  130. package/src/screens/AddNewGateway/index.js +0 -1
  131. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
  132. package/src/screens/AddNewOneTap/index.js +2 -3
  133. package/src/screens/AllCamera/index.js +4 -4
  134. package/src/screens/Automate/MultiUnits.js +8 -8
  135. package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
  136. package/src/screens/Automate/__test__/index.test.js +12 -7
  137. package/src/screens/Automate/index.js +3 -5
  138. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
  139. package/src/screens/ConfirmUnitDeletion/index.js +1 -7
  140. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
  141. package/src/screens/Device/EditDevice/index.js +15 -17
  142. package/src/screens/Device/__test__/detail.test.js +86 -33
  143. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  144. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
  145. package/src/screens/Device/components/SensorDisplayItem.js +2 -5
  146. package/src/screens/Device/detail.js +24 -80
  147. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  148. package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
  149. package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
  150. package/src/screens/EditActionsList/index.js +1 -1
  151. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
  152. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
  153. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
  154. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
  155. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  156. package/src/screens/EmergencySetting/index.js +1 -4
  157. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
  158. package/src/screens/Explore/index.js +0 -2
  159. package/src/screens/GuestInfo/__test__/index.test.js +41 -14
  160. package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
  161. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  162. package/src/screens/HanetCamera/Detail.js +1 -1
  163. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +12 -8
  164. package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
  165. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
  166. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
  167. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
  168. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
  169. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
  170. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  171. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  172. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +22 -33
  173. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
  174. package/src/screens/ManageAccess/hooks/index.js +4 -7
  175. package/src/screens/ManageAccess/index.js +1 -2
  176. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
  177. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  178. package/src/screens/Notification/__test__/Notification.test.js +25 -14
  179. package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
  180. package/src/screens/Notification/components/NotificationItem.js +20 -17
  181. package/src/screens/Notification/index.js +2 -9
  182. package/src/screens/PlayBackCamera/Timer.js +2 -2
  183. package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
  184. package/src/screens/PlayBackCamera/index.js +6 -22
  185. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
  186. package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
  187. package/src/screens/ScanChipQR/hooks/index.js +16 -15
  188. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
  189. package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
  190. package/src/screens/ScriptDetail/index.js +14 -19
  191. package/src/screens/SelectUnit/__test__/index.test.js +55 -12
  192. package/src/screens/SelectUnit/index.js +4 -9
  193. package/src/screens/SetSchedule/index.js +11 -15
  194. package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
  195. package/src/screens/SharedUnit/index.js +0 -2
  196. package/src/screens/Sharing/Components/SensorItem.js +12 -10
  197. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  198. package/src/screens/Sharing/MemberList.js +11 -12
  199. package/src/screens/Sharing/SelectPermission.js +76 -121
  200. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
  201. package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
  202. package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
  203. package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
  204. package/src/screens/Sharing/hooks/index.js +0 -3
  205. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
  206. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  207. package/src/screens/SubUnit/AddSubUnit.js +17 -23
  208. package/src/screens/SubUnit/Detail.js +2 -1
  209. package/src/screens/SubUnit/EditSubUnit.js +13 -15
  210. package/src/screens/SubUnit/ManageSubUnit.js +7 -13
  211. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
  212. package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
  213. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
  214. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
  215. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
  216. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  217. package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
  218. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
  219. package/src/screens/TDSGuide/index.js +1 -4
  220. package/src/screens/UVIndexGuide/index.js +1 -1
  221. package/src/screens/Unit/ChooseLocation.js +14 -7
  222. package/src/screens/Unit/Detail.js +75 -30
  223. package/src/screens/Unit/ManageUnit.js +0 -1
  224. package/src/screens/Unit/SelectAddress.js +23 -45
  225. package/src/screens/Unit/SmartAccount.js +4 -4
  226. package/src/screens/Unit/Station/index.js +0 -4
  227. package/src/screens/Unit/Summaries.js +2 -18
  228. package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
  229. package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
  230. package/src/screens/Unit/__test__/Detail.test.js +200 -99
  231. package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
  232. package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
  233. package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
  234. package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
  235. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  236. package/src/screens/Unit/components/SharedUnit/index.js +0 -1
  237. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  238. package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
  239. package/src/screens/Unit/styles.js +0 -4
  240. package/src/screens/UnitSummary/__test__/index.test.js +30 -91
  241. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
  242. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
  243. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
  244. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
  245. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
  246. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
  247. package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
  248. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  249. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
  250. package/src/screens/UnitSummary/index.js +1 -15
  251. package/src/screens/WaterQualityGuide/index.js +1 -1
  252. package/src/utils/Apis/axios.js +31 -54
  253. package/src/utils/Converter/time.js +18 -0
  254. package/src/utils/I18n/translations/en.json +1 -7
  255. package/src/utils/I18n/translations/vi.json +1 -8
  256. package/src/utils/Route/index.js +0 -1
  257. package/src/utils/Utils.js +7 -11
  258. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
  259. package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
  260. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
  261. package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
  262. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
  263. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
  264. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
  265. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
  266. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
  267. package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
  268. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
  269. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
  270. package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
  271. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
  272. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
  273. package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
  274. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
  275. package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
  276. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
  277. package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
  278. package/src/hooks/IoT/index.js +0 -4
  279. package/src/hooks/IoT/useGGHomeConnection.js +0 -91
  280. package/src/hooks/IoT/useRemoteControl.js +0 -79
  281. package/src/hooks/index.js +0 -4
  282. package/src/navigations/UnitStackStyles.js +0 -21
  283. package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
  284. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
  285. package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
  286. package/src/screens/SideMenuDetail/index.js +0 -148
  287. package/src/screens/Unit/__test__/Summaries.test.js +0 -100
  288. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  289. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  290. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
  291. package/src/utils/Permission/common.js +0 -67
  292. package/src/utils/Setting/Location.js +0 -30
  293. package/src/utils/__test__/Utils.test.js +0 -12
@@ -1,14 +1,12 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
3
+ import axios from 'axios';
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';
12
10
 
13
11
  const wrapComponent = (route) => (
14
12
  <SCProvider initState={mockSCStore({})}>
@@ -19,7 +17,7 @@ const wrapComponent = (route) => (
19
17
  const mockedNavigate = jest.fn();
20
18
  const mockedGoBack = jest.fn();
21
19
 
22
- const mock = new MockAdapter(api.axiosInstance);
20
+ jest.mock('axios');
23
21
 
24
22
  jest.mock('react', () => {
25
23
  return { ...jest.requireActual('react'), memo: (x) => x };
@@ -50,6 +48,10 @@ describe('test ScanChipQR', () => {
50
48
  };
51
49
  });
52
50
 
51
+ afterEach(() => {
52
+ axios.get.mockClear();
53
+ });
54
+
53
55
  test('create ScanChipQR', async () => {
54
56
  let tree;
55
57
  await act(async () => {
@@ -66,8 +68,13 @@ describe('test ScanChipQR', () => {
66
68
  id: 1,
67
69
  name: 'ABC',
68
70
  };
69
-
70
- mock.onPost(API.UNIT.CHIP_SCAN_GET_WIFI_INFO()).reply(200, new_chip);
71
+ const response = {
72
+ status: 200,
73
+ data: new_chip,
74
+ };
75
+ axios.post.mockImplementation(async () => {
76
+ return response;
77
+ });
71
78
 
72
79
  let tree;
73
80
  const body = { id: 1, imei: 'SENSOR-X341241', name: 'New Chip' };
@@ -97,7 +104,13 @@ describe('test ScanChipQR', () => {
97
104
  id: 1,
98
105
  name: 'ABC',
99
106
  };
100
- mock.onPost(API.UNIT.CHIP_SCAN_GET_WIFI_INFO()).reply(200, new_chip);
107
+ const response = {
108
+ data: new_chip,
109
+ };
110
+ axios.post.mockImplementation(async () => {
111
+ return response;
112
+ });
113
+
101
114
  let tree;
102
115
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
103
116
  await act(async () => {
@@ -160,7 +160,6 @@ const styles = StyleSheet.create({
160
160
  position: 'absolute',
161
161
  top: getStatusBarHeight(true) + 16,
162
162
  left: 16,
163
- zIndex: 10,
164
163
  },
165
164
  viewVerifing: {
166
165
  marginLeft: 16,
@@ -3,7 +3,6 @@ import API from '../../../configs/API';
3
3
  import { useCallback, useState } from 'react';
4
4
  import { axiosPost } from '../../../utils/Apis/axios';
5
5
  import Routes from '../../../utils/Route';
6
- import { ToastBottomHelper } from '../../../utils/Utils';
7
6
 
8
7
  const useChipScan = (route) => {
9
8
  const {
@@ -49,26 +48,28 @@ const useChipScan = (route) => {
49
48
  }
50
49
  );
51
50
  if (success) {
52
- navigation.navigate(Routes.ConnectWifiWarning, {
53
- wifi_ssid: new_chip.wifi_ssid,
54
- wifi_pass: new_chip.wifi_pass,
55
- chip_id: new_chip.id,
56
- unit_id: unit_id,
57
- unit_name: unit_name,
58
- devicePrefixName,
59
- body,
60
- });
51
+ if (new_chip.is_wifi) {
52
+ navigation.navigate(Routes.ConnectWifiWarning, {
53
+ wifi_ssid: new_chip.wifi_ssid,
54
+ wifi_pass: new_chip.wifi_pass,
55
+ chip_id: new_chip.id,
56
+ unit_id: unit_id,
57
+ unit_name: unit_name,
58
+ devicePrefixName,
59
+ body,
60
+ });
61
+ } else {
62
+ navigation.navigate(Routes.ConnectingGateway, {
63
+ new_chip,
64
+ ...route.params,
65
+ });
66
+ }
61
67
  } else {
62
- ToastBottomHelper.error(
63
- 'Fail to fetch wifi info',
64
- devicePrefixName
65
- );
66
68
  navigation.goBack();
67
69
  }
68
70
  }
69
71
  break;
70
72
  default:
71
- ToastBottomHelper.error('Invalid QR prefix', devicePrefixName);
72
73
  navigation.goBack();
73
74
  break;
74
75
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
3
+ import axios from 'axios';
4
4
 
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
@@ -8,7 +8,6 @@ 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';
12
11
 
13
12
  const wrapComponent = (route) => (
14
13
  <SCProvider initState={mockSCStore({})}>
@@ -16,11 +15,11 @@ const wrapComponent = (route) => (
16
15
  </SCProvider>
17
16
  );
18
17
 
19
- const mock = new MockAdapter(api.axiosInstance);
20
-
21
18
  const mockedNavigate = jest.fn();
22
19
  const mockedGoBack = jest.fn();
23
20
 
21
+ jest.mock('axios');
22
+
24
23
  jest.mock('react', () => {
25
24
  return { ...jest.requireActual('react'), memo: (x) => x };
26
25
  });
@@ -49,6 +48,10 @@ describe('test ScanSensorQR', () => {
49
48
  };
50
49
  });
51
50
 
51
+ afterEach(() => {
52
+ axios.get.mockClear();
53
+ });
54
+
52
55
  test('create ScanSensorQR', async () => {
53
56
  let tree;
54
57
  await act(async () => {
@@ -65,8 +68,13 @@ describe('test ScanSensorQR', () => {
65
68
  id: 1,
66
69
  name: 'ABC',
67
70
  };
68
-
69
- mock.onPost(API.SUB_UNIT.SENSOR_SCAN(1)).reply(200, new_sensor);
71
+ const response = {
72
+ status: 200,
73
+ data: new_sensor,
74
+ };
75
+ axios.post.mockImplementation(async () => {
76
+ return response;
77
+ });
70
78
 
71
79
  let tree;
72
80
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
@@ -80,6 +88,7 @@ describe('test ScanSensorQR', () => {
80
88
  qrScan.props.onScan(JSON.stringify(body));
81
89
  });
82
90
  expect(qrScan.props.loading).toEqual(true);
91
+ expect(axios.post).toHaveBeenCalledWith(API.SUB_UNIT.SENSOR_SCAN(1), body);
83
92
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectingDevices, {
84
93
  new_sensor,
85
94
  station_id: 1,
@@ -93,7 +102,13 @@ describe('test ScanSensorQR', () => {
93
102
  id: 1,
94
103
  name: 'ABC',
95
104
  };
96
- mock.onPost(API.SUB_UNIT.SENSOR_SCAN(1)).reply(200, new_chip);
105
+ const response = {
106
+ data: new_chip,
107
+ };
108
+ axios.post.mockImplementation(async () => {
109
+ return response;
110
+ });
111
+
97
112
  let tree;
98
113
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
99
114
  await act(async () => {
@@ -106,6 +121,7 @@ describe('test ScanSensorQR', () => {
106
121
  qrScan.props.onScan(JSON.stringify(body));
107
122
  });
108
123
  expect(qrScan.props.loading).toEqual(true);
109
- expect(mockedGoBack).not.toHaveBeenCalled();
124
+ expect(axios.post).toHaveBeenCalledWith(API.SUB_UNIT.SENSOR_SCAN(1), body);
125
+ expect(mockedGoBack).toHaveBeenCalled();
110
126
  });
111
127
  });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
3
+ import axios from 'axios';
4
4
  import { SCProvider } from '../../../context';
5
5
  import { mockSCStore } from '../../../context/mockStore';
6
6
  import ScriptDetail from '..';
@@ -17,7 +17,6 @@ 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';
21
20
 
22
21
  const wrapComponent = (route) => (
23
22
  <SCProvider initState={mockSCStore({})}>
@@ -44,7 +43,7 @@ jest.mock('@react-navigation/native', () => {
44
43
  };
45
44
  });
46
45
 
47
- const mock = new MockAdapter(api.axiosInstance);
46
+ jest.mock('axios');
48
47
 
49
48
  describe('Test ScriptDetail', () => {
50
49
  let route;
@@ -52,6 +51,10 @@ describe('Test ScriptDetail', () => {
52
51
  let tree;
53
52
 
54
53
  beforeEach(() => {
54
+ axios.get.mockClear();
55
+ axios.patch.mockClear();
56
+ axios.delete.mockClear();
57
+ axios.post.mockClear();
55
58
  mockGoBack.mockClear();
56
59
  route = {
57
60
  params: {
@@ -110,10 +113,22 @@ describe('Test ScriptDetail', () => {
110
113
  await act(async () => {
111
114
  textInput.props.onChange('new_name');
112
115
  });
113
- mock.onPatch(API.AUTOMATE.SCRIPT(1)).reply(200, { name: 'new_name' });
116
+
117
+ const response = {
118
+ status: 200,
119
+ data: {
120
+ name: 'new_name',
121
+ },
122
+ };
123
+ axios.patch.mockImplementation(async () => {
124
+ return response;
125
+ });
114
126
  await act(async () => {
115
127
  await alertAction.props.rightButtonClick();
116
128
  });
129
+ expect(axios.patch).toHaveBeenCalledWith(API.AUTOMATE.SCRIPT(1), {
130
+ name: 'new_name',
131
+ });
117
132
  expect(alertAction.props.visible).toBeFalsy();
118
133
  });
119
134
 
@@ -131,10 +146,15 @@ describe('Test ScriptDetail', () => {
131
146
  await menu.props.hideComplete();
132
147
  });
133
148
  expect(alertAction.props.visible).toBeTruthy();
134
- mock.onDelete(API.AUTOMATE.SCRIPT(1)).reply(204);
149
+
150
+ const response = { status: 204 };
151
+ axios.delete.mockImplementation(async () => {
152
+ return response;
153
+ });
135
154
  await act(async () => {
136
155
  await alertAction.props.rightButtonClick();
137
156
  });
157
+ expect(axios.delete).toHaveBeenCalledWith(API.AUTOMATE.SCRIPT(1));
138
158
  expect(alertAction.props.visible).toBeFalsy();
139
159
  expect(mockGoBack).toHaveBeenCalled();
140
160
  });
@@ -147,30 +167,62 @@ describe('Test ScriptDetail', () => {
147
167
  const buttonStar = instance.find(
148
168
  (el) => el.props.testID === TESTID.HEADER_DEVICE_BUTTON_STAR
149
169
  );
150
- mock.onPost(API.AUTOMATE.STAR_SCRIPT(1)).reply(200);
170
+
171
+ axios.post.mockImplementation(async () => {
172
+ return { status: 200 };
173
+ });
151
174
  await act(async () => {
152
175
  await buttonStar.props.onPress();
153
176
  });
154
- mock.onPost(API.AUTOMATE.UNSTAR_SCRIPT(1)).reply(204);
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
+ });
155
185
  await act(async () => {
156
186
  await buttonStar.props.onPress();
157
187
  });
188
+ expect(axios.post).toHaveBeenCalledWith(
189
+ API.AUTOMATE.UNSTAR_SCRIPT(route.params.automate.id)
190
+ );
191
+
158
192
  const menu = instance.findByType(MenuActionMore);
159
193
  const addFavorite = menu.props.listMenuItem[1];
160
- mock.onPost(API.AUTOMATE.STAR_SCRIPT(1)).reply(200);
194
+ axios.post.mockClear();
195
+ axios.post.mockImplementation(async () => {
196
+ return { status: 200 };
197
+ });
161
198
  await act(async () => {
162
199
  await menu.props.onItemClick(addFavorite);
163
200
  });
201
+ expect(axios.post).toHaveBeenCalledWith(
202
+ API.AUTOMATE.STAR_SCRIPT(route.params.automate.id)
203
+ );
204
+
164
205
  const removeFavorite = menu.props.listMenuItem[1];
165
- mock.onPost(API.AUTOMATE.UNSTAR_SCRIPT(1)).reply(204);
206
+ axios.post.mockClear();
207
+ axios.post.mockImplementation(async () => {
208
+ return { status: 204 };
209
+ });
166
210
  await act(async () => {
167
211
  await menu.props.onItemClick(removeFavorite);
168
212
  });
169
- expect(mockGoBack).not.toHaveBeenCalled();
213
+ expect(axios.post).toHaveBeenCalledWith(
214
+ API.AUTOMATE.UNSTAR_SCRIPT(route.params.automate.id)
215
+ );
170
216
  });
171
217
 
172
218
  test('test activate one tap', async () => {
173
- mock.onGet(API.AUTOMATE.SCRIPT(1)).reply(200, data);
219
+ const response = {
220
+ status: 200,
221
+ data: data,
222
+ };
223
+ axios.get.mockImplementation(async () => {
224
+ return response;
225
+ });
174
226
  await act(() => {
175
227
  tree = create(wrapComponent(route));
176
228
  });
@@ -180,15 +232,24 @@ describe('Test ScriptDetail', () => {
180
232
  el.props.testID === TESTID.BUTTON_ACTIVATE_ONE_TAP &&
181
233
  el.type === TouchableOpacity
182
234
  );
183
- mock.onPost(API.AUTOMATE.ACTION_ONE_TAP(1)).reply(200);
235
+
236
+ axios.post.mockImplementation(async () => {
237
+ return { status: 200 };
238
+ });
184
239
  await act(async () => {
185
240
  await buttonActivate.props.onPress();
186
241
  });
187
- expect(mockNavigate).not.toBeCalled();
242
+ expect(axios.post).toHaveBeenCalledWith(API.AUTOMATE.ACTION_ONE_TAP(1));
188
243
  });
189
244
 
190
245
  test('test press add action', async () => {
191
- mock.onGet(API.AUTOMATE.SCRIPT(1)).reply(200, data);
246
+ const response = {
247
+ status: 200,
248
+ data: data,
249
+ };
250
+ axios.get.mockImplementation(async () => {
251
+ return response;
252
+ });
192
253
  await act(() => {
193
254
  tree = create(wrapComponent(route));
194
255
  });
@@ -206,9 +267,8 @@ describe('Test ScriptDetail', () => {
206
267
  automateId: route.params.id,
207
268
  isCreateNewAction: true,
208
269
  scriptName: route.params.name,
209
- title: AUTOMATE_SELECT.SELECT_DEVICE,
270
+ title: AUTOMATE_SELECT.SELECT_DEVICES,
210
271
  type: AUTOMATE_TYPE.ONE_TAP,
211
- oldType: AUTOMATE_TYPE.ONE_TAP,
212
272
  automate: route.params.automate,
213
273
  });
214
274
  });
@@ -224,7 +284,16 @@ describe('Test ScriptDetail', () => {
224
284
  await act(async () => {
225
285
  await WrapHeaderScrollables[0].props.onGoBack();
226
286
  });
227
- expect(mockNavigate).toBeCalled();
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
+ });
228
297
  });
229
298
 
230
299
  const _testGoToActivityLog = (automateType, activityLogType, isMultiUnit) => {
@@ -179,10 +179,8 @@ const ScriptDetail = ({ route }) => {
179
179
  }, []);
180
180
 
181
181
  const getScriptDetail = useCallback(async () => {
182
- const { success, data: automateData } = await axiosGet(
183
- API.AUTOMATE.SCRIPT(id)
184
- );
185
- success && setData(automateData?.script_actions || []);
182
+ const { success, data } = await axiosGet(API.AUTOMATE.SCRIPT(id));
183
+ success && setData(data?.script_actions || []);
186
184
  }, [id]);
187
185
 
188
186
  const onPressEdit = useCallback(() => {
@@ -191,19 +189,18 @@ const ScriptDetail = ({ route }) => {
191
189
  }, [data]);
192
190
 
193
191
  const onPressAddAction = useCallback(() => {
194
- const navParams = {
192
+ const params = {
195
193
  unit,
196
194
  scriptName,
197
195
  automateId: id,
198
196
  type,
199
- oldType: type,
200
197
  isCreateNewAction: true,
201
- title: AUTOMATE_SELECT.SELECT_DEVICE,
198
+ title: AUTOMATE_SELECT.SELECT_DEVICES,
202
199
  automate,
203
200
  };
204
201
  navigate(
205
202
  isMultiUnits ? Routes.SelectUnit : Routes.SelectSensorDevices,
206
- navParams
203
+ params
207
204
  );
208
205
  }, [unit, scriptName, id, type, navigate, isMultiUnits, automate]);
209
206
 
@@ -361,21 +358,21 @@ const ScriptDetail = ({ route }) => {
361
358
  weekday_repeat,
362
359
  } = automate;
363
360
  if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
364
- let text;
361
+ let textCondition;
365
362
  if (condition === '>') {
366
- text = 'higher_than';
363
+ textCondition = 'higher_than';
367
364
  } else if (condition === '<') {
368
- text = 'lower_than';
365
+ textCondition = 'lower_than';
369
366
  } else if (condition === '=') {
370
- text = 'equal';
367
+ textCondition = 'equal';
371
368
  }
372
- return `${config_name} ${t(text)} ${value}`;
369
+ return `${config_name} ${t(textCondition)} ${value}`;
373
370
  } else if (type === AUTOMATE_TYPE.SCHEDULE) {
374
371
  const time =
375
- time_repeat?.length >= 8
376
- ? time_repeat.substring(0, time_repeat?.length - 3)
372
+ time_repeat.length >= 8
373
+ ? time_repeat.substring(0, time_repeat.length - 3)
377
374
  : time_repeat;
378
- const date = date_repeat?.split('-').reverse().join('/');
375
+ const date = date_repeat.split('-').reverse().join('/');
379
376
  const weekday = {
380
377
  1: t('mon'),
381
378
  2: t('tue'),
@@ -392,9 +389,7 @@ const ScriptDetail = ({ route }) => {
392
389
  return `${t('every_day_at', { time })}`;
393
390
  } else if (repeat === REPEAT_OPTIONS.EVERYWEEK) {
394
391
  //sort 0 is last number, exp: [1,3,5,0]
395
- const newWeekdayRepeat = weekday_repeat.map((item) =>
396
- parseInt(item, 10)
397
- );
392
+ const newWeekdayRepeat = weekday_repeat.map((item) => parseInt(item));
398
393
  const sortWeekday = newWeekdayRepeat.sort((a, b) => {
399
394
  if (a !== 0 && b === 0) {
400
395
  return -1;
@@ -2,18 +2,14 @@ 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 MockAdapter from 'axios-mock-adapter';
6
-
5
+ import axios from 'axios';
7
6
  import SelectUnit from '../';
8
7
  import { SCProvider } from '../../../context';
9
8
  import { mockSCStore } from '../../../context/mockStore';
10
9
  import { TESTID } from '../../../configs/Constants';
11
10
  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);
16
11
 
12
+ jest.mock('axios');
17
13
  const mockSetState = jest.fn();
18
14
  const mockDispatch = jest.fn();
19
15
  const mockGoBack = jest.fn();
@@ -51,6 +47,7 @@ describe('Test Select unit screen', () => {
51
47
  beforeEach(() => {
52
48
  mockSetState.mockClear();
53
49
  mockNavigate.mockClear();
50
+ axios.get.mockClear();
54
51
  });
55
52
 
56
53
  it('Test render', async () => {
@@ -75,7 +72,9 @@ describe('Test Select unit screen', () => {
75
72
  },
76
73
  ],
77
74
  };
78
- mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(200, response.data);
75
+ axios.get.mockImplementation(async () => {
76
+ return response;
77
+ });
79
78
  useState.mockImplementation((init) => [response.data, mockSetState]);
80
79
  await act(async () => {
81
80
  tree = await create(wrapComponent());
@@ -100,8 +99,12 @@ describe('Test Select unit screen', () => {
100
99
  isCreateNewAction: false,
101
100
  },
102
101
  });
103
-
104
- mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(400);
102
+ const response = {
103
+ status: 400,
104
+ };
105
+ axios.get.mockImplementation(async () => {
106
+ return response;
107
+ });
105
108
 
106
109
  await act(async () => {
107
110
  tree = await create(wrapComponent());
@@ -114,8 +117,8 @@ describe('Test Select unit screen', () => {
114
117
  await TouchableOpacities[1].props.onPress();
115
118
  await TouchableOpacities[2].props.onPress();
116
119
  });
120
+ expect(mockSetState).toBeCalledTimes(1);
117
121
  });
118
-
119
122
  it('Test form ScriptDetail onPressAddAction to Select-unit', async () => {
120
123
  useRoute.mockReturnValue({
121
124
  params: {
@@ -139,7 +142,9 @@ describe('Test Select unit screen', () => {
139
142
  },
140
143
  ],
141
144
  };
142
- mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(200, response.data);
145
+ axios.get.mockImplementation(async () => {
146
+ return response;
147
+ });
143
148
 
144
149
  await act(async () => {
145
150
  tree = await create(wrapComponent());
@@ -147,6 +152,16 @@ describe('Test Select unit screen', () => {
147
152
 
148
153
  const instance = tree.root;
149
154
 
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
+
150
165
  const buttonContinue = instance.findAll(
151
166
  (el) =>
152
167
  el.props.testID === TESTID.BOTTOM_VIEW_MAIN &&
@@ -157,6 +172,34 @@ describe('Test Select unit screen', () => {
157
172
  await act(async () => {
158
173
  await buttonContinue[0].props.onPress();
159
174
  });
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
+ });
160
203
  });
161
204
 
162
205
  it('Test handleOnGoBackAndClose', async () => {
@@ -192,7 +235,7 @@ describe('Test Select unit screen', () => {
192
235
  isCreateNewAction: true,
193
236
  isMultiUnits: undefined,
194
237
  name: '1',
195
- type: undefined,
238
+ type: 'value_change',
196
239
  unit: {
197
240
  id: 1,
198
241
  },
@@ -26,10 +26,9 @@ const SelectUnit = () => {
26
26
  scriptName,
27
27
  routeName,
28
28
  isCreateNewAction,
29
+ unit,
29
30
  title,
30
31
  automate,
31
- oldType,
32
- unit,
33
32
  } = params;
34
33
  const [data, setData] = useState([]);
35
34
  const [selectedItem, setSelectedItem] = useState(data[0]);
@@ -39,11 +38,9 @@ const SelectUnit = () => {
39
38
  };
40
39
 
41
40
  const getAllUnits = useCallback(async () => {
42
- const { success, data: automateData } = await axiosGet(
43
- API.AUTOMATE.GET_ALL_UNITS()
44
- );
41
+ const { success, data } = await axiosGet(API.AUTOMATE.GET_ALL_UNITS());
45
42
  if (success) {
46
- setData(automateData);
43
+ setData(data);
47
44
  }
48
45
  }, []);
49
46
 
@@ -52,7 +49,7 @@ const SelectUnit = () => {
52
49
  navigate(Routes.ScriptDetail, {
53
50
  id: automateId,
54
51
  name: scriptName,
55
- type: oldType,
52
+ type: type,
56
53
  havePermission: true,
57
54
  unit,
58
55
  isMultiUnits,
@@ -80,7 +77,6 @@ const SelectUnit = () => {
80
77
  unit: selectedItem,
81
78
  automateId,
82
79
  scriptName,
83
- oldType,
84
80
  }
85
81
  );
86
82
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -159,7 +155,6 @@ const SelectUnit = () => {
159
155
  keyExtractor={(item) => item.id}
160
156
  data={data}
161
157
  renderItem={renderItem}
162
- scrollIndicatorInsets={{ right: 1 }}
163
158
  />
164
159
  </View>
165
160
  </WrapHeaderScrollable>