@eohjsc/react-native-smart-city 0.3.31 → 0.3.32

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 (351) hide show
  1. package/package.json +7 -5
  2. package/src/commons/Action/ItemQuickAction.js +2 -3
  3. package/src/commons/Action/__test__/ItemQuickAction.test.js +17 -9
  4. package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +4 -4
  6. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +5 -2
  7. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +10 -4
  8. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +4 -4
  9. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  11. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +2 -2
  12. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +2 -2
  13. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
  14. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -6
  15. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +8 -4
  16. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -6
  17. package/src/commons/ActionGroup/OneBigButtonTemplate.js +1 -1
  18. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +10 -4
  19. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +25 -9
  20. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/ControlPlay.test.js +13 -7
  21. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/RectangleButton.test.js +9 -5
  22. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/SmartTiviActionTemplate.test.js +25 -9
  23. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +16 -6
  24. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +10 -4
  25. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButton.js +7 -3
  26. package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -2
  27. package/src/commons/ActionGroup/ThreeButtonTemplate.js +5 -5
  28. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +4 -4
  29. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +7 -7
  30. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +3 -3
  31. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
  32. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +9 -5
  33. package/src/commons/ActionGroup/__test__/index.test.js +5 -3
  34. package/src/commons/AlertAction/index.js +2 -2
  35. package/src/commons/Auth/AccountItem.js +9 -3
  36. package/src/commons/Auth/__test__/AccountItem.test.js +6 -3
  37. package/src/commons/Automate/ItemAutomate.js +13 -3
  38. package/src/commons/BackDefault/index.js +2 -2
  39. package/src/commons/BottomButtonView/index.js +4 -5
  40. package/src/commons/Button/index.js +0 -2
  41. package/src/commons/ButtonPopup/index.js +3 -3
  42. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -2
  43. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +4 -2
  44. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +6 -3
  45. package/src/commons/Dashboard/MyUnit/index.js +5 -3
  46. package/src/commons/Device/ConnectedViewHeader.js +2 -2
  47. package/src/commons/Device/DeviceAlertStatus.js +2 -2
  48. package/src/commons/Device/DisconnectedView.js +2 -2
  49. package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
  50. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +3 -2
  51. package/src/commons/Device/FlatListItems.js +2 -2
  52. package/src/commons/Device/ItemAddNew/index.js +7 -12
  53. package/src/commons/Device/ItemDevice.js +16 -11
  54. package/src/commons/Device/SensorConnectedStatus.js +5 -2
  55. package/src/commons/Device/WindDirection/Compass/index.js +5 -2
  56. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +8 -4
  57. package/src/commons/Device/__test__/FlatListItems.test.js +3 -2
  58. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +4 -2
  59. package/src/commons/Explore/ActivityIndicator/index.js +5 -2
  60. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +3 -3
  61. package/src/commons/Explore/SearchBox/index.js +2 -2
  62. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +4 -4
  63. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +11 -8
  64. package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
  65. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -2
  66. package/src/commons/FieldTemplate/PasscodeField/index.js +2 -2
  67. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +12 -7
  68. package/src/commons/Form/TextInput.js +2 -2
  69. package/src/commons/Form/TextInputPassword.js +2 -2
  70. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +5 -3
  71. package/src/commons/GroupCheckBox/index.js +2 -2
  72. package/src/commons/HeaderAni/index.js +2 -3
  73. package/src/commons/MediaPlayerDetail/index.js +2 -2
  74. package/src/commons/MenuActionList/index.js +2 -2
  75. package/src/commons/MenuActionMore/index.js +2 -3
  76. package/src/commons/NavBar/index.js +2 -3
  77. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +11 -5
  78. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +7 -3
  79. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +4 -2
  80. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +11 -8
  81. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +9 -5
  82. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +5 -3
  83. package/src/commons/Popover/index.js +2 -13
  84. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -3
  85. package/src/commons/PreventAccess/index.js +3 -3
  86. package/src/commons/{Connecting → Processing}/__test__/Connecting.test.js +5 -4
  87. package/src/commons/Processing/index.js +93 -0
  88. package/src/commons/{Connecting → Processing}/styles.js +9 -1
  89. package/src/commons/SelectGateway/index.js +105 -0
  90. package/src/commons/SelectGateway/styles.js +55 -0
  91. package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +106 -0
  92. package/src/commons/SelectSubUnit/index.js +124 -0
  93. package/src/commons/SelectSubUnit/styles.js +55 -0
  94. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
  95. package/src/commons/SelectUnit/index.js +106 -0
  96. package/src/commons/SelectUnit/styles.js +54 -0
  97. package/src/commons/Sharing/WrapHeaderScrollable.js +2 -2
  98. package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -4
  99. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +25 -10
  100. package/src/commons/SubUnit/OneTap/index.js +9 -4
  101. package/src/commons/SubUnit/ShortDetail.js +11 -29
  102. package/src/commons/SubUnit/__test__/ShortDetail.test.js +15 -10
  103. package/src/commons/SummaryItem/index.js +2 -2
  104. package/src/commons/Unit/HeaderUnit/index.js +4 -5
  105. package/src/commons/Unit/SharedUnit.js +10 -8
  106. package/src/commons/Unit/__test__/HeaderUnit.test.js +13 -5
  107. package/src/commons/Unit/__test__/SharedUnit.test.js +30 -11
  108. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +13 -8
  109. package/src/commons/UnitSummary/AirQuality/index.js +7 -3
  110. package/src/commons/UnitSummary/TotalPowerBox.js +2 -2
  111. package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -2
  112. package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +3 -2
  113. package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +4 -2
  114. package/src/commons/ViewButtonBottom/index.js +4 -4
  115. package/src/commons/WheelDateTimePicker/index.js +5 -3
  116. package/src/commons/WrapParallaxScrollView/index.js +2 -1
  117. package/src/configs/API.js +6 -14
  118. package/src/configs/AccessibilityLabel.js +608 -0
  119. package/src/configs/Constants.js +1 -604
  120. package/src/context/actionType.ts +7 -3
  121. package/src/context/mockStore.ts +6 -3
  122. package/src/context/reducer.ts +23 -8
  123. package/src/hoc/withRemoteControl.js +1 -0
  124. package/src/hooks/Common/index.js +2 -2
  125. package/src/hooks/Common/{useGGHomeDeviceConnected.js → useHomeAssistantDeviceConnected.js} +3 -3
  126. package/src/hooks/Common/usePopover.js +6 -1
  127. package/src/hooks/IoT/__test__/{useGGHomeConnection.test.js → useHomeAssistantConnection.test.js} +18 -18
  128. package/src/hooks/IoT/__test__/useRemoteControl.test.js +17 -12
  129. package/src/hooks/IoT/index.js +2 -2
  130. package/src/hooks/IoT/useHomeAssistantConnection.js +91 -0
  131. package/src/hooks/IoT/useRemoteControl.js +6 -6
  132. package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +21 -17
  133. package/src/iot/RemoteControl/LG.js +2 -1
  134. package/src/iot/RemoteControl/__test__/{GoogleHome.test.js → HomeAssistant.test.js} +30 -30
  135. package/src/navigations/AddDeviceStack.js +0 -14
  136. package/src/navigations/AddGatewayStack.js +51 -21
  137. package/src/navigations/Main.js +2 -2
  138. package/src/navigations/SmartIrStack.js +3 -3
  139. package/src/navigations/UnitStack.js +1 -1
  140. package/src/screens/AQIGuide/__test__/AQIGuide.test.js +5 -3
  141. package/src/screens/AQIGuide/index.js +5 -3
  142. package/src/screens/ActivityLog/FilterPopup.js +2 -2
  143. package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
  144. package/src/screens/ActivityLog/__test__/index.test.js +3 -2
  145. package/src/screens/ActivityLog/index.js +3 -3
  146. package/src/screens/AddCommon/SelectSubUnit.js +44 -191
  147. package/src/screens/AddCommon/SelectUnit.js +51 -204
  148. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +7 -50
  149. package/src/screens/AddCommon/__test__/SelectUnit.test.js +28 -26
  150. package/src/screens/AddLocationMaps/__test__/index.test.js +13 -7
  151. package/src/screens/AddLocationMaps/index.js +3 -3
  152. package/src/screens/AddNewAction/Device/index.js +2 -2
  153. package/src/screens/AddNewAction/SelectAction.js +6 -6
  154. package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
  155. package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
  156. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +8 -3
  157. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -7
  158. package/src/screens/AddNewAutoSmart/index.js +9 -12
  159. package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
  160. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +7 -4
  161. package/src/screens/AddNewDevice/index.js +4 -4
  162. package/src/screens/AddNewGateway/ConnectingDevice.js +40 -0
  163. package/src/screens/AddNewGateway/ConnectingModbusDevice.js +61 -0
  164. package/src/screens/AddNewGateway/ConnectingWifiDevice.js +70 -0
  165. package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +60 -0
  166. package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +21 -8
  167. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +23 -4
  168. package/src/screens/AddNewGateway/RenameNewDevices.js +141 -0
  169. package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +75 -0
  170. package/src/screens/AddNewGateway/ScanGatewayQR.js +57 -0
  171. package/src/screens/AddNewGateway/ScanModbusQR.js +53 -0
  172. package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +55 -0
  173. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +31 -0
  174. package/src/screens/AddNewGateway/SelectDeviceType.js +52 -0
  175. package/src/screens/AddNewGateway/SelectDeviceUnit.js +29 -0
  176. package/src/screens/AddNewGateway/SelectModbusGateway.js +34 -0
  177. package/src/screens/AddNewGateway/SelectZigbeeGateway.js +34 -0
  178. package/src/screens/AddNewGateway/ShareWifiPassword.js +302 -0
  179. package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +44 -0
  180. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -4
  181. package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +63 -0
  182. package/src/screens/AddNewGateway/__test__/{SelectGateway.test.js → ConnectingWifiDevice.test.js} +15 -10
  183. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +62 -0
  184. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
  185. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +73 -0
  186. package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +75 -0
  187. package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +73 -0
  188. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +47 -0
  189. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +89 -0
  190. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +48 -0
  191. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +77 -0
  192. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +77 -0
  193. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +294 -0
  194. package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -1
  195. package/src/screens/AddNewGateway/index.js +4 -4
  196. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +5 -4
  197. package/src/screens/AddNewOneTap/index.js +4 -4
  198. package/src/screens/Automate/__test__/index.test.js +2 -2
  199. package/src/screens/Automate/index.js +6 -2
  200. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +3 -2
  201. package/src/screens/ConfirmUnitDeletion/index.js +3 -3
  202. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +5 -5
  203. package/src/screens/Device/EditDevice/index.js +3 -3
  204. package/src/screens/Device/__test__/detail.test.js +38 -22
  205. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +6 -6
  206. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  207. package/src/screens/Device/detail.js +28 -22
  208. package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
  209. package/src/screens/DeviceInfo/__test__/index.test.js +8 -4
  210. package/src/screens/DeviceInfo/index.js +10 -6
  211. package/src/screens/Drawer/index.js +21 -9
  212. package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +8 -4
  213. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
  214. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -3
  215. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +9 -5
  216. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +7 -3
  217. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -3
  218. package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +3 -2
  219. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  220. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +6 -3
  221. package/src/screens/EnterPassword/index.js +5 -3
  222. package/src/screens/GuestInfo/__test__/index.test.js +18 -12
  223. package/src/screens/GuestInfo/components/AccessScheduleItem.js +2 -2
  224. package/src/screens/GuestInfo/components/AccessScheduleSheet.js +3 -3
  225. package/src/screens/GuestInfo/components/HeaderGuestInfo.js +2 -2
  226. package/src/screens/GuestInfo/components/RecurringDetail.js +4 -4
  227. package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -3
  228. package/src/screens/GuestInfo/index.js +1 -1
  229. package/src/screens/HanetCamera/Detail.js +10 -4
  230. package/src/screens/HanetCamera/ManageAccess.js +4 -4
  231. package/src/screens/HanetCamera/MemberInfo.js +1 -1
  232. package/src/screens/HanetCamera/__test__/Detail.test.js +5 -3
  233. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +10 -4
  234. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +4 -2
  235. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
  236. package/src/screens/ManageAccess/index.js +1 -1
  237. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +4 -4
  238. package/src/screens/MoveToAnotherSubUnit/index.js +2 -2
  239. package/src/screens/PlayBackCamera/__test__/index.test.js +9 -6
  240. package/src/screens/PlayBackCamera/index.js +6 -6
  241. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
  242. package/src/screens/ScanChipQR/components/QRScan/index.js +10 -3
  243. package/src/screens/ScriptDetail/__test__/index.test.js +8 -4
  244. package/src/screens/ScriptDetail/index.js +7 -6
  245. package/src/screens/SelectUnit/__test__/index.test.js +4 -3
  246. package/src/screens/SelectUnit/index.js +3 -3
  247. package/src/screens/SetSchedule/index.js +1 -1
  248. package/src/screens/Sharing/Components/SensorItem.js +2 -2
  249. package/src/screens/Sharing/Components/__test__/SensorItem.test.js +4 -2
  250. package/src/screens/Sharing/InfoMemberUnit.js +7 -6
  251. package/src/screens/Sharing/MemberList.js +4 -4
  252. package/src/screens/Sharing/SelectPermission.js +9 -4
  253. package/src/screens/Sharing/SelectUser.js +9 -5
  254. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
  255. package/src/screens/Sharing/__test__/SelectUser.test.js +7 -4
  256. package/src/screens/SideMenuDetail/__test__/index.test.js +11 -7
  257. package/src/screens/SideMenuDetail/index.js +2 -2
  258. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +4 -2
  259. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +5 -5
  260. package/src/screens/SmartIr/__test__/SmartIr.test.js +14 -6
  261. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +4 -2
  262. package/src/screens/SmartIr/components/{SelectDeviceType.js → SelectIrDeviceType.js} +2 -2
  263. package/src/screens/SmartIr/index.js +1 -1
  264. package/src/screens/SubUnit/AddSubUnit.js +7 -3
  265. package/src/screens/SubUnit/Detail.js +6 -6
  266. package/src/screens/SubUnit/EditSubUnit.js +10 -6
  267. package/src/screens/SubUnit/ManageSubUnit.js +2 -2
  268. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +6 -3
  269. package/src/screens/SubUnit/__test__/Detail.test.js +5 -3
  270. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +9 -5
  271. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +3 -2
  272. package/src/screens/SyncLGDevice/AddLGDevice.js +4 -4
  273. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +7 -4
  274. package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
  275. package/src/screens/TDSGuide/index.js +2 -2
  276. package/src/screens/Template/EditTemplate.js +2 -1
  277. package/src/screens/Template/__test__/detail.test.js +9 -1
  278. package/src/screens/Template/index.js +0 -1
  279. package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
  280. package/src/screens/UVIndexGuide/index.js +2 -2
  281. package/src/screens/Unit/AddMenu.js +6 -20
  282. package/src/screens/Unit/ChooseLocation.js +1 -1
  283. package/src/screens/Unit/Detail.js +10 -10
  284. package/src/screens/Unit/ManageUnit.js +21 -15
  285. package/src/screens/Unit/MyAllUnit/index.js +1 -1
  286. package/src/screens/Unit/SelectAddToFavorites.js +7 -8
  287. package/src/screens/Unit/SelectAddress.js +4 -4
  288. package/src/screens/Unit/SmartAccountItem.js +3 -3
  289. package/src/screens/Unit/Station/__test__/index.test.js +1 -1
  290. package/src/screens/Unit/Station/index.js +2 -2
  291. package/src/screens/Unit/Summaries.js +2 -2
  292. package/src/screens/Unit/__test__/CheckSendEmail.test.js +6 -6
  293. package/src/screens/Unit/__test__/Detail.test.js +17 -12
  294. package/src/screens/Unit/__test__/ManageUnit.test.js +40 -18
  295. package/src/screens/Unit/__test__/SelectAddress.test.js +15 -8
  296. package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
  297. package/src/screens/Unit/components/AutomateScript/index.js +5 -2
  298. package/src/screens/Unit/components/ListMyAllUnit/index.js +1 -1
  299. package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +9 -5
  300. package/src/screens/Unit/components/MyAllUnit/index.js +1 -1
  301. package/src/screens/Unit/components/MyUnitDevice/index.js +8 -5
  302. package/src/screens/Unit/components/SharedUnit/index.js +12 -6
  303. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  304. package/src/screens/Unit/components/__test__/SharedUnit.test.js +24 -9
  305. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +25 -11
  306. package/src/screens/UnitSummary/__test__/index.test.js +4 -2
  307. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +4 -2
  308. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
  309. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +4 -2
  310. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
  311. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +5 -4
  312. package/src/screens/UnitSummary/components/RunningDevices/index.js +6 -3
  313. package/src/screens/UnitSummary/components/TotalPowerBox/index.js +2 -2
  314. package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -2
  315. package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +3 -2
  316. package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +4 -2
  317. package/src/screens/UnitSummary/index.js +10 -8
  318. package/src/screens/WaterQualityGuide/__test__/index.test.js +17 -12
  319. package/src/screens/WaterQualityGuide/index.js +26 -10
  320. package/src/utils/Apis/axios.js +1 -0
  321. package/src/utils/I18n/translations/en.json +9 -9
  322. package/src/utils/I18n/translations/vi.json +8 -8
  323. package/src/utils/Route/index.js +16 -10
  324. package/src/commons/Connecting/index.js +0 -67
  325. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
  326. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +0 -41
  327. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +0 -163
  328. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +0 -19
  329. package/src/commons/ConnectingProcess/index.js +0 -213
  330. package/src/commons/ConnectingProcess/styles.js +0 -69
  331. package/src/hooks/IoT/useGGHomeConnection.js +0 -91
  332. package/src/iot/RemoteControl/index.js +0 -55
  333. package/src/screens/AddNewDevice/ConnectDevices.js +0 -184
  334. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -131
  335. package/src/screens/AddNewGateway/ConnectedGateway.js +0 -139
  336. package/src/screens/AddNewGateway/ConnectingGateway.js +0 -137
  337. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +0 -214
  338. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +0 -319
  339. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +0 -75
  340. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +0 -130
  341. package/src/screens/AddNewGateway/SelectGateway.js +0 -133
  342. package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -207
  343. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -71
  344. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +0 -96
  345. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -120
  346. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +0 -115
  347. package/src/screens/ScanChipQR/hooks/index.js +0 -120
  348. package/src/screens/ScanChipQR/index.js +0 -29
  349. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +0 -111
  350. package/src/screens/ScanSensorQR/hooks/index.js +0 -40
  351. package/src/screens/ScanSensorQR/index.js +0 -39
