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

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 (297) 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 +29 -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 +6 -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/__test__/ConfigHistoryChart.test.js +28 -1
  86. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  87. package/src/commons/UnitSummary/ConfigHistoryChart.js +55 -13
  88. package/src/commons/WheelDateTimePicker/index.js +4 -3
  89. package/src/configs/API.js +91 -143
  90. package/src/configs/Constants.js +80 -1
  91. package/src/configs/SCConfig.js +4 -0
  92. package/src/context/actionType.ts +14 -2
  93. package/src/context/mockStore.ts +26 -0
  94. package/src/context/reducer.ts +84 -5
  95. package/src/hooks/Common/index.js +2 -0
  96. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  97. package/src/hooks/Common/useGetIdUser.js +1 -5
  98. package/src/hooks/Common/useSensorsStatus.js +4 -4
  99. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
  100. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  101. package/src/hooks/IoT/__test__/useValueEvaluation.test.js +58 -0
  102. package/src/hooks/IoT/index.js +5 -0
  103. package/src/hooks/IoT/useGGHomeConnection.js +93 -0
  104. package/src/hooks/IoT/useRemoteControl.js +79 -0
  105. package/src/hooks/IoT/useValueEvaluation.js +45 -0
  106. package/src/hooks/index.js +4 -0
  107. package/src/hooks/useReceiveNotifications.js +12 -7
  108. package/src/iot/Monitor.js +3 -2
  109. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  110. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  111. package/src/iot/RemoteControl/Internet.js +1 -1
  112. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
  113. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  114. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  115. package/src/iot/RemoteControl/index.js +52 -52
  116. package/src/navigations/UnitStack.js +19 -20
  117. package/src/navigations/UnitStackStyles.js +21 -0
  118. package/src/screens/AQIGuide/index.js +1 -1
  119. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  120. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  121. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  122. package/src/screens/ActivityLog/hooks/index.js +1 -1
  123. package/src/screens/ActivityLog/index.js +2 -2
  124. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  125. package/src/screens/AddCommon/SelectUnit.js +1 -0
  126. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  127. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  128. package/src/screens/AddLocationMaps/__test__/index.test.js +265 -0
  129. package/src/screens/AddLocationMaps/index.js +48 -21
  130. package/src/screens/AddNewAction/SelectAction.js +33 -13
  131. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  132. package/src/screens/AddNewAction/SetupSensor.js +68 -32
  133. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  134. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  135. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +2 -0
  136. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  137. package/src/screens/AddNewAutoSmart/index.js +5 -2
  138. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  139. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
  140. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  141. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  142. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  143. package/src/screens/AddNewDevice/index.js +1 -0
  144. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  145. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
  146. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
  147. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  148. package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
  149. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  150. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  151. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  152. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  153. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  154. package/src/screens/AddNewGateway/index.js +1 -0
  155. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  156. package/src/screens/AddNewOneTap/index.js +3 -2
  157. package/src/screens/AllCamera/index.js +4 -4
  158. package/src/screens/Automate/MultiUnits.js +8 -8
  159. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  160. package/src/screens/Automate/__test__/index.test.js +7 -12
  161. package/src/screens/Automate/index.js +5 -3
  162. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  163. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  164. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  165. package/src/screens/Device/EditDevice/index.js +17 -15
  166. package/src/screens/Device/__test__/detail.test.js +33 -86
  167. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  168. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
  169. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  170. package/src/screens/Device/detail.js +101 -51
  171. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  172. package/src/screens/Device/hooks/useEvaluateValue.js +97 -0
  173. package/src/screens/Device/hooks/useFavoriteDevice.js +7 -11
  174. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  175. package/src/screens/EditActionsList/index.js +1 -1
  176. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  177. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  178. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  179. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  180. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  181. package/src/screens/EmergencySetting/index.js +4 -1
  182. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  183. package/src/screens/Explore/index.js +2 -0
  184. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  185. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  186. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  187. package/src/screens/HanetCamera/Detail.js +1 -1
  188. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  189. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  190. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  191. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  192. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  193. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  194. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  195. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  196. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  197. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  198. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  199. package/src/screens/ManageAccess/hooks/index.js +7 -4
  200. package/src/screens/ManageAccess/index.js +2 -1
  201. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  202. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  203. package/src/screens/Notification/__test__/Notification.test.js +31 -25
  204. package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
  205. package/src/screens/Notification/components/NotificationItem.js +17 -20
  206. package/src/screens/Notification/index.js +13 -2
  207. package/src/screens/PlayBackCamera/Timer.js +2 -2
  208. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  209. package/src/screens/PlayBackCamera/index.js +54 -35
  210. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  211. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  212. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  213. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  214. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  215. package/src/screens/ScriptDetail/index.js +30 -15
  216. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  217. package/src/screens/SelectUnit/index.js +9 -4
  218. package/src/screens/SetSchedule/index.js +15 -11
  219. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  220. package/src/screens/SharedUnit/index.js +2 -0
  221. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  222. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  223. package/src/screens/Sharing/MemberList.js +12 -11
  224. package/src/screens/Sharing/SelectPermission.js +136 -83
  225. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  226. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  227. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  228. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  229. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  230. package/src/screens/Sharing/hooks/index.js +3 -0
  231. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  232. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  233. package/src/screens/SideMenuDetail/index.js +148 -0
  234. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  235. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  236. package/src/screens/SubUnit/AddSubUnit.js +23 -17
  237. package/src/screens/SubUnit/Detail.js +1 -2
  238. package/src/screens/SubUnit/EditSubUnit.js +15 -13
  239. package/src/screens/SubUnit/ManageSubUnit.js +13 -7
  240. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
  241. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  242. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  243. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  244. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
  245. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  246. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  247. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
  248. package/src/screens/TDSGuide/index.js +4 -1
  249. package/src/screens/UVIndexGuide/index.js +1 -1
  250. package/src/screens/Unit/ChooseLocation.js +7 -14
  251. package/src/screens/Unit/Detail.js +37 -75
  252. package/src/screens/Unit/ManageUnit.js +1 -0
  253. package/src/screens/Unit/SelectAddress.js +46 -26
  254. package/src/screens/Unit/SelectDevices.js +158 -0
  255. package/src/screens/Unit/SelectDevicesStyles.js +40 -0
  256. package/src/screens/Unit/SmartAccount.js +4 -4
  257. package/src/screens/Unit/Station/index.js +4 -0
  258. package/src/screens/Unit/Summaries.js +18 -2
  259. package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
  260. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  261. package/src/screens/Unit/__test__/Detail.test.js +98 -199
  262. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  263. package/src/screens/Unit/__test__/SelectAddress.test.js +249 -50
  264. package/src/screens/Unit/__test__/SelectDevices.test.js +110 -0
  265. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  266. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  267. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  268. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  269. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  270. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  271. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  272. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  273. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  274. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  275. package/src/screens/Unit/styles.js +8 -0
  276. package/src/screens/UnitSummary/__test__/index.test.js +91 -30
  277. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  278. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  279. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  280. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  281. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  282. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  283. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  284. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  285. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
  286. package/src/screens/UnitSummary/index.js +15 -1
  287. package/src/screens/WaterQualityGuide/index.js +1 -1
  288. package/src/utils/Apis/axios.js +61 -32
  289. package/src/utils/Converter/time.js +0 -18
  290. package/src/utils/I18n/translations/en.json +13 -1
  291. package/src/utils/I18n/translations/vi.json +14 -1
  292. package/src/utils/Permission/common.js +67 -0
  293. package/src/utils/Route/index.js +2 -0
  294. package/src/utils/Setting/Location.js +30 -0
  295. package/src/utils/Utils.js +12 -7
  296. package/src/utils/Validation.js +3 -0
  297. package/src/utils/__test__/Utils.test.js +12 -0
