@eohjsc/react-native-smart-city 0.3.8 → 0.3.9

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 (287) hide show
  1. package/README.md +36 -15
  2. package/package.json +10 -6
  3. package/react-native-smart-city.podspec +1 -0
  4. package/src/commons/Action/ItemQuickAction.js +16 -4
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
  8. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
  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/OnOffButtonTemplate.js +8 -2
  14. package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
  15. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
  16. package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
  17. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
  19. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
  20. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  21. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  22. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  23. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
  24. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
  25. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
  26. package/src/commons/ActionGroup/__test__/index.test.js +135 -0
  27. package/src/commons/Auth/AccountList.js +1 -1
  28. package/src/commons/Automate/ItemAutomate.js +1 -3
  29. package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
  30. package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
  31. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
  32. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
  33. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
  34. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
  35. package/src/commons/ConnectingProcess/index.js +76 -26
  36. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
  37. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  38. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
  39. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  40. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
  41. package/src/commons/Device/HistoryChart.js +7 -3
  42. package/src/commons/Device/ItemDevice.js +34 -13
  43. package/src/commons/Device/LinearChart.js +15 -0
  44. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  45. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  46. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  47. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  48. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
  49. package/src/commons/Explore/__test__/CityItem.test.js +33 -54
  50. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  51. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  52. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  53. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
  54. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  55. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  56. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
  57. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  58. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  59. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
  60. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  61. package/src/commons/Form/CurrencyInput.js +15 -1
  62. package/src/commons/Form/TextInputPassword.js +1 -1
  63. package/src/commons/FullLoading/index.js +2 -1
  64. package/src/commons/Header/HeaderCustom.js +2 -1
  65. package/src/commons/HeaderAni/index.js +6 -1
  66. package/src/commons/HorizontalPicker/index.js +2 -2
  67. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
  68. package/src/commons/MediaPlayerDetail/index.js +26 -47
  69. package/src/commons/MenuActionAddnew/index.js +1 -0
  70. package/src/commons/MenuActionList/index.js +1 -0
  71. package/src/commons/MenuActionMore/index.js +1 -1
  72. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  73. package/src/commons/PreventAccess/index.js +9 -1
  74. package/src/commons/Sharing/MemberList.js +10 -2
  75. package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
  76. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
  77. package/src/commons/SubUnit/Favorites/index.js +2 -3
  78. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
  79. package/src/commons/SubUnit/OneTap/index.js +1 -2
  80. package/src/commons/SubUnit/ShortDetail.js +25 -9
  81. package/src/commons/SubUnit/__test__/Item.test.js +0 -1
  82. package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
  83. package/src/commons/Unit/SharedUnit.js +1 -0
  84. package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
  85. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  86. package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
  87. package/src/commons/WheelDateTimePicker/index.js +4 -3
  88. package/src/configs/API.js +87 -143
  89. package/src/configs/Constants.js +61 -1
  90. package/src/configs/SCConfig.js +4 -0
  91. package/src/context/actionType.ts +10 -0
  92. package/src/context/mockStore.ts +11 -0
  93. package/src/context/reducer.ts +51 -2
  94. package/src/hooks/Common/index.js +2 -0
  95. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  96. package/src/hooks/Common/useGetIdUser.js +1 -5
  97. package/src/hooks/Common/useSensorsStatus.js +4 -4
  98. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
  99. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  100. package/src/hooks/IoT/index.js +4 -0
  101. package/src/hooks/IoT/useGGHomeConnection.js +93 -0
  102. package/src/hooks/IoT/useRemoteControl.js +79 -0
  103. package/src/hooks/index.js +4 -0
  104. package/src/hooks/useReceiveNotifications.js +9 -5
  105. package/src/iot/Monitor.js +3 -2
  106. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  107. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  108. package/src/iot/RemoteControl/Internet.js +1 -1
  109. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
  110. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  111. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  112. package/src/iot/RemoteControl/index.js +52 -52
  113. package/src/navigations/UnitStack.js +11 -20
  114. package/src/navigations/UnitStackStyles.js +21 -0
  115. package/src/screens/AQIGuide/index.js +1 -1
  116. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  117. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  118. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  119. package/src/screens/ActivityLog/hooks/index.js +1 -1
  120. package/src/screens/ActivityLog/index.js +2 -2
  121. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  122. package/src/screens/AddCommon/SelectUnit.js +1 -0
  123. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  124. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  125. package/src/screens/AddLocationMaps/index.js +9 -5
  126. package/src/screens/AddNewAction/SelectAction.js +8 -8
  127. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  128. package/src/screens/AddNewAction/SetupSensor.js +7 -7
  129. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  130. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  131. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  132. package/src/screens/AddNewAutoSmart/index.js +5 -2
  133. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  134. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
  135. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  136. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  137. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  138. package/src/screens/AddNewDevice/index.js +1 -0
  139. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  140. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
  141. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
  142. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  143. package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
  144. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  145. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  146. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  147. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  148. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  149. package/src/screens/AddNewGateway/index.js +1 -0
  150. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  151. package/src/screens/AddNewOneTap/index.js +3 -2
  152. package/src/screens/AllCamera/index.js +4 -4
  153. package/src/screens/Automate/MultiUnits.js +8 -8
  154. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  155. package/src/screens/Automate/__test__/index.test.js +7 -12
  156. package/src/screens/Automate/index.js +5 -3
  157. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  158. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  159. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  160. package/src/screens/Device/EditDevice/index.js +17 -15
  161. package/src/screens/Device/__test__/detail.test.js +33 -86
  162. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  163. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
  164. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  165. package/src/screens/Device/detail.js +85 -26
  166. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  167. package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
  168. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  169. package/src/screens/EditActionsList/index.js +1 -1
  170. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  171. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  172. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  173. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  174. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  175. package/src/screens/EmergencySetting/index.js +4 -1
  176. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  177. package/src/screens/Explore/index.js +2 -0
  178. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  179. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  180. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  181. package/src/screens/HanetCamera/Detail.js +1 -1
  182. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  183. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  184. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  185. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  186. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  187. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  188. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  189. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  190. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  191. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  192. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  193. package/src/screens/ManageAccess/hooks/index.js +7 -4
  194. package/src/screens/ManageAccess/index.js +2 -1
  195. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  196. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  197. package/src/screens/Notification/__test__/Notification.test.js +14 -25
  198. package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
  199. package/src/screens/Notification/components/NotificationItem.js +17 -20
  200. package/src/screens/Notification/index.js +9 -2
  201. package/src/screens/PlayBackCamera/Timer.js +2 -2
  202. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  203. package/src/screens/PlayBackCamera/index.js +54 -35
  204. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  205. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  206. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  207. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  208. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  209. package/src/screens/ScriptDetail/index.js +19 -14
  210. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  211. package/src/screens/SelectUnit/index.js +9 -4
  212. package/src/screens/SetSchedule/index.js +15 -11
  213. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  214. package/src/screens/SharedUnit/index.js +2 -0
  215. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  216. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  217. package/src/screens/Sharing/MemberList.js +12 -11
  218. package/src/screens/Sharing/SelectPermission.js +121 -76
  219. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  220. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  221. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  222. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  223. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  224. package/src/screens/Sharing/hooks/index.js +3 -0
  225. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  226. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  227. package/src/screens/SideMenuDetail/index.js +148 -0
  228. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  229. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  230. package/src/screens/SubUnit/AddSubUnit.js +23 -17
  231. package/src/screens/SubUnit/Detail.js +1 -2
  232. package/src/screens/SubUnit/EditSubUnit.js +15 -13
  233. package/src/screens/SubUnit/ManageSubUnit.js +13 -7
  234. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
  235. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  236. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  237. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  238. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
  239. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  240. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  241. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
  242. package/src/screens/TDSGuide/index.js +4 -1
  243. package/src/screens/UVIndexGuide/index.js +1 -1
  244. package/src/screens/Unit/ChooseLocation.js +7 -14
  245. package/src/screens/Unit/Detail.js +31 -75
  246. package/src/screens/Unit/ManageUnit.js +1 -0
  247. package/src/screens/Unit/SelectAddress.js +45 -23
  248. package/src/screens/Unit/SmartAccount.js +4 -4
  249. package/src/screens/Unit/Station/index.js +4 -0
  250. package/src/screens/Unit/Summaries.js +18 -2
  251. package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
  252. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  253. package/src/screens/Unit/__test__/Detail.test.js +98 -199
  254. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  255. package/src/screens/Unit/__test__/SelectAddress.test.js +159 -49
  256. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  257. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  258. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  259. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  260. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  261. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  262. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  263. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  264. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  265. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  266. package/src/screens/Unit/styles.js +4 -0
  267. package/src/screens/UnitSummary/__test__/index.test.js +91 -30
  268. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  269. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  270. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  271. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  272. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  273. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  274. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  275. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  276. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
  277. package/src/screens/UnitSummary/index.js +15 -1
  278. package/src/screens/WaterQualityGuide/index.js +1 -1
  279. package/src/utils/Apis/axios.js +54 -31
  280. package/src/utils/Converter/time.js +0 -18
  281. package/src/utils/I18n/translations/en.json +7 -1
  282. package/src/utils/I18n/translations/vi.json +8 -1
  283. package/src/utils/Permission/common.js +67 -0
  284. package/src/utils/Route/index.js +1 -0
  285. package/src/utils/Setting/Location.js +30 -0
  286. package/src/utils/Utils.js +11 -7
  287. package/src/utils/__test__/Utils.test.js +12 -0