@@ -0,0 +1,52 @@
1
+ import React, { useCallback } from 'react';
2
+ import { View, Text } from 'react-native';
3
+ import styles from './ConnectingGatewayStyles';
4
+ import { useNavigation } from '@react-navigation/native';
5
+ import Routes from '../../utils/Route';
6
+ import Button from '../../commons/Button';
7
+
8
+ const SelectDeviceType = ({ route }) => {
9
+ const { unitId, stationId } = route?.params || {};
10
+ const navigation = useNavigation();
11
+
12
+ const onPressModbus = useCallback(() => {
13
+ navigation.navigate(Routes.SelectModbusGateway, {
14
+ unitId,
15
+ stationId,
16
+ type: 'modbus',
17
+ });
18
+ }, [navigation, unitId, stationId]);
19
+
20
+ const onPressZigbee = useCallback(() => {
21
+ navigation.navigate(Routes.SelectZigbeeGateway, {
22
+ unitId,
23
+ stationId,
24
+ type: 'zigbee',
25
+ });
26
+ }, [navigation, stationId, unitId]);
27
+
28
+ const onPressGateway = useCallback(() => {
29
+ navigation.navigate(Routes.ScanGatewayQR, {
30
+ unitId,
31
+ stationId,
32
+ });
33
+ }, [navigation, stationId, unitId]);
34
+ const onPressWifiDevice = useCallback(() => {
35
+ navigation.navigate(Routes.ScanWifiDeviceQR, {
36
+ unitId,
37
+ stationId,
38
+ });
39
+ }, [navigation, stationId, unitId]);
40
+ // Todo Bang this screen will be re-do by other soon
41
+ return (
42
+ <View style={styles.wrap}>
43
+ <Text>Select device type</Text>
44
+ <Button title={'Modbus'} onPress={onPressModbus} />
45
+ <Button title={'Zigbee'} onPress={onPressZigbee} />
46
+ <Button title={'Gateway'} onPress={onPressGateway} />
47
+ <Button title={'Wifi Device'} onPress={onPressWifiDevice} />
48
+ </View>
49
+ );
50
+ };
51
+
52
+ export default SelectDeviceType;
@@ -0,0 +1,29 @@
1
+ import React, { useCallback } from 'react';
2
+ import SelectUnit from '../../commons/SelectUnit';
3
+ import { useTranslations } from '../../hooks/Common/useTranslations';
4
+ import { useNavigation } from '@react-navigation/native';
5
+ import Routes from '../../utils/Route';
6
+
7
+ const SelectDeviceUnit = ({ route }) => {
8
+ const t = useTranslations();
9
+ const { navigate } = useNavigation();
10
+ const onPressNext = useCallback(
11
+ (unit) => {
12
+ navigate(Routes.SelectDeviceSubUnit, {
13
+ unitId: unit?.id,
14
+ unitName: unit?.name,
15
+ });
16
+ },
17
+ [navigate]
18
+ );
19
+
20
+ return (
21
+ <SelectUnit
22
+ title={t('add_new_device')}
23
+ subTitle={t('first_select_a_unit')}
24
+ onPressNext={onPressNext}
25
+ />
26
+ );
27
+ };
28
+
29
+ export default SelectDeviceUnit;
@@ -0,0 +1,34 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useNavigation } from '@react-navigation/native';
3
+ import { useTranslations } from '../../hooks/Common/useTranslations';
4
+ import SelectGateway from '../../commons/SelectGateway';
5
+ import Routes from '../../utils/Route';
6
+
7
+ const SelectModbusGateway = ({ route }) => {
8
+ const t = useTranslations();
9
+ const navigation = useNavigation();
10
+ const { unitId, stationId } = route?.params || {};
11
+
12
+ const onPressNext = useCallback(
13
+ (gateway) => {
14
+ navigation.navigate(Routes.ScanModbusQR, {
15
+ unitId,
16
+ stationId,
17
+ chipId: gateway.id,
18
+ });
19
+ },
20
+ [navigation, unitId, stationId]
21
+ );
22
+
23
+ return (
24
+ <SelectGateway
25
+ onPressNext={onPressNext}
26
+ title={t('text_select_a_gateway')}
27
+ subTitle={t('text_select_a_gateway')}
28
+ unitId={unitId}
29
+ type="modbus"
30
+ />
31
+ );
32
+ };
33
+
34
+ export default SelectModbusGateway;
@@ -0,0 +1,34 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useNavigation } from '@react-navigation/native';
3
+ import { useTranslations } from '../../hooks/Common/useTranslations';
4
+ import SelectGateway from '../../commons/SelectGateway';
5
+ import Routes from '../../utils/Route';
6
+
7
+ const SelectZigbeeGateway = ({ route }) => {
8
+ const t = useTranslations();
9
+ const navigation = useNavigation();
10
+ const { unitId, stationId } = route?.params || {};
11
+
12
+ const onPressNext = useCallback(
13
+ (gateway) => {
14
+ navigation.navigate(Routes.ConnectingZigbeeDevice, {
15
+ unitId,
16
+ stationId,
17
+ chipId: gateway.id,
18
+ });
19
+ },
20
+ [navigation, unitId, stationId]
21
+ );
22
+
23
+ return (
24
+ <SelectGateway
25
+ onPressNext={onPressNext}
26
+ title={t('text_select_a_gateway')}
27
+ subTitle={t('text_select_a_gateway')}
28
+ unitId={unitId}
29
+ type="zigbee"
30
+ />
31
+ );
32
+ };
33
+
34
+ export default SelectZigbeeGateway;
@@ -0,0 +1,302 @@
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import WifiManager from 'react-native-wifi-reborn';
3
+ import { ToastBottomHelper } from '../../utils/Utils';
4
+ import {
5
+ Alert,
6
+ Platform,
7
+ ScrollView,
8
+ TouchableOpacity,
9
+ View,
10
+ } from 'react-native';
11
+ import _ from 'lodash';
12
+ import dgram from 'react-native-udp';
13
+ import { useTranslations } from '../../hooks/Common/useTranslations';
14
+ import { HeaderCustom } from '../../commons/Header';
15
+ import Text from '../../commons/Text';
16
+ import WifiIcon from '../../../assets/images/wifi.svg';
17
+ import ButtonPopup from '../../commons/ButtonPopup';
18
+ import AccessibilityLabel from '../../configs/AccessibilityLabel';
19
+ import { Colors } from '../../configs';
20
+ import TextInputPassword from '../../commons/Form/TextInputPassword';
21
+ import styles from './ShareWifiPasswordStyles';
22
+ import { useNavigation } from '@react-navigation/native';
23
+ import Routes from '../../utils/Route';
24
+
25
+ const WifiItem = ({ item, setIsShowPopupPassword, setSelectedWifi }) => {
26
+ const showPopupPassword = useCallback(
27
+ (ssid) => {
28
+ setIsShowPopupPassword(true);
29
+ setSelectedWifi(ssid);
30
+ },
31
+ [setIsShowPopupPassword, setSelectedWifi]
32
+ );
33
+
34
+ return (
35
+ <TouchableOpacity
36
+ style={styles.listItem}
37
+ onPress={() => showPopupPassword(item.ssid)}
38
+ accessibilityLabel={`${AccessibilityLabel.SELECT_WIFI}${item.ssid}`}
39
+ >
40
+ <Text type="H4" style={styles.textItem}>
41
+ {item.ssid}
42
+ </Text>
43
+ <View style={styles.wifiIcon}>
44
+ <WifiIcon />
45
+ </View>
46
+ </TouchableOpacity>
47
+ );
48
+ };
49
+
50
+ const ShareWifiPassword = ({ route }) => {
51
+ const { prefix, unitId, stationId } = route?.params || {};
52
+ const t = useTranslations();
53
+ const navigation = useNavigation();
54
+
55
+ const [wifiList, setWifiList] = useState([]);
56
+ const [isShowPopupPassword, setIsShowPopupPassword] = useState(false);
57
+ const [selectedWifi, setSelectedWifi] = useState('');
58
+ const [selectedWifiPassword, setSelectedWifiPassword] = useState('');
59
+ const [currentState, setCurrentState] = useState(t('loading_wifi_list'));
60
+
61
+ const hidePopupPassword = useCallback(() => {
62
+ setIsShowPopupPassword(false);
63
+ }, []);
64
+
65
+ const shareWifiToDevice = useCallback(
66
+ (socket, i) => {
67
+ const timeoutSendConnect = setTimeout(async () => {
68
+ i--;
69
+ socket.send(
70
+ JSON.stringify({
71
+ type: 'connect',
72
+ data: { wifi: { ssid: selectedWifi, pass: selectedWifiPassword } },
73
+ }),
74
+ undefined,
75
+ undefined,
76
+ 54321,
77
+ '192.168.27.1',
78
+ undefined
79
+ );
80
+ if (i > 0) {
81
+ shareWifiToDevice(socket, i);
82
+ clearTimeout(timeoutSendConnect);
83
+ }
84
+ }, 1000);
85
+ },
86
+ [selectedWifiPassword, selectedWifi]
87
+ );
88
+
89
+ const handleSocketOnMsg = useCallback(
90
+ (currentSsid, msg) => {
91
+ const data = JSON.parse(msg.toString());
92
+ if (!Object.prototype.hasOwnProperty.call(data, 'gateway')) {
93
+ return false;
94
+ }
95
+ const gatewayInfo = data.gateway;
96
+ const checkWifiInterval = setInterval(async () => {
97
+ let ssid;
98
+ try {
99
+ ssid = await WifiManager.getCurrentWifiSSID();
100
+ } catch (e) {
101
+ return;
102
+ }
103
+
104
+ if (ssid !== currentSsid) {
105
+ clearInterval(checkWifiInterval);
106
+ navigation.navigate(Routes.ConnectingWifiDevice, {
107
+ unitId,
108
+ stationId,
109
+ gateway: gatewayInfo,
110
+ selectedWifi: {
111
+ ssid: selectedWifi,
112
+ password: selectedWifiPassword,
113
+ },
114
+ });
115
+ }
116
+ }, 1000);
117
+
118
+ return true;
119
+ },
120
+ [navigation, selectedWifi, selectedWifiPassword, stationId, unitId]
121
+ );
122
+
123
+ const onPasswordReady = useCallback(async () => {
124
+ const socket = dgram.createSocket({ type: 'udp4' });
125
+ socket.bind(54321);
126
+ let currentSsid;
127
+ try {
128
+ currentSsid = await WifiManager.getCurrentWifiSSID();
129
+ } catch (e) {
130
+ Alert.alert(t('cannot_get_current_wifi_ssid'));
131
+ return;
132
+ }
133
+
134
+ socket.on('message', (msg, rinfo) => {
135
+ if (handleSocketOnMsg(currentSsid, msg)) {
136
+ socket.close();
137
+ }
138
+ });
139
+ socket.on('error', () => {
140
+ ToastBottomHelper.error(t('server_error'));
141
+ // todo Bang handle error
142
+ });
143
+
144
+ setCurrentState(t('sharing_wifi_password_to_device'));
145
+ setIsShowPopupPassword(false);
146
+ shareWifiToDevice(socket, 3);
147
+ }, [handleSocketOnMsg, shareWifiToDevice, t]);
148
+
149
+ const connectToDeviceWifi = useCallback(async () => {
150
+ const wifiPrefix = `eoh.${prefix.toLowerCase()}.`;
151
+ const buttons = [
152
+ {
153
+ text: t('cancel'),
154
+ onPress: navigation.goBack,
155
+ },
156
+ {
157
+ text: t('retry'),
158
+ onPress: connectToDeviceWifi,
159
+ },
160
+ ];
161
+
162
+ if (Platform.OS === 'android') {
163
+ let phoneWifiList;
164
+ try {
165
+ phoneWifiList = await WifiManager.reScanAndLoadWifiList();
166
+ } catch (e) {
167
+ Alert.alert(t('cannot_fetch_wifi_list'));
168
+ return;
169
+ }
170
+ const wifi = _.find(phoneWifiList, function (x) {
171
+ return x.SSID.indexOf(`eoh.${prefix.toLowerCase()}.`) === 0;
172
+ });
173
+
174
+ if (!wifi) {
175
+ Alert.alert(
176
+ t('fail_to_discover_device_wifi'),
177
+ t('try to turn on device or try again'),
178
+ buttons
179
+ );
180
+ return;
181
+ }
182
+
183
+ try {
184
+ await WifiManager.connectToProtectedSSID(wifi.SSID, 'Eoh@2021', false);
185
+ } catch (e) {
186
+ Alert.alert(
187
+ t('cannot_connect_to_device_wifi'),
188
+ t('try to turn on device or try again'),
189
+ buttons
190
+ );
191
+ return;
192
+ }
193
+ } else {
194
+ try {
195
+ await WifiManager.connectToProtectedSSIDPrefix(
196
+ wifiPrefix,
197
+ 'Eoh@2021',
198
+ false
199
+ );
200
+ } catch (e) {
201
+ Alert.alert(
202
+ t('cannot_connect_to_device_wifi'),
203
+ t('try to turn on device or try again'),
204
+ buttons
205
+ );
206
+ return;
207
+ }
208
+ }
209
+
210
+ let intervalSend = null;
211
+ const socket = dgram.createSocket({ type: 'udp4' });
212
+ socket.bind(54321);
213
+
214
+ socket.on('message', (msg, rinfo) => {
215
+ const data = JSON.parse(msg.toString());
216
+ if (Object.prototype.hasOwnProperty.call(data, 'wifi')) {
217
+ setWifiList(data.wifi);
218
+ setCurrentState(t('select_wifi'));
219
+ clearInterval(intervalSend);
220
+ socket.close();
221
+ }
222
+ });
223
+
224
+ socket.on('error', () => {
225
+ ToastBottomHelper.error(t('fail_trigger_scan_wifi_on_device'));
226
+ });
227
+
228
+ intervalSend = setInterval(() => {
229
+ socket.send(
230
+ JSON.stringify({ type: 'scan', data: { wifi: '' } }),
231
+ undefined,
232
+ undefined,
233
+ 54321,
234
+ '192.168.27.1',
235
+ undefined
236
+ );
237
+ }, 5000); // workaround, todo Bang continue research
238
+ }, [navigation.goBack, prefix, t]);
239
+
240
+ useEffect(() => {
241
+ connectToDeviceWifi();
242
+ }, [connectToDeviceWifi]);
243
+
244
+ return (
245
+ <View style={styles.screen}>
246
+ <HeaderCustom
247
+ onGoBack={navigation.goBack}
248
+ title={t('connect_home_wifi')}
249
+ isShowSeparator
250
+ />
251
+ <View>
252
+ <Text style={styles.title} semibold type="H3">
253
+ {t('set_network')}
254
+ </Text>
255
+ <Text style={styles.subTitle} type="Body">
256
+ {currentState}
257
+ </Text>
258
+
259
+ <ScrollView
260
+ style={styles.listContainer}
261
+ scrollIndicatorInsets={{ right: 1 }}
262
+ >
263
+ {!!wifiList?.length &&
264
+ wifiList.map((item, index) => {
265
+ return (
266
+ <WifiItem
267
+ key={index}
268
+ item={item}
269
+ setSelectedWifi={setSelectedWifi}
270
+ setIsShowPopupPassword={setIsShowPopupPassword}
271
+ />
272
+ );
273
+ })}
274
+ </ScrollView>
275
+ </View>
276
+
277
+ <ButtonPopup
278
+ accessibilityLabel={AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP}
279
+ visible={isShowPopupPassword}
280
+ mainTitle={t('connect')}
281
+ onPressMain={onPasswordReady}
282
+ secondaryTitle={t('cancel')}
283
+ typeSecondary={'cancel'}
284
+ onPressSecondary={hidePopupPassword}
285
+ hideClose
286
+ >
287
+ <>
288
+ <Text>{t('enter_wifi_password')}</Text>
289
+ <TextInputPassword
290
+ secureTextEntry
291
+ placeholder={t('password')}
292
+ onChange={setSelectedWifiPassword}
293
+ value={selectedWifiPassword}
294
+ textInputStyle={styles.input}
295
+ selectionColor={Colors.Primary}
296
+ />
297
+ </>
298
+ </ButtonPopup>
299
+ </View>
300
+ );
301
+ };
302
+ export default ShareWifiPassword;
@@ -0,0 +1,44 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from '../../configs';
3
+
4
+ export default StyleSheet.create({
5
+ screen: {
6
+ flex: 1,
7
+ backgroundColor: Colors.Gray2,
8
+ },
9
+ title: {
10
+ marginVertical: 16,
11
+ marginLeft: 16,
12
+ },
13
+ subTitle: {
14
+ marginBottom: 16,
15
+ marginLeft: 16,
16
+ },
17
+ listContainer: {
18
+ borderWidth: 1,
19
+ backgroundColor: Colors.White,
20
+ borderRadius: 20,
21
+ borderColor: Colors.Gray4,
22
+ },
23
+ listItem: {
24
+ borderBottomColor: Colors.Gray4,
25
+ flex: 1,
26
+ flexDirection: 'row',
27
+ justifyContent: 'space-between',
28
+ alignItems: 'center',
29
+ },
30
+ textItem: {
31
+ paddingVertical: 16,
32
+ paddingLeft: 16,
33
+ },
34
+ wifiIcon: {
35
+ paddingRight: 16,
36
+ },
37
+ input: {
38
+ height: 40,
39
+ marginVertical: 12,
40
+ borderWidth: 1,
41
+ padding: 10,
42
+ borderColor: Colors.Gray5,
43
+ },
44
+ });
@@ -4,7 +4,7 @@ import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import AddNewGateway from '../index';
6
6
  import GroupCheckBox from '../../../commons/GroupCheckBox';
