@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,25 +1,11 @@
1
- /* eslint-disable promise/prefer-await-to-callbacks */
2
1
  import { TESTID } from '../../../configs/Constants';
3
2
  import { watchMultiConfigs } from '../../../iot/Monitor';
4
3
  import React from 'react';
5
4
  import { View } from 'react-native';
6
- import { useSelector } from 'react-redux';
7
5
  import { act, create } from 'react-test-renderer';
8
6
  import OnOffTemplate from '../OnOffTemplate';
9
7
  import OnOffButtonTemplate from '../OnOffTemplate/OnOffButtonTemplate';
10
8
  import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
11
- import { mockSCStore } from '../../../context/mockStore';
12
- import { SCProvider } from '../../../context';
13
-
14
- const wrapComponent = (actionGroup, mockDoAction, sensor) => (
15
- <SCProvider initState={mockSCStore({})}>
16
- <OnOffTemplate
17
- actionGroup={actionGroup}
18
- doAction={mockDoAction}
19
- sensor={sensor}
20
- />
21
- </SCProvider>
22
- );
23
9
 
24
10
  jest.mock('../../../iot/Monitor');
25
11
 
@@ -27,15 +13,9 @@ jest.mock('../../../iot/states', () => ({
27
13
  useConfigGlobalState: () => [{ 5: 2 }, null],
28
14
  }));
29
15
 
