@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,12 +1,11 @@
1
1
  import { act, renderHook } from '@testing-library/react-hooks';
2
- import MockAdapter from 'axios-mock-adapter';
3
2
  import useActivityLog from '../';
3
+ import axios from 'axios';
4
4
  import { API } from '../../../../configs';
5
+ import moment from 'moment';
5
6
  import { AUTOMATE_TYPE } from '../../../../configs/Constants';
6
- import api from '../../../../utils/Apis/axios';
7
- import { getDataForList, getEmergencyEventDataForList } from '../../utils';
8
7
 
9
- const mock = new MockAdapter(api.axiosInstance);
8
+ jest.mock('axios');
10
9
 
11
10
  describe('Test useActivityLog', () => {
12
11
  let props;
@@ -62,6 +61,7 @@ describe('Test useActivityLog', () => {
62
61
 
63
62
  beforeEach(() => {
64
63
  Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
64
+ axios.get.mockClear();
65
65
  props = {
66
66
  id: 1,
67
67
  type: 'action',
@@ -81,75 +81,103 @@ describe('Test useActivityLog', () => {
81
81
 
82
82
  it('Test onRefresh activity log of sensor', async () => {
83
83
  const { result } = renderHook(() => useActivityLog(props));
84
- mock.onGet(API.DEVICE.ACTIVITY_LOG(1)).reply(200, {
85
- results: actionLogData,
86
- count: 21,
87
- });
84
+ axios.get.mockImplementation(() => ({
85
+ status: 200,
86
+ data: {
87
+ results: actionLogData,
88
+ count: 21,
89
+ },
90
+ }));
88
91
  await act(async () => {
89
92
  await result.current.onRefresh();
90
93
  });
91
- expect(result.current.data).toEqual(getDataForList(actionLogData));
94
+ const params = new URLSearchParams();
95
+ params.append('id', 1);
96
+ params.append('page', 1);
97
+ expect(axios.get).toHaveBeenCalled();
92
98
  });
93
99
 
94
100
  it('Test onRefresh activity log of automate', async () => {
95
101
  props.type = 'automate';
96
102
  const { result } = renderHook(() => useActivityLog(props));
97
- mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
98
- results: automateLogData,
99
- count: 2,
100
- });
103
+ axios.get.mockImplementation(() => ({
104
+ status: 200,
105
+ data: {
106
+ results: automateLogData,
107
+ count: 2,
108
+ },
109
+ }));
101
110
  await act(async () => {
102
111
  await result.current.onRefresh();
103
112
  });
104
- expect(result.current.data).toEqual(getDataForList(automateLogData));
113
+ const params = new URLSearchParams();
114
+ params.append('page', 1);
115
+ expect(axios.get).toHaveBeenCalled();
105
116
  });
106
117
 
107
118
  it('Test onRefresh activity log of automate one tap', async () => {
108
119
  props.type = `automate.${AUTOMATE_TYPE.ONE_TAP}`;
109
120
  props.filterEnabled.date = true;
110
121
  const { result } = renderHook(() => useActivityLog(props));
111
- mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
112
- results: automateLogData,
113
- count: 2,
114
- });
122
+ axios.get.mockImplementation(() => ({
123
+ status: 200,
124
+ data: {
125
+ results: automateLogData,
126
+ count: 2,
127
+ },
128
+ }));
115
129
  await act(async () => {
116
130
  await result.current.onRefresh();
117
131
  });
118
- expect(result.current.data).toEqual(getDataForList(automateLogData));
132
+ const params = new URLSearchParams();
133
+ params.append('page', 1);
134
+ params.append('date_from', moment().add(-7, 'days').format('YYYY-MM-DD'));
135
+ params.append('date_to', moment().format('YYYY-MM-DD'));
136
+ expect(axios.get).toHaveBeenCalled();
119
137
  });
120
138
 
121
139
  it('Test onRefresh activity log of emergency button', async () => {
122
140
  props.type = 'emergency_event';
123
141
  const { result } = renderHook(() => useActivityLog(props));
124
- mock.onGet(API.EMERGENCY_BUTTON.ACTIVITY_LOG()).reply(200, {
125
- results: emergencyEventLogData,
126
- count: 2,
127
- });
142
+ axios.get.mockImplementation(() => ({
143
+ status: 200,
144
+ data: {
145
+ results: emergencyEventLogData,
146
+ count: 2,
147
+ },
148
+ }));
128
149
  await act(async () => {
129
150
  await result.current.onRefresh();
130
151
  });
131
- expect(result.current.data).toEqual(
132
- getEmergencyEventDataForList(emergencyEventLogData)
133
- );
152
+ const params = new URLSearchParams();
153
+ params.append('device_id', 1);
154
+ params.append('page', 1);
155
+ expect(axios.get).toHaveBeenCalled();
134
156
  });
135
157
 
136
158
  it('Test onLoadMore', async () => {
137
159
  const { result } = renderHook(() => useActivityLog(props));
138
- mock.onGet(API.DEVICE.ACTIVITY_LOG(1)).reply(200, {
139
- results: actionLogData,
140
- count: 21,
141
- });
160
+ axios.get.mockImplementation(() => ({
161
+ status: 200,
162
+ data: {
163
+ results: actionLogData,
164
+ count: 1,
165
+ },
166
+ }));
142
167
  await act(async () => {
143
168
  await result.current.onLoadMore();
144
169
  });
145
- mock.onGet(API.DEVICE.ACTIVITY_LOG(2)).reply(200, {
146
- results: actionLogData,
147
- count: 21,
148
- });
170
+ const params = new URLSearchParams();
171
+ params.append('id', 1);
172
+ params.append('page', 2);
173
+ expect(axios.get).toHaveBeenCalled();
174
+
175
+ axios.get.mockClear();
176
+
149
177
  await act(async () => {
150
178
  await result.current.onLoadMore();
151
179
  });
152
- expect(result.current.isLoading).toBeFalsy();
180
+ expect(axios.get).toHaveBeenCalledTimes(0);
153
181
  });
154
182
 
155
183
  it('Test fetchMembers', async () => {
@@ -157,20 +185,25 @@ describe('Test useActivityLog', () => {
157
185
  props.share = { id: 2 };
158
186
  props.filterEnabled.user = true;
159
187
  const { result } = renderHook(() => useActivityLog(props));
160
- mock.onGet(API.SHARE.UNITS_MEMBERS(2)).reply(200, [
161
- {
162
- id: 1,
163
- name: 'user 1',
164
- },
165
- {
166
- id: 2,
167
- name: 'user 2',
168
- },
169
- ]);
188
+ axios.get.mockImplementation(() => ({
189
+ status: 200,
190
+ data: [
191
+ {
192
+ id: 1,
193
+ name: 'user 1',
194
+ },
195
+ {
196
+ id: 2,
197
+ name: 'user 2',
198
+ },
199
+ ],
200
+ }));
170
201
  await act(async () => {
171
202
  await result.current.fetchMembers();
172
203
  });
173
- expect(result.current.data).toEqual([]);
204
+ const params = new URLSearchParams();
205
+ params.append('page', 1);
206
+ expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(2), {});
174
207
  });
175
208
 
176
209
  it('Test filter by users', async () => {
@@ -185,10 +218,13 @@ describe('Test useActivityLog', () => {
185
218
  users: userIds,
186
219
  });
187
220
  });
188
- mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
189
- results: automateLogData,
190
- count: 2,
191
- });
221
+ axios.get.mockImplementation(() => ({
222
+ status: 200,
223
+ data: {
224
+ results: automateLogData,
225
+ count: 2,
226
+ },
227
+ }));
192
228
  await act(async () => {
193
229
  await result.current.onRefresh();
194
230
  });
@@ -196,6 +232,9 @@ describe('Test useActivityLog', () => {
196
232
  userIds.map((id) => {
197
233
  params.append('users', id);
198
234
  });
199
- expect(result.current.data).toEqual(getDataForList(automateLogData));
235
+ params.append('date_from', moment().add(-7, 'days').format('YYYY-MM-DD'));
236
+ params.append('date_to', moment().format('YYYY-MM-DD'));
237
+ params.append('page', 1);
238
+ expect(axios.get).toHaveBeenCalled();
200
239
  });
201
240
  });
@@ -9,7 +9,7 @@ import { getDataForList, getEmergencyEventDataForList } from '../utils';
9
9
 
10
10
  const apiMaps = {
11
11
  ['action']: {
12
- url: () => API.DEVICE.ACTIVITY_LOG(),
12
+ url: () => API.SENSOR.ACTIVITY_LOG(),
13
13
  params: (id) => ({ id: id }),
14
14
  standardizeData: getDataForList,
15
15
  memberUrl: (id) => API.SHARE.UNITS_MEMBERS(id),
@@ -23,7 +23,7 @@ const keyExtractor = (item) => item.id;
23
23
 
24
24
  const ActivityLogScreen = ({ route }) => {
25
25
  const t = useTranslations();
26
- const { id, type, share, filterEnabled } = route.params || {};
26
+ const { id, type, share, filterEnabled } = route.params;
27
27
  const {
28
28
  data,
29
29
  isLoading,
@@ -118,7 +118,7 @@ const ActivityLogScreen = ({ route }) => {
118
118
  onMomentumScrollBegin={onMomentumScrollBegin}
119
119
  />
120
120
  </View>
121
- {(filterEnabled?.user || filterEnabled?.date) && (
121
+ {(filterEnabled.user || filterEnabled.date) && (
122
122
  <FilterPopup
123
123
  isVisible={showFilterPopup}
124
124
  onHide={setHideFilterPopup}
@@ -174,7 +174,6 @@ const AddCommonSelectSubUnit = ({ route }) => {
174
174
  <ScrollView
175
175
  style={styles.scrollContainer}
176
176
  showsVerticalScrollIndicator={false}
177
- scrollIndicatorInsets={{ right: 1 }}
178
177
  >
179
178
  <Section type={'border'}>
180
179
  {subUnits.map((item, index) => (
@@ -159,7 +159,6 @@ const AddCommonSelectUnit = ({ route }) => {
159
159
  <ScrollView
160
160
  style={styles.scrollContainer}
161
161
  showsVerticalScrollIndicator={false}
162
- scrollIndicatorInsets={{ right: 1 }}
163
162
  >
164
163
  <Section type={'border'}>
165
164
  {units.map((item, index) => (
@@ -1,18 +1,15 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
  import { TouchableOpacity } from 'react-native';
4
- import MockAdapter from 'axios-mock-adapter';
5
-
6
4
  import AddCommonSelectSubUnit from '../SelectSubUnit';
7
5
  import { ViewButtonBottom } from '../../../commons';
8
6
  import { SCProvider } from '../../../context';
9
7
  import { mockSCStore } from '../../../context/mockStore';
10
8
  import Text from '../../../commons/Text';
9
+ import axios from 'axios';
11
10
  import { TESTID } from '../../../configs/Constants';
12
- import api from '../../../utils/Apis/axios';
13
- import { API } from '../../../configs';
14
11
 
15
- const mock = new MockAdapter(api.axiosInstance);
12
+ jest.mock('axios');
16
13
 
17
14
  const mockedGoBack = jest.fn();
18
15
  const mockedNavigate = jest.fn();
@@ -98,10 +95,18 @@ describe('Test SelectSubUnit container', () => {
98
95
  });
99
96
  test(`press next to navigate ${type}`, async () => {
100
97
  const route = { params: { addType: type } };
101
- mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, [
102
- { id: 1, name: 'Unit 1' },
103
- { id: 2, name: 'Unit 2' },
104
- ]);
98
+ const response = {
99
+ status: 200,
100
+ success: true,
101
+ data: [
102
+ { id: 1, name: 'Unit 1' },
103
+ { id: 2, name: 'Unit 2' },
104
+ ],
105
+ };
106
+
107
+ axios.get.mockImplementation(async () => {
108
+ return response;
109
+ });
105
110
 
106
111
  await act(async () => {
107
112
  tree = renderer.create(wrapComponent(route));
@@ -154,13 +159,19 @@ describe('Test SelectSubUnit container', () => {
154
159
  break;
155
160
  case 'AddDeviceNewFlow':
156
161
  expect(mockedNavigate).toBeCalledWith('ConnectingProcess', {
157
- devicePrefixName: undefined,
158
162
  gateway: undefined,
159
163
  scan_sensor_data: undefined,
160
164
  station: undefined,
161
- unit: [],
162
- wifi_pass: undefined,
163
- wifi_ssid: undefined,
165
+ unit: [
166
+ {
167
+ id: 1,
168
+ name: 'Unit 1',
169
+ },
170
+ {
171
+ id: 2,
172
+ name: 'Unit 2',
173
+ },
174
+ ],
164
175
  });
165
176
  break;
166
177
  default:
@@ -1,17 +1,15 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
  import { TouchableOpacity, Platform } from 'react-native';
4
- import MockAdapter from 'axios-mock-adapter';
4
+ import axios from 'axios';
5
5
 
6
6
  import AddCommonSelectUnit from '../SelectUnit';
7
7
  import Text from '../../../commons/Text';
8
8
  import { TESTID } from '../../../configs/Constants';
9
9
  import { SCProvider } from '../../../context';
10
10
  import { mockSCStore } from '../../../context/mockStore';
11
- import api from '../../../utils/Apis/axios';
12
- import { API } from '../../../configs';
13
11
 
14
- const mock = new MockAdapter(api.axiosInstance);
12
+ jest.mock('axios');
15
13
 
16
14
  const mockedGoBack = jest.fn();
17
15
  const mockedNavigate = jest.fn();
@@ -88,7 +86,11 @@ describe('Test SelectUnit container', () => {
88
86
  { id: 2, name: 'Unit 2' },
89
87
  ],
90
88
  };
91
- mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
89
+
90
+ axios.get.mockImplementation(async () => {
91
+ return response;
92
+ });
93
+
92
94
  await act(async () => {
93
95
  tree = renderer.create(wrapComponent(route));
94
96
  });
@@ -149,6 +151,10 @@ describe('Test SelectUnit container', () => {
149
151
  describe('test single SelectUnit', () => {
150
152
  let tree;
151
153
 
154
+ beforeEach(() => {
155
+ axios.get.mockClear();
156
+ });
157
+
152
158
  test('fetch Unit success', async () => {
153
159
  Platform.OS = 'android';
154
160
  const route = { params: { addType: 'AddSubUnit' } };
@@ -160,10 +166,15 @@ describe('test single SelectUnit', () => {
160
166
  { id: 2, name: 'Unit 2' },
161
167
  ],
162
168
  };
163
- mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
169
+
170
+ axios.get.mockImplementation(async () => {
171
+ return response;
172
+ });
173
+
164
174
  await act(async () => {
165
175
  tree = renderer.create(wrapComponent(route));
166
176
  });
177
+
167
178
  const instance = tree.root;
168
179
  const unitName = instance.findAll(
169
180
  (item) =>
@@ -172,23 +183,35 @@ describe('test single SelectUnit', () => {
172
183
  const radioButton = instance.findAll(
173
184
  (item) => item.props.testID === TESTID.SELECT_UNIT_RADIO_BUTTON
174
185
  );
186
+
175
187
  expect(unitName[0].props.children).toBe('Unit 1');
176
188
  expect(unitName[1].props.children).toBe('Unit 2');
177
189
  expect(radioButton[0].props.active).toBeFalsy();
178
190
  expect(radioButton[1].props.active).toBeFalsy();
191
+
179
192
  const selectUnit = instance.findAll(
180
193
  (item) => item.props.testID === TESTID.SELECT_UNIT_SELECT
181
194
  );
195
+
182
196
  await act(async () => {
183
197
  selectUnit[0].props.onPress();
184
198
  });
199
+
185
200
  expect(radioButton[0].props.active).toBeTruthy();
186
201
  });
187
202
 
188
203
  test('fetch Unit not success', async () => {
189
204
  Platform.OS = 'ios';
190
205
  const route = { params: { addType: 'AddSubUnit' } };
191
- mock.onGet(500);
206
+ const response = {
207
+ status: 500,
208
+ success: false,
209
+ };
210
+
211
+ axios.get.mockImplementation(async () => {
212
+ return response;
213
+ });
214
+
192
215
  await act(async () => {
193
216
  tree = renderer.create(wrapComponent(route));
194
217
  });
@@ -201,8 +224,9 @@ describe('test single SelectUnit', () => {
201
224
  const radioButton = instance.findAll(
202
225
  (item) => item.props.testID === TESTID.SELECT_UNIT_RADIO_BUTTON
203
226
  );
204
- expect(unitName).toHaveLength(2);
205
- expect(radioButton).toHaveLength(2);
227
+
228
+ expect(unitName).toHaveLength(0);
229
+ expect(radioButton).toHaveLength(0);
206
230
  });
207
231
 
208
232
  test('click goBack', async () => {
@@ -45,9 +45,9 @@ const AddLocationMaps = memo(() => {
45
45
  goBack();
46
46
  }, [goBack]);
47
47
 
48
- const onTextInput = useCallback(async (newValue) => {
49
- setInput(newValue);
50
- if (!newValue) {
48
+ const onTextInput = useCallback(async (input) => {
49
+ setInput(input);
50
+ if (!input) {
51
51
  setSearchData([]);
52
52
  setSearchedLocation(null);
53
53
  return;
@@ -55,7 +55,7 @@ const AddLocationMaps = memo(() => {
55
55
  try {
56
56
  const config = {
57
57
  params: {
58
- input: newValue,
58
+ input: input,
59
59
  key: SCConfig.GOOGLE_MAP_API_KEY,
60
60
  sessiontoken: 123456324,
61
61
  strictBounds: false,
@@ -70,7 +70,6 @@ const AddLocationMaps = memo(() => {
70
70
  if (success) {
71
71
  setSearchData(data.predictions);
72
72
  }
73
- // eslint-disable-next-line no-empty
74
73
  } catch (error) {}
75
74
  }, []);
76
75
 
@@ -170,10 +169,7 @@ const AddLocationMaps = memo(() => {
170
169
  </Text>
171
170
  <View style={styles.searchLocation}>
172
171
  <SearchBarLocation input={input} onTextInput={onTextInput} />
173
- <ScrollView
174
- style={styles.searchData}
175
- scrollIndicatorInsets={{ right: 1 }}
176
- >
172
+ <ScrollView style={styles.searchData}>
177
173
  {searchData.map((item) => (
178
174
  <RowLocation item={item} onPress={onPressRowLocation} />
179
175
  ))}
@@ -21,7 +21,7 @@ import { TitleCheckBox } from '../Sharing/Components';
21
21
  import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
22
22
  import { popAction } from '../../navigations/utils';
23
23
  import { LoadingSelectAction } from './Components';
24
- import { notImplemented, ToastBottomHelper } from '../../utils/Utils';
24
+ import { ToastBottomHelper } from '../../utils/Utils';
25
25
 
26
26
  const SelectAction = memo(({ route }) => {
27
27
  const t = useTranslations();
@@ -48,10 +48,10 @@ const SelectAction = memo(({ route }) => {
48
48
  const fetchData = useCallback(async () => {
49
49
  isSelectSensor && setIsLoading(true);
50
50
  setIsfetched(true);
51
- const { success, data: automateData } = await axiosGet(
51
+ const { success, data } = await axiosGet(
52
52
  isSelectSensor
53
53
  ? API.AUTOMATE.GET_SENSOR_CONFIG(device.id)
54
- : API.DEVICE.DISPLAY_ACTIONS(device.id),
54
+ : API.SENSOR.DISPLAY_ACTIONS(device.id),
55
55
  isSelectSensor && {},
56
56
  isSelectSensor && true
57
57
  );
@@ -78,21 +78,21 @@ const SelectAction = memo(({ route }) => {
78
78
  const condition = conditionType.find((item) => {
79
79
  return item.conditionValue === automate.condition;
80
80
  });
81
- const updateSensorData = automateData.map((obj) =>
81
+ const updateSensorData = data.map((obj) =>
82
82
  obj.id === automate.config_id
83
83
  ? { ...obj, value: automate.value, ...condition }
84
84
  : obj
85
85
  );
86
- let selectSensor = automateData.find((config) => {
86
+ let selectSensor = data.find((config) => {
87
87
  return config.id === automate.config_id;
88
88
  });
89
89
  setSensorData(updateSensorData);
90
90
  setCheckedItem(selectSensor);
91
91
  } else {
92
- setSensorData(automateData);
92
+ setSensorData(data);
93
93
  }
94
94
  } else {
95
- setData(automateData);
95
+ setData(data);
96
96
  }
97
97
  }
98
98
  setIsfetched(false);
@@ -265,7 +265,7 @@ const SelectAction = memo(({ route }) => {
265
265
  dispatch(popAction(3));
266
266
  isAutomateTab && goBack();
267
267
  } else {
268
- notImplemented(t);
268
+ alert(t('feature_under_development'));
269
269
  }
270
270
  // eslint-disable-next-line react-hooks/exhaustive-deps
271
271
  }, [route.params]);
@@ -28,7 +28,6 @@ const SelectSensorDevices = memo(({ route }) => {
28
28
  isAutomateTab,
29
29
  isCreateNewAction,
30
30
  isMultiUnits,
31
- oldType,
32
31
  } = route.params;
33
32
 
34
33
  const [listStation, setListStation] = useState([]);
@@ -138,7 +137,7 @@ const SelectSensorDevices = memo(({ route }) => {
138
137
  navigate(Routes.ScriptDetail, {
139
138
  id: automateId,
140
139
  name: scriptName,
141
- type: oldType,
140
+ type: type,
142
141
  havePermission: true,
143
142
  unit,
144
143
  isMultiUnits,
@@ -176,7 +175,6 @@ const SelectSensorDevices = memo(({ route }) => {
176
175
  <ScrollView
177
176
  style={styles.wrap}
178
177
  contentContainerStyle={styles.contentContainerStyle}
179
- scrollIndicatorInsets={{ right: 1 }}
180
178
  >
181
179
  <Text bold type="H2" style={styles.title}>
182
180
  {t(title)}
@@ -218,11 +216,7 @@ const SelectSensorDevices = memo(({ route }) => {
218
216
  style={styles.bottomButtonView}
219
217
  mainTitle={t('continue')}
220
218
  onPressMain={onPressContinue}
221
- typeMain={
222
- Object.keys(selectedDevice || {}).length === 0
223
- ? 'disabled'
224
- : 'primary'
225
- }
219
+ typeMain={selectedDevice ? 'primary' : 'disabled'}
226
220
  />
227
221
  </View>
228
222
  );
@@ -45,13 +45,13 @@ const SetUpSensor = () => {
45
45
  const [isShowModal, setIsShowModal] = useState(false);
46
46
  const [itemActiveModal, setItemActiveModal] = useState(modalData[0]);
47
47
  const [value, setValue] = useState(parseFloat(item?.value || 0));
48
- const [minimum] = useState(isHasLimit ? parseInt(item?.range_min, 10) : 0);
48
+ const [minimum] = useState(isHasLimit ? parseInt(item?.range_min) : 0);
49
49
  const [maximum, setMaximum] = useState(
50
50
  value === 0
51
51
  ? 100
52
52
  : isHasLimit
53
- ? (parseInt(item?.range_max, 10) - minimum) * 10 + minimum
54
- : (parseInt(item?.value, 10) + 20 - minimum) * 10 + minimum
53
+ ? (parseInt(item?.range_max) - minimum) * 10 + minimum
54
+ : (parseInt(item?.value) + 20 - minimum) * 10 + minimum
55
55
  );
56
56
 
57
57
  const onOpenModal = useCallback(() => {
@@ -62,8 +62,8 @@ const SetUpSensor = () => {
62
62
  setIsShowModal(false);
63
63
  }, []);
64
64
 
65
- const onChooseCondition = (selectedItem) => () => {
66
- setItemActiveModal(selectedItem);
65
+ const onChooseCondition = (item) => () => {
66
+ setItemActiveModal(item);
67
67
  onCloseModal();
68
68
  };
69
69
 
@@ -74,9 +74,9 @@ const SetUpSensor = () => {
74
74
  }, []);
75
75
 
76
76
  const onChangeValue = useCallback(
77
- (newValue) => {
77
+ (value) => {
78
78
  setValue(
79
- (parseFloat(newValue / 128) + parseFloat(minimum)).toFixed(
79
+ (parseFloat(value / 128) + parseFloat(minimum)).toFixed(
80
80
  item?.decimal_behind || 1
81
81
  )
82
82
  );