7
- import { TESTID } from '../../../configs/Constants';
7
+ import { AccessibilityLabel } from '../../../configs/Constants';
8
8
  import { ViewButtonBottom } from '../../../commons';
9
9
  import { TextInput } from 'react-native';
10
10
  import { getTranslate } from '../../../utils/I18n';
@@ -54,7 +54,7 @@ describe('Test AddNewGateway', () => {
54
54
  });
55
55
 
56
56
  const getText = (instance, id) => {
57
- return instance.find((el) => el.props.testID === id);
57
+ return instance.find((el) => el.props.accessibilityLabel === id);
58
58
  };
59
59
 
60
60
  test('create', async () => {
@@ -62,8 +62,11 @@ describe('Test AddNewGateway', () => {
62
62
  tree = await create(wrapComponent(route));
63
63
  });
64
64
  const instance = tree.root;
65
- const textAdd = getText(instance, TESTID.ADD_NEW_GATEWAY_ADD);
66
- const textThen = getText(instance, TESTID.ADD_NEW_GATEWAY_THEN_SELECT);
65
+ const textAdd = getText(instance, AccessibilityLabel.ADD_NEW_GATEWAY_ADD);
66
+ const textThen = getText(
67
+ instance,
68
+ AccessibilityLabel.ADD_NEW_GATEWAY_THEN_SELECT
69
+ );
67
70
  expect(textAdd.props.children).toEqual(
68
71
  getTranslate('en', 'add_new_gateway')
69
72
  );
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import MockAdapter from 'axios-mock-adapter';
4
+ import ConnectingModbusDevice from '../ConnectingModbusDevice';
5
+ import { SCProvider } from '../../../context';
6
+ import { mockSCStore } from '../../../context/mockStore';
7
+ import api from '../../../utils/Apis/axios';
8
+ import Processing from '../../../commons/Processing';
9
+
10
+ const wrapComponent = (route) => (
11
+ <SCProvider initState={mockSCStore({})}>
12
+ <ConnectingModbusDevice route={route} />
13
+ </SCProvider>
14
+ );
15
+
16
+ const mock = new MockAdapter(api.axiosInstance);
17
+
18
+ jest.mock('react', () => {
19
+ return { ...jest.requireActual('react'), memo: (x) => x };
20
+ });
21
+
22
+ const mockedNavigate = jest.fn();
23
+ const mockedGoBack = jest.fn();
24
+
25
+ jest.mock('@react-navigation/native', () => {
26
+ return {
27
+ ...jest.requireActual('@react-navigation/native'),
28
+ useNavigation: () => ({
29
+ navigate: mockedNavigate,
30
+ goBack: mockedGoBack,
31
+ }),
32
+ };
33
+ });
34
+
35
+ describe('Test connecting modbus device', () => {
36
+ let tree;
37
+ let route;
38
+
39
+ afterEach(() => {
40
+ mockedNavigate.mockClear();
41
+ });
42
+
43
+ beforeEach(() => {
44
+ route = {
45
+ params: {
46
+ unitId: 1,
47
+ stationId: 2,
48
+ chipId: 3,
49
+ qrData: {},
50
+ },
51
+ };
52
+ });
53
+
54
+ test('rendering', async () => {
55
+ await act(async () => {
56
+ tree = await create(wrapComponent(route));
57
+ });
58
+ const instance = tree.root;
59
+ expect(instance.findAllByType(Processing)).toHaveLength(1);
60
+
61
+ expect(mock.history.post).toHaveLength(1);
62
+ });
63
+ });
@@ -1,17 +1,20 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
-
4
- import AddNewGatewaySelectGateway from '../SelectGateway';
3
+ import MockAdapter from 'axios-mock-adapter';
4
+ import ConnectingWifiDevice from '../ConnectingWifiDevice';
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
- import { SafeAreaView } from 'react-native';
7
+ import api from '../../../utils/Apis/axios';
8
+ import Processing from '../../../commons/Processing';
8
9
 
9
10
  const wrapComponent = (route) => (
10
11
  <SCProvider initState={mockSCStore({})}>
11
- <AddNewGatewaySelectGateway route={route} />
12
+ <ConnectingWifiDevice route={route} />
12
13
  </SCProvider>
13
14
  );
14
15
 
16
+ const mock = new MockAdapter(api.axiosInstance);
17
+
15
18
  jest.mock('react', () => {
16
19
  return { ...jest.requireActual('react'), memo: (x) => x };
17
20
  });
@@ -26,11 +29,10 @@ jest.mock('@react-navigation/native', () => {
26
29
  navigate: mockedNavigate,
27
30
  goBack: mockedGoBack,
28
31
  }),
29
- useIsFocused: () => true,
30
32
  };
31
33
  });
32
34
 
33
- describe('Test AddNewGatewaySelectGateway', () => {
35
+ describe('Test connecting wifi device', () => {
34
36
  let tree;
35
37
  let route;
36
38
 
@@ -41,17 +43,20 @@ describe('Test AddNewGatewaySelectGateway', () => {
41
43
  beforeEach(() => {
42
44
  route = {
43
45
  params: {
44
- unit_id: 1,
46
+ unitId: 1,
47
+ stationId: 2,
48
+ gateway: {},
49
+ selectedWifi: {},
45
50
  },
46
51
  };
47
52
  });
48
53
 
49
- test('create AddNewGatewaySelectGateway', async () => {
54
+ test('rendering', async () => {
50
55
  await act(async () => {
51
56
  tree = await create(wrapComponent(route));
52
57
  });
53
58
  const instance = tree.root;
54
- const safeAreaView = instance.findAllByType(SafeAreaView);
55
- expect(safeAreaView).toHaveLength(1);
59
+ expect(instance.findAllByType(Processing)).toHaveLength(1);
60
+ expect(mock.history.post).toHaveLength(1);
56
61
  });
57
62
  });