30
- jest.mock('react-redux', () => ({
31
- ...jest.requireActual('react-redux'),
32
- useSelector: jest.fn(),
33
- }));
34
-
35
16
  describe('Test OnOffTemplate', () => {
17
+ let wrapper;
36
18
  let actionGroup;
37
- let tree;
38
- let sensor;
39
19
 
40
20
  const action_data = {
41
21
  color: '#00979D',
@@ -82,23 +62,20 @@ describe('Test OnOffTemplate', () => {
82
62
  },
83
63
  title: 'Turn on / off',
84
64
  };
85
-
86
- sensor = { name: 'Sensor' };
87
-
88
- const localState = {
89
- isOnSwich: false,
90
- };
91
- useSelector.mockImplementation((cb) => {
92
- return cb(localState);
93
- });
94
65
  });
95
66
 
96
67
  test('render with template OnOffSimpleActionTemplate', async () => {
97
68
  const mockDoAction = jest.fn();
98
69
  await act(async () => {
99
- tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
70
+ wrapper = await create(
71
+ <OnOffTemplate
72
+ actionGroup={actionGroup}
73
+ doAction={mockDoAction}
74
+ sensor={{}}
75
+ />
76
+ );
100
77
  });
101
- const instance = tree.root;
78
+ const instance = wrapper.root;
102
79
  const template = instance.findAllByType(OnOffSimpleTemplate);
103
80
  expect(template).toHaveLength(1);
104
81
  });
@@ -107,9 +84,15 @@ describe('Test OnOffTemplate', () => {
107
84
  actionGroup.template = 'on_off_button_action_template';
108
85
  const mockDoAction = jest.fn();
109
86
  await act(async () => {
110
- tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
87
+ wrapper = await create(
88
+ <OnOffTemplate
89
+ actionGroup={actionGroup}
90
+ doAction={mockDoAction}
91
+ sensor={{}}
92
+ />
93
+ );
111
94
  });
112
- const instance = tree.root;
95
+ const instance = wrapper.root;
113
96
  const template = instance.findAllByType(OnOffButtonTemplate);
114
97
  expect(template).toHaveLength(0);
115
98
  });
@@ -118,9 +101,15 @@ describe('Test OnOffTemplate', () => {
118
101
  actionGroup.template = 'wrong_template';
119
102
  const mockDoAction = jest.fn();
120
103
  await act(async () => {
121
- tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
104
+ wrapper = await create(
105
+ <OnOffTemplate
106
+ actionGroup={actionGroup}
107
+ doAction={mockDoAction}
108
+ sensor={{}}
109
+ />
110
+ );
122
111
  });
123
- const instance = tree.root;
112
+ const instance = wrapper.root;
124
113
 
125
114
  const templateOnOffButton = instance.findAll(
126
115
  (el) =>
@@ -136,20 +125,32 @@ describe('Test OnOffTemplate', () => {
136
125
  test('render with template OnOffSimpleActionTemplate with is_managed_by_backend', async () => {
137
126
  const mockDoAction = jest.fn();
138
127
  await act(async () => {
139
- tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
128
+ wrapper = await create(
129
+ <OnOffTemplate
130
+ actionGroup={actionGroup}
131
+ doAction={mockDoAction}
132
+ sensor={{ is_managed_by_backend: true }}
133
+ />
134
+ );
140
135
  });
141
- const instance = tree.root;
136
+ const instance = wrapper.root;
142
137
  const template = instance.findAllByType(OnOffSimpleTemplate);
143
138
  expect(template).toHaveLength(1);
144
- expect(watchMultiConfigs).toBeCalledTimes(0);
139
+ expect(watchMultiConfigs).toBeCalledTimes(1);
145
140
  });
146
141
 
147
142
  test('template OnOffSimpleActionTemplate doAction with is_on_value, match configValue', async () => {
148
143
  const mockDoAction = jest.fn();
149
144
  await act(async () => {
150
- tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
145
+ wrapper = await create(
146
+ <OnOffTemplate
147
+ actionGroup={actionGroup}
148
+ doAction={mockDoAction}
149
+ sensor={{ name: 'Sensor name' }}
150
+ />
151
+ );
151
152
  });
152
- const instance = tree.root;
153
+ const instance = wrapper.root;
153
154
  const template = instance.findByType(OnOffSimpleTemplate);
154
155
  expect(template.props.isOn).toEqual(true);
155
156
 
@@ -159,7 +160,7 @@ describe('Test OnOffTemplate', () => {
159
160
  expect(mockDoAction).toHaveBeenCalledWith(
160
161
  action_off_data,
161
162
  null,
162
- 'Sensor turn on / off off'
163
+ 'Sensor name turn on / off off'
163
164
  );
164
165
  expect(watchMultiConfigs).toBeCalledTimes(0);
165
166
  });
@@ -168,9 +169,15 @@ describe('Test OnOffTemplate', () => {
168
169
  actionGroup.configuration.is_on_value = [1];
169
170
  const mockDoAction = jest.fn();
170
171
  await act(async () => {
171
- tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
172
+ wrapper = await create(
173
+ <OnOffTemplate
174
+ actionGroup={actionGroup}
175
+ doAction={mockDoAction}
176
+ sensor={{ name: 'Sensor name' }}
177
+ />
178
+ );
172
179
  });
173
- const instance = tree.root;
180
+ const instance = wrapper.root;
174
181
  const template = instance.findByType(OnOffSimpleTemplate);
175
182
  expect(template.props.isOn).toEqual(false);
176
183
 
@@ -180,16 +187,22 @@ describe('Test OnOffTemplate', () => {
180
187
  expect(mockDoAction).toHaveBeenCalledWith(
181
188
  action_on_data,
182
189
  null,
183
- 'Sensor turn on / off on'
190
+ 'Sensor name turn on / off on'
184
191
  );
185
192
  });
186
193
 
187
194
  test('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
188
195
  const mockDoAction = jest.fn();
189
196
  await act(async () => {
190
- tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
197
+ wrapper = await create(
198
+ <OnOffTemplate
199
+ actionGroup={actionGroup}
200
+ doAction={mockDoAction}
201
+ sensor={{ name: 'Sensor name', is_managed_by_backend: true }}
202
+ />
203
+ );
191
204
  });
192
- const instance = tree.root;
205
+ const instance = wrapper.root;
193
206
  const template = instance.findByType(OnOffSimpleTemplate);
194
207
  expect(template.props.isOn).toEqual(true);
195
208
 
@@ -199,9 +212,9 @@ describe('Test OnOffTemplate', () => {
199
212
  expect(mockDoAction).toHaveBeenCalledWith(
200
213
  action_off_data,
201
214
  null,
202
- 'Sensor turn on / off off'
215
+ 'Sensor name turn on / off off'
203
216
  );
204
- expect(watchMultiConfigs).toBeCalledTimes(0);
217
+ expect(watchMultiConfigs).toBeCalledTimes(2);
205
218
  });
206
219
 
207
220
  test('render with template OnOffSimpleActionTemplate with just action_data', async () => {
@@ -217,9 +230,15 @@ describe('Test OnOffTemplate', () => {
217
230
  };
218
231
  const mockDoAction = jest.fn();
219
232
  await act(async () => {
220
- tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
233
+ wrapper = await create(
234
+ <OnOffTemplate
235
+ actionGroup={actionGroup}
236
+ doAction={mockDoAction}
237
+ sensor={{ is_managed_by_backend: true }}
238
+ />
239
+ );
221
240
  });
222
- const instance = tree.root;
241
+ const instance = wrapper.root;
223
242
  const template = instance.findAllByType(OnOffSimpleTemplate);
224
243
  expect(template).toHaveLength(1);
225
244
  expect(template[0].props.disabled).toBeFalsy();
@@ -242,9 +261,15 @@ describe('Test OnOffTemplate', () => {
242
261
  };
243
262
  const mockDoAction = jest.fn();
244
263
  await act(async () => {
245
- tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
264
+ wrapper = await create(
265
+ <OnOffTemplate
266
+ actionGroup={actionGroup}
267
+ doAction={mockDoAction}
268
+ sensor={{ is_managed_by_backend: true }}
269
+ />
270
+ );
246
271
  });
247
- const instance = tree.root;
272
+ const instance = wrapper.root;
248
273
  const template = instance.findAllByType(OnOffSimpleTemplate);
249
274
  expect(template).toHaveLength(1);
250
275
  expect(template[0].props.disabled).toBeTruthy();
@@ -1,27 +1,8 @@
1
- /* eslint-disable promise/prefer-await-to-callbacks */
2
1
  import React from 'react';
3
2
  import { create, act } from 'react-test-renderer';
4
3
  import { TouchableOpacity } from 'react-native';
5
- import { useSelector } from 'react-redux';
6
4
 
7
5
  import OneBigButtonTemplate from '../OneBigButtonTemplate';
8
- import { mockSCStore } from '../../../context/mockStore';
9
- import { SCProvider } from '../../../context';
10
-
11
- const wrapComponent = (actionGroup, mockDoAction, sensor) => (
12
- <SCProvider initState={mockSCStore({})}>
13
- <OneBigButtonTemplate
14
- actionGroup={actionGroup}
15
- doAction={mockDoAction}
16
- sensor={sensor}
17
- />
18
- </SCProvider>
19
- );
20
-
21
- jest.mock('react-redux', () => ({
22
- ...jest.requireActual('react-redux'),
23
- useSelector: jest.fn(),
24
- }));
25
6
 
26
7
  describe('Test OneBigButtonTemplate', () => {
27
8
  const action_data = {
@@ -42,25 +23,24 @@ describe('Test OneBigButtonTemplate', () => {
42
23
  text: 'UP',
43
24
  },
44
25
  };
45
- let tree;
46
- let sensor;
47
-
48
- beforeEach(() => {
49
- const localState = {
50
- isOnSwich: false,
51
- };
52
- useSelector.mockImplementation((cb) => {
53
- return cb(localState);
54
- });
55
- sensor = { name: 'Sensor' };
56
- });
26
+ const sensor = {
27
+ name: 'Sensor name',
28
+ };
29
+ let wrapper;
57
30
 
58
- test('render OneBigButtonTemplate', async () => {
31
+ test('render OneBigButtonTemplate', () => {
59
32
  const mockDoAction = jest.fn();
60
- await act(async () => {
61
- tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
33
+ act(() => {
34
+ wrapper = create(
35
+ <OneBigButtonTemplate
36
+ actionGroup={actionGroup}
37
+ doAction={mockDoAction}
38
+ sensor={sensor}
39
+ />
40
+ );
62
41
  });
63
- const instance = tree.root;
42
+
43
+ const instance = wrapper.root;
64
44
  const buttons = instance.findAllByType(TouchableOpacity);
65
45
  expect(buttons.length).toEqual(1);
66
46
 
@@ -69,6 +49,10 @@ describe('Test OneBigButtonTemplate', () => {
69
49
  });
70
50
 
71
51
  expect(mockDoAction).toHaveBeenCalledTimes(1);
72
- expect(mockDoAction).toHaveBeenCalledWith(action_data, null, 'Sensor up');
52
+ expect(mockDoAction).toHaveBeenCalledWith(
53
+ action_data,
54
+ null,
55
+ 'Sensor name up'
56
+ );
73
57
  });
74
58
  });
@@ -5,7 +5,7 @@ import { act, create } from 'react-test-renderer';
5
5
  import Text from '../../../commons/Text';
6
6
  import { watchMultiConfigs } from '../../../iot/Monitor';
7
7
  import { AlertAction, RadioCircle } from '../../../commons';
8
- import { TESTID } from '../../../configs/Constants';
8
+ import { DEVICE_TYPE, TESTID } from '../../../configs/Constants';
9
9
  import { getTranslate } from '../../../utils/I18n';
10
10
  import { SCProvider } from '../../../context';
11
11
  import { mockSCStore } from '../../../context/mockStore';
@@ -246,4 +246,60 @@ describe('Test OptionsDropdownActionTemplate', () => {
246
246
  getTranslate('en', 'not_available')
247
247
  );
248
248
  });
249
+ test('doAction sensor device type is GOOGLE_HOME', async () => {
250
+ actionGroup.configuration.options[0].value_text = 'level-1';
251
+ sensor.device_type = DEVICE_TYPE.GOOGLE_HOME;
252
+ const mockDoAction = jest.fn();
253
+ await act(async () => {
254
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
255
+ });
256
+ const instance = wrapper.root;
257
+
258
+ const touchs = instance.findAllByType(TouchableOpacity);
259
+ expect(touchs).toHaveLength(5);
260
+ const showListOption = touchs[0];
261
+
262
+ const texts = instance.findAllByType(Text);
263
+ expect(texts[1].props.children).toEqual('Level2');
264
+
265
+ const radioCircles = instance.findAllByType(RadioCircle);
266
+ expect(radioCircles[0].props.active).toBeFalsy();
267
+ expect(radioCircles[1].props.active).toBeTruthy();
268
+
269
+ const listChoosingOption = instance.findAll(
270
+ (el) =>
271
+ el.props.testID === TESTID.OPTIONS_DROPDOWN_ACTION_CHOOSING_ITEM &&
272
+ el.type === TouchableOpacity
273
+ );
274
+ expect(listChoosingOption).toHaveLength(2);
275
+
276
+ const alertAction = instance.findByType(AlertAction);
277
+ expect(alertAction.props.visible).toBeFalsy();
278
+
279
+ // show option
280
+ await act(async () => {
281
+ await showListOption.props.onPress();
282
+ });
283
+ expect(alertAction.props.visible).toBeTruthy();
284
+
285
+ // Choosed Level1 option
286
+ await act(async () => {
287
+ await listChoosingOption[0].props.onPress();
288
+ });
289
+
290
+ expect(radioCircles[0].props.active).toBeTruthy();
291
+ expect(radioCircles[1].props.active).toBeFalsy();
292
+
293
+ // doAction then update selectedOption
294
+ await act(async () => {
295
+ await alertAction.props.rightButtonClick();
296
+ });
297
+ expect(alertAction.props.visible).toBeFalsy();
298
+
299
+ expect(mockDoAction).toHaveBeenCalledWith(
300
+ action_data,
301
+ 'level-1',
302
+ 'Sensor name fan speed level-1'
303
+ ); // doAction with text instead of int
304
+ });
249
305
  });
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
- import { Switch, TouchableOpacity } from 'react-native';
2
+ import { Switch } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
4
  import TimerActionTemplate from '../TimerActionTemplate';
5
5
  import DateTimePickerModal from 'react-native-modal-datetime-picker';
6
- import ScrollPicker from 'react-native-wheel-scrollview-picker';
7
-
8
6
  import moment from 'moment';
9
7
  import Text from '../../Text';
10
8
  import { watchMultiConfigs } from '../../../iot/Monitor';
@@ -17,14 +15,12 @@ jest.mock('../../../iot/states', () => ({
17
15
  useConfigGlobalState: () => [{ 5: 18, 6: 30 }, null],
18
16
  }));
19
17
 
20
- const mockDoAction = jest.fn();
21
-
22
- const wrapComponent = (actionGroup, sensor) => (
18
+ const wrapComponent = (actionGroup, mockDoAction, is_managed_by_backend) => (
23
19
  <SCProvider initState={mockSCStore({})}>
24
20
  <TimerActionTemplate
25
21
  actionGroup={actionGroup}
26
22
  doAction={mockDoAction}
27
- sensor={sensor}
23
+ sensor={{ is_managed_by_backend }}
28
24
  />
29
25
  </SCProvider>
30
26
  );
@@ -43,7 +39,6 @@ describe('Test TimerActionTemplate success with config value', () => {
43
39
 
44
40
  let actionGroup;
45
41
  let wrapper;
46
- let sensor;
47
42
 
48
43
  beforeEach(() => {
49
44
  watchMultiConfigs.mockClear();
@@ -55,24 +50,12 @@ describe('Test TimerActionTemplate success with config value', () => {
55
50
  config_minute: 6,
56
51
  },
57
52
  };
58
- sensor = {
59
- is_managed_by_backend: true,
60
- device_type: '',
61
- };
62
- });
63
-
64
- test('render without params', async () => {
65
- await act(async () => {
66
- wrapper = await create(wrapComponent());
67
- });
68
- const instance = wrapper.root;
69
- const texts = instance.findAllByType(Text);
70
- expect(texts).toHaveLength(6);
71
53
  });
72
54
 
73
55
  test('render template', async () => {
56
+ const mockDoAction = jest.fn();
74
57
  await act(async () => {
75
- wrapper = await create(wrapComponent(actionGroup, sensor));
58
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
76
59
  });
77
60
  const instance = wrapper.root;
78
61
 
@@ -83,46 +66,11 @@ describe('Test TimerActionTemplate success with config value', () => {
83
66
 
84
67
  const switchButton = instance.findByType(Switch);
85
68
  expect(switchButton.props.value).toBeTruthy();
86
- await switchButton.props.onValueChange();
87
- expect(mockDoAction).toBeCalled();
88
-
89
- const bottomScrollPicker = instance.findByType(ScrollPicker);
90
- expect(bottomScrollPicker).toBeDefined();
91
- const TouchableOpacities = instance.findAllByType(TouchableOpacity);
92
- await TouchableOpacities[0].props.onPress();
93
69
 
94
70
  const dateTimePicker = instance.findByType(DateTimePickerModal);
95
- expect(dateTimePicker.props.isVisible).toBeTruthy();
71
+ expect(dateTimePicker.props.isVisible).toBeFalsy();
96
72
  expect(dateTimePicker.props.date).toEqual(
97
73
  moment('18:30', 'HH:mm').valueOf()
98
74
  );
99
75
  });
100
-
101
- test('render template with config_hour', async () => {
102
- actionGroup = {
103
- ...actionGroup,
104
- configuration: {
105
- ...actionGroup.configuration,
106
- config_hour: 5,
107
- config_minute: null,
108
- },
109
- };
110
- await act(async () => {
111
- wrapper = await create(wrapComponent(actionGroup, sensor));
112
- });
113
- const instance = wrapper.root;
114
-
115
- const bottomScrollPicker = instance.findByType(ScrollPicker);
116
- expect(bottomScrollPicker).toBeDefined();
117
-
118
- const dateTimePicker = instance.findByType(DateTimePickerModal);
119
- expect(dateTimePicker.props.isVisible).toBeFalsy();
120
- await dateTimePicker.props.onConfirm();
121
-
122
- const TouchableOpacities = instance.findAllByType(TouchableOpacity);
123
- expect(TouchableOpacities).toHaveLength(3);
124
- await TouchableOpacities[0].props.onPress();
125
- await TouchableOpacities[2].props.onPress(3);
126
- expect(mockDoAction).toBeCalled();
127
- });
128
76
  });
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
- import { DEVICE_TYPE } from '../../../configs/Constants';
5
4
  import TwoButtonTemplate from '../TwoButtonTemplate';
6
5
 
7
6
  jest.mock('react', () => ({
@@ -32,10 +31,6 @@ describe('Test TwoButtonTemplate', () => {
32
31
  key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
33
32
  };
34
33
 
35
- const sensor = {
36
- device_type: DEVICE_TYPE.LG_THINQ,
37
- is_managed_by_backend: true,
38
- };
39
34
  const actionGroup = {
40
35
  configuration: {
41
36
  button1: {
@@ -46,9 +41,6 @@ describe('Test TwoButtonTemplate', () => {
46
41
  icon_on: 'poweroff',
47
42
  text_on: 'ON',
48
43
  config: 621,
49
- is_on_value: [true],
50
- action_on_data,
51
- action_off_data,
52
44
  },
53
45
  button2: {
54
46
  action_off: 'f49e1577-493d-4bae-a9ab-3b0f96a4ec52',
@@ -58,9 +50,6 @@ describe('Test TwoButtonTemplate', () => {
58
50
  icon_on: 'caret-right',
59
51
  text_on: 'START',
60
52
  config: 621,
61
- is_on_value: [true],
62
- action_on_data,
63
- action_off_data,
64
53
  },
65
54
  },
66
55
  };
@@ -113,44 +102,7 @@ describe('Test TwoButtonTemplate', () => {
113
102
  const mockDoAction = jest.fn();
114
103
  await act(() => {
115
104
  wrapper = create(
116
- <TwoButtonTemplate
117
- actionGroup={actionGroup}
118
- doAction={mockDoAction}
119
- sensor={sensor}
120
- />
121
- );
122
- });
123
- const instance = wrapper.root;
124
- const touchableOpacities = instance.findAllByType(TouchableOpacity);
125
- expect(touchableOpacities.length).toEqual(2);
126
- await touchableOpacities[0].props.onPress();
127
- await touchableOpacities[1].props.onPress();
128
- expect(mockDoAction).toBeCalled();
129
- });
130
-
131
- test('render TouchableOpacity TwoButtonTemplate without is_on_value', async () => {
132
- const mockDoAction = jest.fn();
133
- let new_actionGroup = {
134
- ...actionGroup,
135
- configuration: {
136
- ...actionGroup.configuration,
137
- button1: {
138
- ...actionGroup.configuration.button1,
139
- is_on_value: null,
140
- },
141
- button2: {
142
- ...actionGroup.configuration.button2,
143
- is_on_value: null,
144
- },
145
- },
146
- };
147
- await act(() => {
148
- wrapper = create(
149
- <TwoButtonTemplate
150
- actionGroup={new_actionGroup}
151
- doAction={mockDoAction}
152
- sensor={sensor}
153
- />
105
+ <TwoButtonTemplate actionGroup={actionGroup} doAction={mockDoAction} />
154
106
  );
155
107
  });
156
108
  const instance = wrapper.root;