@@ -56,7 +56,7 @@ const ConnectWifiWarning = memo(({ route }) => {
56
56
  const { setAction } = useContext(SCContext);
57
57
 
58
58
  const getPermissionWifiAndroid = useCallback(async () => {
59
- const granted = await PermissionsAndroid.request(
59
+ return await PermissionsAndroid.request(
60
60
  PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
61
61
  {
62
62
  title: t('location_permission_required_wifi_title'),
@@ -65,15 +65,21 @@ const ConnectWifiWarning = memo(({ route }) => {
65
65
  buttonPositive: t('allow'),
66
66
  }
67
67
  );
68
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
69
- ToastBottomHelper.success('GRANTED');
70
- } else {
71
- ToastBottomHelper.error('DENIED');
72
- }
73
- }, [t]);
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ }, []);
74
70
 
75
71
  useEffect(() => {
76
- isAndroid && getPermissionWifiAndroid();
72
+ if (isAndroid) {
73
+ (async () => {
74
+ const granted = await getPermissionWifiAndroid();
75
+ if (!granted) {
76
+ ToastBottomHelper.error(
77
+ 'Fail permission',
78
+ 'You need to grant permission to continue'
79
+ );
80
+ }
81
+ })();
82
+ }
77
83
  }, [getPermissionWifiAndroid]);
78
84
 
79
85
  const handleSend = async () => {
@@ -83,7 +89,7 @@ const ConnectWifiWarning = memo(({ route }) => {
83
89
  await socket.on('message', (msg, rinfo) => {
84
90
  clearInterval(intervalSend);
85
91
  const data = JSON.parse(msg.toString());
86
- if (data.hasOwnProperty('wifi')) {
92
+ if (Object.prototype.hasOwnProperty.call(data, 'wifi')) {
87
93
  navigate(Routes.GatewayWifiList, {
88
94
  list_wifi: data.wifi,
89
95
  unit_id: unit_id,
@@ -113,12 +119,12 @@ const ConnectWifiWarning = memo(({ route }) => {
113
119
  goBack();
114
120
  });
115
121
  } else {
116
- const socket = dgram.createSocket({ type: 'udp4' });
122
+ const dgSocket = dgram.createSocket({ type: 'udp4' });
117
123
  await setIsPercentConnect(1);
118
- await socket.bind(54321);
119
- await socket.on('message', (msg, rinfo) => {
124
+ await dgSocket.bind(54321);
125
+ await dgSocket.on('message', (msg, rinfo) => {
120
126
  const data = JSON.parse(msg.toString());
121
- if (data.hasOwnProperty('wifi')) {
127
+ if (Object.prototype.hasOwnProperty.call(data, 'wifi')) {
122
128
  navigate(Routes.GatewayWifiList, {
123
129
  list_wifi: data.wifi,
124
130
  unit_id: unit_id,
@@ -128,12 +134,12 @@ const ConnectWifiWarning = memo(({ route }) => {
128
134
  wifi_pass: wifi_pass,
129
135
  unit_name: unit_name,
130
136
  devicePrefixName: devicePrefixName,
131
- socket: socket,
137
+ socket: dgSocket,
132
138
  });
133
139
  }
134
140
  });
135
- await socket.once('listening', async () => {
136
- await socket.send(
141
+ await dgSocket.once('listening', async () => {
142
+ await dgSocket.send(
137
143
  JSON.stringify({ type: 'scan', data: { wifi: '' } }),
138
144
  undefined,
139
145
  undefined,
@@ -142,7 +148,7 @@ const ConnectWifiWarning = memo(({ route }) => {
142
148
  undefined
143
149
  );
144
150
  });
145
- socket.on('error', () => {
151
+ dgSocket.on('error', () => {
146
152
  ToastBottomHelper.error(t('server_error'));
147
153
  setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
148
154
  goBack();
@@ -28,8 +28,6 @@ import WifiManager from 'react-native-wifi-reborn';
28
28
  import { useNavigation } from '@react-navigation/native';
29
29
  import { TESTID } from '../../../configs/Constants';
30
30
 
31
- const isIos = Platform.OS === 'ios';
32
-
33
31
  const GatewayWifiList = memo(({ route }) => {
34
32
  const {
35
33
  list_wifi,
@@ -60,8 +58,8 @@ const GatewayWifiList = memo(({ route }) => {
60
58
  };
61
59
 
62
60
  const onPasswordChange = useCallback(
63
- (password) => {
64
- setPassword(password?.toString());
61
+ (newPassword) => {
62
+ setPassword(newPassword?.toString());
65
63
  },
66
64
  [setPassword]
67
65
  );
@@ -69,44 +67,49 @@ const GatewayWifiList = memo(({ route }) => {
69
67
  const handleSocketOnMsg = useCallback(
70
68
  (msg) => {
71
69
  const data = JSON.parse(msg.toString());
72
- if (data.hasOwnProperty('gateway')) {
70
+ if (Object.prototype.hasOwnProperty.call(data, 'gateway')) {
73
71
  const checkWifiInterval = setInterval(() => {
74
72
  // eslint-disable-next-line promise/prefer-await-to-then
75
- WifiManager.getCurrentWifiSSID().then((ssid) => {
76
- if (ssid !== wifi_ssid) {
77
- const IsRobot = devicePrefixName === 'ROBOT';
78
- if (IsRobot) {
79
- setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
80
- navigate(Routes.AddDeviceStack, {
81
- screen: Routes.AddCommonSelectSubUnit,
82
- params: {
83
- scan_sensor_data: scan_sensor_data,
84
- addType: 'AddDeviceNewFlow',
85
- gateway: data?.gateway,
86
- unit_id: unit_id,
87
- devicePrefixName: devicePrefixName,
88
- wifi_ssid: wifi_ssid,
89
- wifi_pass: wifi_pass,
90
- },
91
- });
92
- clearInterval(checkWifiInterval);
93
- } else {
94
- setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
95
- navigate(Routes.AddDeviceStack, {
96
- screen: Routes.ConnectingProcess,
97
- params: {
98
- unit_id: unit_id,
99
- unit_name: unit_name,
100
- scan_sensor_data: scan_sensor_data,
101
- gateway: data?.gateway,
102
- devicePrefixName: devicePrefixName,
103
- chip_id: chip_id,
104
- },
105
- });
106
- clearInterval(checkWifiInterval);
73
+ WifiManager.getCurrentWifiSSID().then(
74
+ (ssid) => {
75
+ if (ssid !== wifi_ssid) {
76
+ const IsRobot = devicePrefixName === 'ROBOT';
77
+ if (IsRobot) {
78
+ setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
79
+ navigate(Routes.AddDeviceStack, {
80
+ screen: Routes.AddCommonSelectSubUnit,
81
+ params: {
82
+ scan_sensor_data: scan_sensor_data,
83
+ addType: 'AddDeviceNewFlow',
84
+ gateway: data?.gateway,
85
+ unit_id: unit_id,
86
+ devicePrefixName: devicePrefixName,
87
+ wifi_ssid: wifi_ssid,
88
+ wifi_pass: wifi_pass,
89
+ },
90
+ });
91
+ clearInterval(checkWifiInterval);
92
+ } else {
93
+ setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
94
+ navigate(Routes.AddDeviceStack, {
95
+ screen: Routes.ConnectingProcess,
96
+ params: {
97
+ unit_id: unit_id,
98
+ unit_name: unit_name,
99
+ scan_sensor_data: scan_sensor_data,
100
+ gateway: data?.gateway,
101
+ devicePrefixName: devicePrefixName,
102
+ chip_id: chip_id,
103
+ },
104
+ });
105
+ clearInterval(checkWifiInterval);
106
+ }
107
107
  }
108
+ },
109
+ () => {
110
+ ToastBottomHelper.error('Cannot get current SSID!');
108
111
  }
109
- });
112
+ );
110
113
  }, 3000);
111
114
  }
112
115
  },
@@ -151,7 +154,7 @@ const GatewayWifiList = memo(({ route }) => {
151
154
 
152
155
  const connectWifi = useCallback(async () => {
153
156
  if (!isConnectWifiGateway) {
154
- if (isIos) {
157
+ if (Platform.OS === 'ios') {
155
158
  sendConnect(0);
156
159
  setAction(Action.IS_CONNECT_WIFI_GATEWAY, true);
157
160
  setIsSendWifi(true);
@@ -224,7 +227,10 @@ const GatewayWifiList = memo(({ route }) => {
224
227
  {t('select_wifi')}
225
228
  </Text>
226
229
 
227
- <ScrollView style={styles.listContainer}>
230
+ <ScrollView
231
+ style={styles.listContainer}
232
+ scrollIndicatorInsets={{ right: 1 }}
233
+ >
228
234
  {!!list_wifi.length &&
229
235
  list_wifi.map((item, index) => (
230
236
  <TouchableOpacity
@@ -1,25 +1,32 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
3
  import GatewayWifiList from '../GatewayWifiList';
4
- import { Text, ScrollView, TouchableOpacity } from 'react-native';
4
+ import { Text, ScrollView, TouchableOpacity, Platform } from 'react-native';
5
5
  import { getTranslate } from '../../../../utils/I18n';
6
6
  import { SCProvider } from '../../../../context';
7
7
  import { mockSCStore } from '../../../../context/mockStore';
8
8
  import TextInputPassword from '../../../../commons/Form/TextInputPassword';
9
9
  import { TESTID } from '../../../../configs/Constants';
10
+ import WifiManager from 'react-native-wifi-reborn';
11
+ import { useNavigation } from '@react-navigation/native';
12
+ import Routes from '../../../../utils/Route';
10
13
 
11
- const wrapComponent = (route) => (
12
- <SCProvider initState={mockSCStore({})}>
14
+ const wrapComponent = (route, state = {}) => (
15
+ <SCProvider initState={{ ...mockSCStore({}), ...state }}>
13
16
  <GatewayWifiList route={route} />
14
17
  </SCProvider>
15
18
  );
16
19
 
17
20
  describe('Test GatewayWifiList', () => {
18
21
  let tree;
22
+ const socket = {
23
+ on: jest.fn(),
24
+ send: jest.fn(),
25
+ };
19
26
  let route = {
20
27
  params: {
21
28
  list_wifi: [{ ssid: 'eoh@io' }, { ssid: 'eoh@ras.io' }],
22
- socket: { send: jest.fn() },
29
+ socket: socket,
23
30
  },
24
31
  };
25
32
 
@@ -33,6 +40,7 @@ describe('Test GatewayWifiList', () => {
33
40
  expect(texts[1].props.children).toEqual(getTranslate('en', 'set_network'));
34
41
  expect(texts[3].props.children).toEqual('eoh@io');
35
42
  });
43
+
36
44
  test('onPress wifi', async () => {
37
45
  await act(async () => {
38
46
  tree = await create(wrapComponent(route));
@@ -46,6 +54,7 @@ describe('Test GatewayWifiList', () => {
46
54
  await touchableOpacity[1].props.onPress();
47
55
  });
48
56
  });
57
+
49
58
  test('onChange TextInputPassword', async () => {
50
59
  await act(async () => {
51
60
  tree = await create(wrapComponent(route));
@@ -60,15 +69,60 @@ describe('Test GatewayWifiList', () => {
60
69
  const ButtonPopup = instance.find(
61
70
  (el) => el.props.testID === TESTID.GATEWAY_WIFI_LIST.BUTTON_POPUP
62
71
  );
63
- await act(() => {
64
- ButtonPopup.props.onPressMain();
72
+ await act(async () => {
73
+ await ButtonPopup.props.onPressMain();
65
74
  });
66
- await act(() => {
67
- ButtonPopup.props.onPressSecondary();
75
+ await act(async () => {
76
+ await ButtonPopup.props.onPressSecondary();
68
77
  });
69
- await act(() => {
70
- ButtonPopup.props.onClose();
78
+ await act(async () => {
79
+ await ButtonPopup.props.onClose();
71
80
  });
72
81
  expect(ButtonPopup).toBeDefined();
73
82
  });
83
+
84
+ test('on device is connected to wifi and mobile re-connect to internet', async () => {
85
+ jest.useFakeTimers();
86
+ Platform.OS = 'android';
87
+
88
+ await act(async () => {
89
+ tree = await create(wrapComponent(route, {}));
90
+ });
91
+
92
+ const instance = tree.root;
93
+ const ButtonPopup = instance.find(
94
+ (el) => el.props.testID === TESTID.GATEWAY_WIFI_LIST.BUTTON_POPUP
95
+ );
96
+ await act(async () => {
97
+ await ButtonPopup.props.onPressMain();
98
+ });
99
+ expect(socket.on).toBeCalled();
100
+ expect(socket.send).toBeCalled();
101
+
102
+ const mockWifiThen = jest.fn();
103
+ WifiManager.getCurrentWifiSSID.mockImplementation(() => ({
104
+ then: mockWifiThen,
105
+ }));
106
+
107
+ // receive message
108
+ await act(async () => {
109
+ await socket.on.mock.calls[0][1](
110
+ JSON.stringify({
111
+ gateway: true,
112
+ })
113
+ );
114
+ });
115
+ jest.runOnlyPendingTimers();
116
+
117
+ expect(WifiManager.getCurrentWifiSSID).toBeCalled();
118
+ expect(mockWifiThen).toBeCalled();
119
+
120
+ // get ssid success
121
+ act(() => {
122
+ mockWifiThen.mock.calls[0][0]('new-ssid');
123
+ });
124
+ const { navigate } = useNavigation();
125
+ expect(navigate).toBeCalled();
126
+ expect(navigate.mock.calls[0][0]).toEqual(Routes.AddDeviceStack);
127
+ });
74
128
  });
@@ -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) => (
@@ -52,6 +52,7 @@ const SetupGatewayWifi = memo(({ route }) => {
52
52
  setWifiName(ssid);
53
53
  });
54
54
  }
55
+ // eslint-disable-next-line no-empty
55
56
  } catch (err) {}
56
57
  };
57
58
  wifiPermission();
@@ -147,6 +148,7 @@ const SetupGatewayWifi = memo(({ route }) => {
147
148
  <ScrollView
148
149
  style={styles.scrollContainer}
149
150
  showsVerticalScrollIndicator={false}
151
+ scrollIndicatorInsets={{ right: 1 }}
150
152
  >
151
153
  <Section type={'border'}>
152
154
  <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,