@@ -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
@@ -35,9 +35,9 @@ const AllCamera = () => {
35
35
  const [dataFullScreen, setDataFullScreen] = useState();
36
36
 
37
37
  const handleFullScreen = useCallback(
38
- (data) => {
38
+ (dataFullscreen) => {
39
39
  setIsFullScreen(!isFullScreen);
40
- setDataFullScreen(data);
40
+ setDataFullScreen(dataFullscreen);
41
41
  },
42
42
  [isFullScreen]
43
43
  );
@@ -74,8 +74,8 @@ const AllCamera = () => {
74
74
  };
75
75
 
76
76
  const goToPlayBack = useCallback(
77
- (item, thumbnail) => () => {
78
- navigate(Routes.PlaybackCamera, { item, thumbnail });
77
+ (item, itemThumbnail) => () => {
78
+ navigate(Routes.PlaybackCamera, { item, thumbnail: itemThumbnail });
79
79
  },
80
80
  [navigate]
81
81
  );
@@ -39,17 +39,17 @@ const MultiUnits = () => {
39
39
  );
40
40
 
41
41
  const getData = useCallback(
42
- async (params) => {
42
+ async (fetchParams) => {
43
43
  if (isMultiUnits) {
44
- const { success, data } = await axiosGet(
44
+ const { success, data: automateData } = await axiosGet(
45
45
  API.AUTOMATE.GET_MULTI_UNITS(),
46
- params
46
+ fetchParams
47
47
  );
48
- success && setData(data);
48
+ success && setData(automateData);
49
49
  } else {
50
50
  await fetchWithCache(API.UNIT.AUTOMATE(unit?.id), {}, (response) => {
51
- const { success, data } = response;
52
- success && setData(data);
51
+ const { success, data: automateData } = response;
52
+ success && setData(automateData);
53
53
  });
54
54
  }
55
55
  },
@@ -60,14 +60,14 @@ const MultiUnits = () => {
60
60
  setTabActive(tab);
61
61
  };
62
62
 
63
- const onPressItem = (item, isOwner) => () => {
63
+ const onPressItem = (item, isItemOwner) => () => {
64
64
  navigate(Routes.UnitStack, {
65
65
  screen: Routes.ScriptDetail,
66
66
  params: {
67
67
  id: item?.id,
68
68
  name: item?.script?.name,
69
69
  type: item?.type,
70
- havePermission: isOwner || idUser === item?.user,
70
+ havePermission: isItemOwner || idUser === item?.user,
71
71
  unit,
72
72
  isMultiUnits,
73
73
  automate: item,
@@ -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,
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { FlatList, 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
 
6
6
  import Automate from '../';
7
7
  import { SCProvider } from '../../../context';
@@ -10,8 +10,10 @@ import ItemOneTap from '../../../commons/SubUnit/OneTap/ItemOneTap';
10
10
  import ItemAddNew from '../../../commons/Device/ItemAddNew';
11
11
  import Routes from '../../../utils/Route';
12
12
  import { TESTID } from '../../../configs/Constants';
13
+ import api from '../../../utils/Apis/axios';
14
+ import { API } from '../../../configs';
13
15
 
14
- jest.mock('axios');
16
+ const mock = new MockAdapter(api.axiosInstance);
15
17
  const mockedNavigate = jest.fn();
16
18
  const mockSetState = jest.fn();
17
19
 
@@ -46,7 +48,6 @@ describe('Test Automate', () => {
46
48
  let tree;
47
49
 
48
50
  beforeEach(() => {
49
- axios.get.mockClear();
50
51
  mockedNavigate.mockClear();
51
52
  mockSetState.mockClear();
52
53
  });
@@ -86,9 +87,7 @@ describe('Test Automate', () => {
86
87
  },
87
88
  ],
88
89
  };
89
- await axios.get.mockImplementation(async () => {
90
- return response;
91
- });
90
+ mock.onGet(API.AUTOMATE.GET_SMART()).reply(200, response.data);
92
91
 
93
92
  useState.mockImplementation(() => [false, mockSetState]);
94
93
  useState.mockImplementation(() => [response.data, mockSetState]);
@@ -141,9 +140,7 @@ describe('Test Automate', () => {
141
140
  { automates: [], unit_id: 3, unit_name: 'La Vida' },
142
141
  ],
143
142
  };
144
- await axios.get.mockImplementation(async () => {
145
- return response;
146
- });
143
+ mock.onGet(API.AUTOMATE.GET_SMART()).reply(200, response.data);
147
144
 
148
145
  useState.mockImplementation(() => [false, mockSetState]);
149
146
  useState.mockImplementation(() => [response.data, mockSetState]);
@@ -199,9 +196,7 @@ describe('Test Automate', () => {
199
196
  { automates: [], unit_id: 3, unit_name: 'La Vida' },
200
197
  ],
201
198
  };
202
- await axios.get.mockImplementation(async () => {
203
- return response;
204
- });
199
+ mock.onGet(API.AUTOMATE.GET_SMART()).reply(200, response.data);
205
200
 
206
201
  useState.mockImplementation(() => [false, mockSetState]);
207
202
  useState.mockImplementation(() => [response.data, mockSetState]);
@@ -109,13 +109,13 @@ const Automate = () => {
109
109
  const isOwner = owner_unit_id
110
110
  ? owner_unit_id === idUser
111
111
  : type === UNIT_TYPES.MULTI;
112
- const renderItemAutomate = ({ item }) => {
112
+ const renderItemAutomate = ({ item: automate }) => {
113
113
  return (
114
114
  <ItemOneTap
115
115
  isOwner={isOwner}
116
- automate={item}
116
+ automate={automate}
117
117
  wrapSyles={styles.wrapAutomateItem}
118
- onPressItem={onPressItem(item, unit_id, type, isOwner)}
118
+ onPressItem={onPressItem(automate, unit_id, type, isOwner)}
119
119
  />
120
120
  );
121
121
  };
@@ -147,6 +147,7 @@ const Automate = () => {
147
147
  showsHorizontalScrollIndicator={false}
148
148
  contentContainerStyle={styles.contentContainerStyle2}
149
149
  ListFooterComponent={renderListFooterComponent(type, unit_id)}
150
+ scrollIndicatorInsets={{ right: 1 }}
150
151
  />
151
152
  </View>
152
153
  );
@@ -189,6 +190,7 @@ const Automate = () => {
189
190
  contentContainerStyle={styles.contentContainerStyle}
190
191
  refreshing={false}
191
192
  onRefresh={getAutomates}
193
+ scrollIndicatorInsets={{ right: 1 }}
192
194
  />
193
195
  </View>
194
196
  );
@@ -1,43 +1,49 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
- import axios from 'axios';
4
3
 
5
4
  import { SCProvider } from '../../../context';
6
5
  import { mockSCStore } from '../../../context/mockStore';
7
6
  import ConfirmUnitDeletion from '../index';
8
7
  import _TextInput from '../../../commons/Form/TextInput';
8
+ import { TouchableOpacity } from 'react-native';
9
+ import { TESTID } from '../../../configs/Constants';
10
+ import API from '../../../configs/API';
11
+ import api from '../../../utils/Apis/axios';
12
+ import MockAdapter from 'axios-mock-adapter';
9
13
 
14
+ const mock = new MockAdapter(api.axiosInstance);
10
15
  const wrapComponent = (route, navigation) => (
11
16
  <SCProvider initState={mockSCStore({})}>
12
17
  <ConfirmUnitDeletion route={route} />
13
18
  </SCProvider>
14
19
  );
15
20
 
16
- const mockedNavigate = jest.fn();
17
-
21
+ const mockNavigate = jest.fn();
22
+ const mockGoBack = jest.fn();
18
23
  jest.mock('@react-navigation/native', () => {
19
24
  return {
20
25
  ...jest.requireActual('@react-navigation/native'),
21
26
  useNavigation: () => ({
22
- goBack: mockedNavigate,
27
+ navigate: mockNavigate,
28
+ goBack: mockGoBack,
23
29
  }),
24
30
  };
25
31
  });
26
32
 
33
+ const mockSetState = jest.fn();
27
34
  jest.mock('react', () => {
28
35
  return {
29
36
  ...jest.requireActual('react'),
37
+ useState: jest.fn((init) => [init, mockSetState]),
30
38
  memo: (x) => x,
31
39
  };
32
40
  });
33
41
 
34
- jest.mock('axios');
35
42
  describe('Test ConfirmUnitDeletion', () => {
36
43
  let tree;
37
44
  let route;
38
45
 
39
46
  beforeAll(() => {
40
- axios.get.mockClear();
41
47
  route = {
42
48
  params: {
43
49
  unit: {
@@ -48,14 +54,36 @@ describe('Test ConfirmUnitDeletion', () => {
48
54
  });
49
55
 
50
56
  test('test render ConfirmUnitDeletion', async () => {
57
+ useState.mockImplementationOnce((init) => ['new_name', mockSetState]);
58
+ await act(async () => {
59
+ tree = await renderer.create(wrapComponent(route));
60
+ });
61
+ const instance = tree.root;
62
+
63
+ const textInput = instance.findByType(_TextInput);
64
+ await act(async () => {
65
+ textInput.props.onChange();
66
+ });
67
+ });
68
+ test('Onpress button ConfirmUnitDeletion ', async () => {
69
+ useState.mockImplementationOnce((init) => ['YES', mockSetState]);
51
70
  await act(async () => {
52
71
  tree = await renderer.create(wrapComponent(route));
53
72
  });
54
73
  const instance = tree.root;
55
74
 
75
+ const touchableOpacity = instance.find(
76
+ (el) =>
77
+ el.props.testID === TESTID.CONFIRM_UNIT_DELETION_BUTTON &&
78
+ el.type === TouchableOpacity
79
+ );
56
80
  const textInput = instance.findByType(_TextInput);
57
81
  await act(async () => {
58
- textInput.props.onChange('new_name');
82
+ touchableOpacity.props.onPress();
83
+ });
84
+ await act(async () => {
85
+ textInput.props.onChange();
59
86
  });
87
+ mock.onDelete(API.UNIT.MANAGE_UNIT(1)).reply(204);
60
88
  });
61
89
  });
@@ -12,6 +12,7 @@ import { Button } from '../../commons';
12
12
  import Routes from '../../utils/Route';
13
13
  import { axiosDelete } from '../../utils/Apis/axios';
14
14
  import { ToastBottomHelper } from '../../utils/Utils';
15
+ import { TESTID } from '../../configs/Constants';
15
16
 
16
17
  const ConfirmUnitDeletion = ({ route }) => {
17
18
  const t = useTranslations();
@@ -55,7 +56,12 @@ const ConfirmUnitDeletion = ({ route }) => {
55
56
  textInputStyle={styles.textInput}
56
57
  />
57
58
  <View style={styles.buttonWrap}>
58
- <Button type="auth" title={t('done')} onPress={onSendPress} />
59
+ <Button
60
+ type="auth"
61
+ title={t('done')}
62
+ onPress={onSendPress}
63
+ testID={TESTID.CONFIRM_UNIT_DELETION_BUTTON}
64
+ />
59
65
  </View>
60
66
  </WrapHeaderScrollable>
61
67
  );