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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +15 -36
  2. package/package.json +5 -9
  3. package/react-native-smart-city.podspec +0 -1
  4. package/src/commons/Action/ItemQuickAction.js +4 -16
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
  8. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
  9. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
  14. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  15. package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
  16. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
  17. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
  18. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
  19. package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
  20. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
  21. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
  22. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
  23. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
  24. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  25. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
  26. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
  27. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
  28. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
  29. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
  30. package/src/commons/ActionGroup/__test__/index.test.js +4 -142
  31. package/src/commons/Auth/AccountList.js +1 -1
  32. package/src/commons/Automate/ItemAutomate.js +3 -1
  33. package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
  34. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
  35. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
  36. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
  37. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
  38. package/src/commons/ConnectingProcess/index.js +25 -75
  39. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
  40. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  41. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
  42. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  43. package/src/commons/Device/HistoryChart.js +3 -7
  44. package/src/commons/Device/ItemDevice.js +12 -19
  45. package/src/commons/Device/LinearChart.js +0 -15
  46. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
  47. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
  48. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  49. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
  50. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
  51. package/src/commons/Explore/__test__/CityItem.test.js +54 -33
  52. package/src/commons/Form/CurrencyInput.js +1 -15
  53. package/src/commons/Form/TextInputPassword.js +1 -1
  54. package/src/commons/FullLoading/index.js +1 -2
  55. package/src/commons/Header/HeaderCustom.js +1 -2
  56. package/src/commons/HeaderAni/index.js +1 -6
  57. package/src/commons/HorizontalPicker/index.js +2 -2
  58. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
  59. package/src/commons/MediaPlayerDetail/index.js +47 -25
  60. package/src/commons/MenuActionAddnew/index.js +0 -1
  61. package/src/commons/MenuActionList/index.js +0 -1
  62. package/src/commons/MenuActionMore/index.js +1 -1
  63. package/src/commons/PreventAccess/index.js +1 -9
  64. package/src/commons/Sharing/MemberList.js +2 -10
  65. package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
  66. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
  67. package/src/commons/SubUnit/Favorites/index.js +3 -2
  68. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
  69. package/src/commons/SubUnit/OneTap/index.js +2 -1
  70. package/src/commons/SubUnit/ShortDetail.js +9 -25
  71. package/src/commons/SubUnit/__test__/Item.test.js +1 -0
  72. package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
  73. package/src/commons/Unit/SharedUnit.js +0 -1
  74. package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
  75. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
  76. package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
  77. package/src/commons/WheelDateTimePicker/index.js +3 -4
  78. package/src/configs/API.js +143 -87
  79. package/src/configs/Constants.js +2 -57
  80. package/src/configs/SCConfig.js +0 -4
  81. package/src/context/actionType.ts +0 -8
  82. package/src/context/mockStore.ts +0 -10
  83. package/src/context/reducer.ts +2 -38
  84. package/src/hooks/Common/index.js +0 -2
  85. package/src/hooks/Common/useGetIdUser.js +5 -1
  86. package/src/hooks/Common/useSensorsStatus.js +4 -4
  87. package/src/hooks/useReceiveNotifications.js +5 -9
  88. package/src/iot/Monitor.js +2 -3
  89. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  90. package/src/iot/RemoteControl/GoogleHome.js +49 -75
  91. package/src/iot/RemoteControl/Internet.js +1 -1
  92. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
  93. package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
  94. package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
  95. package/src/iot/RemoteControl/index.js +52 -52
  96. package/src/navigations/UnitStack.js +20 -11
  97. package/src/screens/AQIGuide/index.js +1 -1
  98. package/src/screens/ActivityLog/FilterPopup.js +0 -2
  99. package/src/screens/ActivityLog/__test__/index.test.js +23 -38
  100. package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
  101. package/src/screens/ActivityLog/hooks/index.js +1 -1
  102. package/src/screens/ActivityLog/index.js +2 -2
  103. package/src/screens/AddCommon/SelectSubUnit.js +0 -1
  104. package/src/screens/AddCommon/SelectUnit.js +0 -1
  105. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
  106. package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
  107. package/src/screens/AddLocationMaps/index.js +5 -9
  108. package/src/screens/AddNewAction/SelectAction.js +8 -8
  109. package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
  110. package/src/screens/AddNewAction/SetupSensor.js +7 -7
  111. package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
  112. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
  113. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
  114. package/src/screens/AddNewAutoSmart/index.js +2 -5
  115. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  116. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
  117. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
  118. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  119. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  120. package/src/screens/AddNewDevice/index.js +0 -1
  121. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
  122. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
  123. package/src/screens/AddNewGateway/SelectGateway.js +0 -1
  124. package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
  125. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
  126. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
  127. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
  128. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
  129. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
  130. package/src/screens/AddNewGateway/index.js +0 -1
  131. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
  132. package/src/screens/AddNewOneTap/index.js +2 -3
  133. package/src/screens/AllCamera/index.js +4 -4
  134. package/src/screens/Automate/MultiUnits.js +8 -8
  135. package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
  136. package/src/screens/Automate/__test__/index.test.js +12 -7
  137. package/src/screens/Automate/index.js +3 -5
  138. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
  139. package/src/screens/ConfirmUnitDeletion/index.js +1 -7
  140. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
  141. package/src/screens/Device/EditDevice/index.js +15 -17
  142. package/src/screens/Device/__test__/detail.test.js +86 -33
  143. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  144. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
  145. package/src/screens/Device/components/SensorDisplayItem.js +2 -5
  146. package/src/screens/Device/detail.js +24 -80
  147. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  148. package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
  149. package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
  150. package/src/screens/EditActionsList/index.js +1 -1
  151. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
  152. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
  153. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
  154. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
  155. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  156. package/src/screens/EmergencySetting/index.js +1 -4
  157. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
  158. package/src/screens/Explore/index.js +0 -2
  159. package/src/screens/GuestInfo/__test__/index.test.js +41 -14
  160. package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
  161. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  162. package/src/screens/HanetCamera/Detail.js +1 -1
  163. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +12 -8
  164. package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
  165. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
  166. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
  167. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
  168. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
  169. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
  170. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  171. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  172. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +22 -33
  173. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
  174. package/src/screens/ManageAccess/hooks/index.js +4 -7
  175. package/src/screens/ManageAccess/index.js +1 -2
  176. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
  177. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  178. package/src/screens/Notification/__test__/Notification.test.js +25 -14
  179. package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
  180. package/src/screens/Notification/components/NotificationItem.js +20 -17
  181. package/src/screens/Notification/index.js +2 -9
  182. package/src/screens/PlayBackCamera/Timer.js +2 -2
  183. package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
  184. package/src/screens/PlayBackCamera/index.js +6 -22
  185. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
  186. package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
  187. package/src/screens/ScanChipQR/hooks/index.js +16 -15
  188. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
  189. package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
  190. package/src/screens/ScriptDetail/index.js +14 -19
  191. package/src/screens/SelectUnit/__test__/index.test.js +55 -12
  192. package/src/screens/SelectUnit/index.js +4 -9
  193. package/src/screens/SetSchedule/index.js +11 -15
  194. package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
  195. package/src/screens/SharedUnit/index.js +0 -2
  196. package/src/screens/Sharing/Components/SensorItem.js +12 -10
  197. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  198. package/src/screens/Sharing/MemberList.js +11 -12
  199. package/src/screens/Sharing/SelectPermission.js +76 -121
  200. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
  201. package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
  202. package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
  203. package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
  204. package/src/screens/Sharing/hooks/index.js +0 -3
  205. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
  206. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  207. package/src/screens/SubUnit/AddSubUnit.js +17 -23
  208. package/src/screens/SubUnit/Detail.js +2 -1
  209. package/src/screens/SubUnit/EditSubUnit.js +13 -15
  210. package/src/screens/SubUnit/ManageSubUnit.js +7 -13
  211. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
  212. package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
  213. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
  214. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
  215. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
  216. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  217. package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
  218. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
  219. package/src/screens/TDSGuide/index.js +1 -4
  220. package/src/screens/UVIndexGuide/index.js +1 -1
  221. package/src/screens/Unit/ChooseLocation.js +14 -7
  222. package/src/screens/Unit/Detail.js +75 -30
  223. package/src/screens/Unit/ManageUnit.js +0 -1
  224. package/src/screens/Unit/SelectAddress.js +23 -45
  225. package/src/screens/Unit/SmartAccount.js +4 -4
  226. package/src/screens/Unit/Station/index.js +0 -4
  227. package/src/screens/Unit/Summaries.js +2 -18
  228. package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
  229. package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
  230. package/src/screens/Unit/__test__/Detail.test.js +200 -99
  231. package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
  232. package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
  233. package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
  234. package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
  235. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  236. package/src/screens/Unit/components/SharedUnit/index.js +0 -1
  237. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  238. package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
  239. package/src/screens/Unit/styles.js +0 -4
  240. package/src/screens/UnitSummary/__test__/index.test.js +30 -91
  241. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
  242. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
  243. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
  244. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
  245. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
  246. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
  247. package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
  248. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  249. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
  250. package/src/screens/UnitSummary/index.js +1 -15
  251. package/src/screens/WaterQualityGuide/index.js +1 -1
  252. package/src/utils/Apis/axios.js +31 -54
  253. package/src/utils/Converter/time.js +18 -0
  254. package/src/utils/I18n/translations/en.json +1 -7
  255. package/src/utils/I18n/translations/vi.json +1 -8
  256. package/src/utils/Route/index.js +0 -1
  257. package/src/utils/Utils.js +7 -11
  258. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
  259. package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
  260. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
  261. package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
  262. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
  263. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
  264. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
  265. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
  266. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
  267. package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
  268. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
  269. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
  270. package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
  271. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
  272. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
  273. package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
  274. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
  275. package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
  276. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
  277. package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
  278. package/src/hooks/IoT/index.js +0 -4
  279. package/src/hooks/IoT/useGGHomeConnection.js +0 -91
  280. package/src/hooks/IoT/useRemoteControl.js +0 -79
  281. package/src/hooks/index.js +0 -4
  282. package/src/navigations/UnitStackStyles.js +0 -21
  283. package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
  284. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
  285. package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
  286. package/src/screens/SideMenuDetail/index.js +0 -148
  287. package/src/screens/Unit/__test__/Summaries.test.js +0 -100
  288. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  289. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  290. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
  291. package/src/utils/Permission/common.js +0 -67
  292. package/src/utils/Setting/Location.js +0 -30
  293. package/src/utils/__test__/Utils.test.js +0 -12
@@ -1,26 +1,26 @@
1
+ /* eslint-disable promise/prefer-await-to-callbacks */
1
2
  import React from 'react';
2
3
  import { create, act } from 'react-test-renderer';
3
-
4
+ import axios from 'axios';
4
5
  import MemberList from '../MemberList';
5
6
  import { AlertAction } from '../../../commons';
7
+ import API from '../../../configs/API';
8
+ import { TESTID } from '../../../configs/Constants';
9
+ import { TouchableOpacity } from 'react-native';
6
10
  import { SCProvider } from '../../../context';
7
11
  import { mockSCStore } from '../../../context/mockStore';
8
- import { TouchableOpacity } from 'react-native';
9
12
  import Routes from '../../../utils/Route';
10
13
 
11
- jest.mock('../../../hooks/Common', () => {
12
- return {
13
- useIsOwnerOfUnit: () => ({ isOwner: true }),
14
- };
15
- });
16
-
17
14
  const mockedNavigate = jest.fn();
15
+ const mockedDispatch = jest.fn();
16
+ const mockedAddListener = jest.fn();
18
17
  const mockUseIsFocused = jest.fn();
19
18
 
20
19
  jest.mock('@react-navigation/native', () => {
21
20
  return {
22
21
  ...jest.requireActual('@react-navigation/native'),
23
22
  useNavigation: () => ({
23
+ addListener: mockedAddListener,
24
24
  navigate: mockedNavigate,
25
25
  }),
26
26
  useIsFocused: () => ({
@@ -29,8 +29,22 @@ jest.mock('@react-navigation/native', () => {
29
29
  };
30
30
  });
31
31
 
32
+ jest.mock('axios');
33
+ jest.mock('react-native-toast-message');
34
+
35
+ jest.mock('react-redux', () => {
36
+ return {
37
+ ...jest.requireActual('react-redux'),
38
+ useDispatch: () => mockedDispatch,
39
+ useSelector: jest.fn(),
40
+ connect: () => {
41
+ return (component) => component;
42
+ },
43
+ };
44
+ });
45
+
32
46
  const wrapComponent = (route, state) => (
33
- <SCProvider initState={mockSCStore({})}>
47
+ <SCProvider initState={mockSCStore(state)}>
34
48
  <MemberList route={route} />
35
49
  </SCProvider>
36
50
  );
@@ -60,6 +74,17 @@ describe('test MemberList', () => {
60
74
  };
61
75
  });
62
76
 
77
+ afterEach(() => {
78
+ axios.get.mockClear();
79
+ });
80
+
81
+ test('render MemberList', async () => {
82
+ await act(async () => {
83
+ await create(wrapComponent(route, localState));
84
+ });
85
+ expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(1), {});
86
+ });
87
+
63
88
  test('AlertAction rightButtonClick', async () => {
64
89
  let tree;
65
90
  await act(async () => {
@@ -70,11 +95,100 @@ describe('test MemberList', () => {
70
95
  await act(async () => {
71
96
  alertAction.props.rightButtonClick();
72
97
  });
73
- const MemberListButtons = instance.findAllByType(TouchableOpacity);
74
- await MemberListButtons[1].props.onPress();
75
- expect(mockedNavigate).toBeCalledWith(Routes.AddMemberStack, {
98
+ });
99
+
100
+ test('get dataMembers', async () => {
101
+ const response = {
102
+ status: 200,
103
+ data: [
104
+ {
105
+ id: 1,
106
+ name: 'a',
107
+ share_id: 1,
108
+ },
109
+ ],
110
+ };
111
+ axios.get.mockImplementation(async () => {
112
+ return response;
113
+ });
114
+
115
+ let tree;
116
+ await act(async () => {
117
+ tree = await create(wrapComponent(route, localState));
118
+ });
119
+ const instance = tree.root;
120
+ const sharingMember = instance.findAll(
121
+ (el) => el.props.testID === TESTID.SHARING_MEMBER
122
+ );
123
+ expect(sharingMember).toHaveLength(1);
124
+ expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(1), {});
125
+ });
126
+
127
+ test('WrapHeaderScrollable rightHeader', async () => {
128
+ const response = {
129
+ status: 200,
130
+ data: [
131
+ {
132
+ id: 1,
133
+ name: 'a',
134
+ },
135
+ ],
136
+ };
137
+ axios.get.mockImplementation(async () => {
138
+ return response;
139
+ });
140
+
141
+ let tree;
142
+ await act(async () => {
143
+ tree = await create(wrapComponent(route, localState));
144
+ });
145
+ const instance = tree.root;
146
+ const button = instance.find(
147
+ (el) =>
148
+ el.props.testID === TESTID.MEMBER_LIST_RIGHT_HEADER_TOUCH &&
149
+ el.type === TouchableOpacity
150
+ );
151
+ await act(async () => {
152
+ await button.props.onPress();
153
+ });
154
+ expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(1), {});
155
+ expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddMemberStack, {
76
156
  screen: Routes.SharingSelectPermission,
77
- params: { unit: { id: 1 } },
157
+ params: { unit: { id: route.params.unitId } },
158
+ });
159
+ });
160
+
161
+ test('WrapHeaderScrollable rightHeader but not owner', async () => {
162
+ route.params.unit.user_id = 1;
163
+ const response = {
164
+ status: 200,
165
+ data: [
166
+ {
167
+ id: 1,
168
+ name: 'a',
169
+ },
170
+ ],
171
+ };
172
+ axios.get.mockImplementation(async () => {
173
+ return response;
174
+ });
175
+
176
+ let tree;
177
+ await act(async () => {
178
+ tree = await create(wrapComponent(route, localState));
179
+ });
180
+ const instance = tree.root;
181
+ const button = instance.find(
182
+ (el) =>
183
+ el.props.testID === TESTID.MEMBER_LIST_RIGHT_HEADER_TOUCH &&
184
+ el.type === TouchableOpacity
185
+ );
186
+ const alertAction = instance.findByType(AlertAction);
187
+ expect(alertAction.props.visible).toEqual(false);
188
+ await act(async () => {
189
+ await button.props.onPress();
78
190
  });
191
+ expect(alertAction.props.visible).toEqual(true);
192
+ expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(1), {});
79
193
  });
80
194
  });
@@ -2,17 +2,16 @@ import { act } from '@testing-library/react-hooks';
2
2
  import React, { useState } from 'react';
3
3
  import { FlatList, Text, Platform } from 'react-native';
4
4
  import { create } from 'react-test-renderer';
5
- import MockAdapter from 'axios-mock-adapter';
6
-
7
5
  import SelectPermission from '../SelectPermission';
6
+ import axios from 'axios';
8
7
  import { SensorItem, TitleCheckBox } from '../Components';
9
8
  import { ViewButtonBottom } from '../../../commons';
9
+ import Routes from '../../../utils/Route';
10
10
  import { SCProvider } from '../../../context';
11
11
  import { mockSCStore } from '../../../context/mockStore';
12
12
  import API from '../../../configs/API';
13
- import api from '../../../utils/Apis/axios';
14
13
 
15
- const mock = new MockAdapter(api.axiosInstance);
14
+ jest.mock('axios');
16
15
 
17
16
  const mockSetState = jest.fn();
18
17
  jest.mock('react', () => {
@@ -64,6 +63,7 @@ describe('Test SelectPermission', () => {
64
63
  const mockSetDataStations = jest.fn();
65
64
 
66
65
  afterEach(() => {
66
+ axios.mockClear();
67
67
  mockSetState.mockClear();
68
68
  mockSetTickAllDevice.mockClear();
69
69
  mockSetActiveItemId.mockClear();
@@ -92,16 +92,15 @@ describe('Test SelectPermission', () => {
92
92
  act(() => {
93
93
  tree = create(wrapComponent(route));
94
94
  });
95
- const instance = tree.root;
96
- const ViewButtonBottoms = instance.findAllByType(ViewButtonBottom);
97
- expect(ViewButtonBottoms).toHaveLength(1);
95
+ expect(axios.get).not.toBeCalled();
98
96
  });
99
97
 
100
98
  it('render empty list', () => {
101
99
  mockLoading();
102
100
  Platform.OS = 'ios';
101
+
103
102
  route.params.unit = 1;
104
- mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(200);
103
+ axios.get.mockImplementationOnce(() => ({ status: 200, data: [] }));
105
104
  act(() => {
106
105
  tree = create(wrapComponent(route));
107
106
  });
@@ -112,8 +111,9 @@ describe('Test SelectPermission', () => {
112
111
 
113
112
  it('test get unit fail', () => {
114
113
  mockLoading();
114
+
115
115
  route.params.unit = 1;
116
- mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(400);
116
+ axios.get.mockImplementationOnce(() => ({ status: 400, data: [] }));
117
117
  act(() => {
118
118
  tree = create(wrapComponent(route));
119
119
  });
@@ -183,15 +183,27 @@ describe('Test SelectPermission', () => {
183
183
  act(() => {
184
184
  ViewButtonBottomElement[0].props.onRightClick();
185
185
  });
186
+ expect(mockNavigate).toBeCalledWith(Routes.SharingInviteMembers, {
187
+ permissions: {
188
+ control_permissions: [{ id: 123, values: [136] }],
189
+ read_permissions: [{ id: 123, values: [137] }],
190
+ },
191
+ unit: 1,
192
+ });
186
193
  act(() => {
187
194
  ViewButtonBottomElement[0].props.onLeftClick();
188
195
  });
189
196
  expect(mockGoBack).toBeCalled();
190
197
  });
191
-
192
198
  it('test selectPermission type share_device', () => {
193
199
  mocSetdata();
194
- useState.mockImplementationOnce((init) => [true, mockSetState]);
200
+ const routes = {
201
+ params: {
202
+ unit: { id: 1 },
203
+ type: 'share_device',
204
+ member: { id: 1, name: 'a', phone_number: '89898888' },
205
+ },
206
+ };
195
207
  const response = {
196
208
  status: 200,
197
209
  data: [
@@ -211,30 +223,28 @@ describe('Test SelectPermission', () => {
211
223
  },
212
224
  ],
213
225
  };
214
- mock
215
- .onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1))
216
- .reply(200, response.data);
217
- const routes = {
218
- params: {
219
- unit: { id: 1 },
220
- type: 'update_shared',
221
- member: {
222
- id: 1,
223
- name: 'a',
224
- phone_number: '89898888',
225
- email: 'abcderfg@gmail.com',
226
- },
227
- },
228
- };
226
+ axios.get.mockImplementation(async () => {
227
+ return response;
228
+ });
229
229
  act(() => {
230
230
  tree = create(wrapComponent(routes));
231
231
  });
232
232
  const instance = tree.root;
233
233
  const ViewButtonBottomElement = instance.findAllByType(ViewButtonBottom);
234
+ expect(ViewButtonBottomElement).toHaveLength(1);
235
+ expect(axios.get).toHaveBeenCalledWith(
236
+ API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1),
237
+ {}
238
+ );
234
239
  act(() => {
235
240
  ViewButtonBottomElement[0].props.onRightClick();
236
241
  });
237
- mock.onPost(API.SHARE.SHARE()).reply(200);
238
- expect(mockGoBack).toBeCalled();
242
+ expect(mockNavigate).toBeCalledWith(Routes.SharingInviteMembers, {
243
+ permissions: {
244
+ control_permissions: [{ id: 123, values: [136] }],
245
+ read_permissions: [{ id: 123, values: [137] }],
246
+ },
247
+ unit: 1,
248
+ });
239
249
  });
240
250
  });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
3
+ import axios from 'axios';
4
4
 
5
5
  import SelectUser from '../SelectUser';
6
6
  import { TESTID } from '../../../configs/Constants';
@@ -11,7 +11,6 @@ import { API } from '../../../configs';
11
11
  import { getTranslate } from '../../../utils/I18n';
12
12
  import { SCProvider } from '../../../context';
13
13
  import { mockSCStore } from '../../../context/mockStore';
14
- import api from '../../../utils/Apis/axios';
15
14
 
16
15
  const wrapComponent = (route) => (
17
16
  <SCProvider initState={mockSCStore({})}>
@@ -19,13 +18,13 @@ const wrapComponent = (route) => (
19
18
  </SCProvider>
20
19
  );
21
20
 
22
- const mock = new MockAdapter(api.axiosInstance);
23
-
24
21
  const mockedNavigate = jest.fn();
25
22
  const mockedGoBack = jest.fn();
26
23
  const mockedDangerouslyGetState = jest.fn();
27
24
  const mockedDangerouslyGetParentGoBack = jest.fn();
28
25
 
26
+ jest.mock('axios');
27
+
29
28
  jest.mock('react-redux', () => {
30
29
  return {
31
30
  ...jest.requireActual('react-redux'),
@@ -53,6 +52,7 @@ describe('test SelectUser container', () => {
53
52
  let route;
54
53
 
55
54
  beforeEach(() => {
55
+ axios.post.mockClear();
56
56
  route = {
57
57
  params: {
58
58
  unit: {
@@ -70,6 +70,12 @@ describe('test SelectUser container', () => {
70
70
  return instance.find((el) => el.props.testID === id);
71
71
  };
72
72
 
73
+ const mockAxiosPost = (response) => {
74
+ axios.post.mockImplementation(async () => {
75
+ return await response;
76
+ });
77
+ };
78
+
73
79
  test('create', async () => {
74
80
  await act(async () => {
75
81
  tree = create(wrapComponent(route));
@@ -119,7 +125,11 @@ describe('test SelectUser container', () => {
119
125
  });
120
126
 
121
127
  test('_TextInput onChange phone, invalidate and not call api sharedPermission', async () => {
122
- mock.onPost(API.SHARE.SHARE()).reply(200);
128
+ const response = {
129
+ status: 200,
130
+ };
131
+ mockAxiosPost(response);
132
+
123
133
  await act(async () => {
124
134
  tree = create(wrapComponent(route));
125
135
  });
@@ -141,37 +151,48 @@ describe('test SelectUser container', () => {
141
151
  expect(textInput.props.errorText).toEqual(
142
152
  getTranslate('en', 'invalid_phone_number_or_email')
143
153
  );
154
+ expect(axios.post).not.toHaveBeenCalled();
144
155
  });
145
156
 
146
157
  test('_TextInput onChange phone, validated and call api sharedPermission', async () => {
158
+ const response = {
159
+ status: 200,
160
+ data: {
161
+ user: {
162
+ id: 2,
163
+ name: 'user add',
164
+ },
165
+ },
166
+ };
167
+ mockAxiosPost(response);
168
+
147
169
  await act(async () => {
148
170
  tree = create(wrapComponent(route));
149
171
  });
150
172
  const instance = tree.root;
173
+
151
174
  const textInput = instance.findByType(_TextInput);
152
175
  const button = instance.findByType(Button);
176
+
153
177
  let accountList = instance.findAllByType(AccountList);
154
178
  expect(accountList).toHaveLength(0);
179
+
155
180
  await act(async () => {
156
181
  await textInput.props.onChange('0909123456');
157
182
  });
158
- mock.onPost(API.SHARE.SHARE()).reply(200, {
159
- user: {
160
- id: 2,
161
- name: 'user add',
162
- phone_number: '0909123456',
163
- },
164
- });
183
+
165
184
  await act(async () => {
166
185
  await button.props.onPress();
167
186
  });
168
- await act(async () => {
169
- await textInput.props.onChange('test123@gmail.com');
170
- });
187
+
171
188
  expect(textInput.props.errorText).toEqual('');
172
- await act(async () => {
173
- await button.props.onPress();
189
+ expect(axios.post).toHaveBeenCalledWith(API.SHARE.SHARE(), {
190
+ phone: '0909123456',
191
+ email: '',
192
+ unit: 1,
193
+ permissions: { controlPermissions: {}, readPermissions: {} },
174
194
  });
195
+
175
196
  accountList = instance.findAllByType(AccountList);
176
197
  expect(accountList).toHaveLength(1);
177
198
  });
@@ -13,7 +13,6 @@ const useDataMember = (unitId, userUnitId = undefined) => {
13
13
  const { navigate, goBack } = useNavigation();
14
14
  const [dataMembers, setDataMembers] = useState([]);
15
15
  const [isRefresh, setRefresh] = useState(false);
16
- const [loading, setLoading] = useState(true);
17
16
  const user = useSCContextSelector((state) => state?.auth?.account?.user);
18
17
  const { isOwner } = useIsOwnerOfUnit(userUnitId);
19
18
 
@@ -43,7 +42,6 @@ const useDataMember = (unitId, userUnitId = undefined) => {
43
42
  const arrChanged = changePositionOwnerAndMe(data);
44
43
  setDataMembers(arrChanged);
45
44
  }
46
- setLoading(false);
47
45
  },
48
46
  [changePositionOwnerAndMe]
49
47
  );
@@ -84,7 +82,6 @@ const useDataMember = (unitId, userUnitId = undefined) => {
84
82
  loadMembers,
85
83
  isRefresh,
86
84
  onRefresh,
87
- loading,
88
85
  };
89
86
  };
90
87
 
@@ -1,5 +1,5 @@
1
1
  import React, { memo, useCallback, useState, useMemo } from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
2
+ import { View, TouchableOpacity, Alert } from 'react-native';
3
3
  import WrapHeaderScrollable from '../../../../commons/Sharing/WrapHeaderScrollable';
4
4
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
5
5
  import SmartTiviActionTemplate from '../../../../commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate';
@@ -14,7 +14,6 @@ import { Remote, SmartIr, Union } from '../../../../Images/SmartIr';
14
14
 
15
15
  import styles from './GroupButtonByTypeStyles';
16
16
  import { TESTID } from '../../../../configs/Constants';
17
- import { notImplemented } from '../../../../utils/Utils';
18
17
 
19
18
  const GroupButtonByType = memo(({ route }) => {
20
19
  const t = useTranslations();
@@ -39,7 +38,7 @@ const GroupButtonByType = memo(({ route }) => {
39
38
  case 'reload':
40
39
  case 'more':
41
40
  case 'done':
42
- return notImplemented(t);
41
+ return Alert.alert(t('feature_under_development'));
43
42
  default:
44
43
  return <></>;
45
44
  }
@@ -36,7 +36,7 @@ const SelectDeviceType = memo(({ route }) => {
36
36
  return (
37
37
  <View style={styles.container}>
38
38
  <HeaderCustom title={t('select_brand')} />
39
- <ScrollView scrollIndicatorInsets={{ right: 1 }}>
39
+ <ScrollView>
40
40
  <View style={styles.listBrands}>
41
41
  {!!deviceBrand &&
42
42
  deviceBrand.map((item, index) => {
@@ -25,12 +25,11 @@ import { ToastBottomHelper } from '../../utils/Utils';
25
25
  import { TESTID } from '../../configs/Constants';
26
26
  import styles from './AddSubUnitStyles';
27
27
  import useKeyboardShow from '../../hooks/Common/useKeyboardShow';
28
- import { replace } from '../../navigations/utils';
29
28
 
30
29
  const AddSubUnit = ({ route }) => {
31
30
  const t = useTranslations();
32
31
  const { dismissKeyboard } = useKeyboardShow();
33
- const { navigate, goBack, dispatch } = useNavigation();
32
+ const { navigate, goBack } = useNavigation();
34
33
  const { unit, addType, isAddUnit, location = '' } = route?.params;
35
34
  const [roomName, setRoomName] = useState('');
36
35
  const [wallpaper, setWallpaper] = useState('');
@@ -63,15 +62,13 @@ const AddSubUnit = ({ route }) => {
63
62
  }
64
63
  );
65
64
  if (success) {
66
- dispatch(
67
- replace(Routes.UnitStack, {
68
- screen: Routes.UnitDetail,
69
- params: {
70
- unitId: data?.id,
71
- routeName: Routes.DashboardStack,
72
- },
73
- })
74
- );
65
+ navigate(Routes.UnitStack, {
66
+ screen: Routes.UnitDetail,
67
+ params: {
68
+ unitId: data?.id,
69
+ routeName: Routes.DashboardStack,
70
+ },
71
+ });
75
72
  cleanData();
76
73
  } else {
77
74
  awaitCreate.current = false;
@@ -101,17 +98,15 @@ const AddSubUnit = ({ route }) => {
101
98
  });
102
99
  return;
103
100
  }
104
- dispatch(
105
- replace(Routes.UnitStack, {
106
- screen: Routes.UnitDetail,
107
- params: {
108
- unitId: unit.id,
109
- unitData: unit,
110
- isAddSubUnit: true,
111
- routeName: Routes.DashboardStack,
112
- },
113
- })
114
- );
101
+ navigate(Routes.UnitStack, {
102
+ screen: Routes.UnitDetail,
103
+ params: {
104
+ unitId: unit.id,
105
+ unitData: unit,
106
+ isAddSubUnit: true,
107
+ routeName: Routes.DashboardStack,
108
+ },
109
+ });
115
110
  cleanData();
116
111
  } else {
117
112
  awaitCreate.current = false;
@@ -128,7 +123,6 @@ const AddSubUnit = ({ route }) => {
128
123
  t,
129
124
  unit,
130
125
  addType,
131
- dispatch,
132
126
  goBack,
133
127
  route.params,
134
128
  ]);
@@ -16,7 +16,7 @@ import styles from './DetailStyles';
16
16
 
17
17
  const SubUnitDetail = ({ route }) => {
18
18
  const t = useTranslations();
19
- const { unit, station } = route.params;
19
+ const { unit, station, isGGHomeConnected } = route.params;
20
20
  const language = useSCContextSelector((state) => state.language);
21
21
  const navigation = useNavigation();
22
22
  const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
@@ -125,6 +125,7 @@ const SubUnitDetail = ({ route }) => {
125
125
  sensor={item}
126
126
  unit={unit}
127
127
  station={station}
128
+ isGGHomeConnected={isGGHomeConnected}
128
129
  />
129
130
  );
130
131
  })}
@@ -228,22 +228,20 @@ const EditSubUnit = ({ route }) => {
228
228
  setImageUrl={setImageUrl}
229
229
  optionsCapture={options}
230
230
  />
231
- {!showEdit && (
232
- <TouchableOpacity
233
- testID={TESTID.MANAGE_SUB_UNIT_REMOVE_BUTTON}
234
- onPress={onPressRemove}
235
- style={styles.removeButton}
231
+ <TouchableOpacity
232
+ testID={TESTID.MANAGE_SUB_UNIT_REMOVE_BUTTON}
233
+ onPress={onPressRemove}
234
+ style={styles.removeButton}
235
+ >
236
+ <Text
237
+ type={'H4'}
238
+ semibold
239
+ color={Colors.Red}
240
+ style={styles.removeText}
236
241
  >
237
- <Text
238
- type={'H4'}
239
- semibold
240
- color={Colors.Red}
241
- style={styles.removeText}
242
- >
243
- {t('remove_sub_unit')}
244
- </Text>
245
- </TouchableOpacity>
246
- )}
242
+ {t('remove_sub_unit')}
243
+ </Text>
244
+ </TouchableOpacity>
247
245
  </View>
248
246
  </View>
249
247
  <ModalCustom