@eohjsc/react-native-smart-city 0.3.90 → 0.3.92

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 (312) hide show
  1. package/package.json +1 -1
  2. package/src/Images/Common/reorder.svg +3 -0
  3. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +1 -1
  4. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +3 -1
  5. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -10
  7. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +1 -0
  8. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +1 -1
  9. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +13 -5
  10. package/src/commons/ActionGroup/SliderRangeTemplate.js +100 -69
  11. package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +27 -27
  12. package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -1
  13. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +1 -1
  14. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -1
  15. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +56 -0
  16. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -2
  17. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +45 -8
  18. package/src/commons/ActionGroup/__test__/index.test.js +0 -19
  19. package/src/commons/ActionGroup/index.js +0 -3
  20. package/src/commons/ActionTemplate/CurtainAction.js +5 -5
  21. package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
  22. package/src/commons/ActionTemplate/OnOffButtonAction.js +4 -4
  23. package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
  24. package/src/commons/ActionTemplate/OnOffSimpleAction.js +4 -4
  25. package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
  26. package/src/commons/ActionTemplate/OnOffSmartLockAction.js +4 -4
  27. package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
  28. package/src/commons/ActionTemplate/OneButtonAction.js +3 -3
  29. package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
  30. package/src/commons/ActionTemplate/ThreeButtonAction.js +5 -5
  31. package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
  32. package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +1 -1
  33. package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +1 -1
  34. package/src/commons/ActionTemplate/__test__/OnOffSimpleAction.test.js +1 -1
  35. package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +1 -1
  36. package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +1 -1
  37. package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +1 -1
  38. package/src/commons/ActionTemplate/__test__/index.test.js +21 -70
  39. package/src/commons/ActionTemplate/index.js +19 -55
  40. package/src/commons/Alert/__test__/Alert.test.js +1 -1
  41. package/src/commons/Auth/AccountList.js +1 -1
  42. package/src/commons/Auth/__test__/OtpInputList.test.js +17 -19
  43. package/src/commons/Automate/ItemAutomate.js +10 -4
  44. package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
  45. package/src/commons/BackDefault/__test__/BackDefault.test.js +1 -1
  46. package/src/commons/Button/__test__/Button.test.js +1 -1
  47. package/src/commons/ButtonPopup/__test__/ButtonPopup.test.js +1 -1
  48. package/src/commons/Calendar/__test__/Calendar.test.js +1 -1
  49. package/src/commons/ChartLoading/__test__/ChartLoading.test.js +1 -1
  50. package/src/commons/CircleButton/__test__/CircleButton.test.js +1 -1
  51. package/src/commons/CircleView/__test__/CircleView.test.js +1 -1
  52. package/src/commons/DateTimeRangeChange/__test__/DateTimeButton.test.js +4 -2
  53. package/src/commons/DateTimeRangeChange/index.js +31 -48
  54. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  55. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +2 -2
  56. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  57. package/src/commons/Device/FlatListItems.js +1 -1
  58. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +2 -2
  59. package/src/commons/Device/HistoryChart.js +6 -49
  60. package/src/commons/Device/LinearChart/LinearChart.test.js +1 -1
  61. package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
  62. package/src/commons/Device/ProgressBar/index.js +5 -11
  63. package/src/commons/Device/ProgressBar/styles.js +11 -3
  64. package/src/commons/Device/RainningSensor/__test__/CurrentRainSensor.test.js +5 -5
  65. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +3 -3
  66. package/src/commons/Device/WindDirection/Compass/Compass.test.js +2 -2
  67. package/src/commons/Device/WindSpeed/Anemometer/index.js +2 -0
  68. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
  69. package/src/commons/Device/WindSpeed/LinearChart/index.js +5 -3
  70. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +3 -3
  71. package/src/commons/Device/__test__/DisconnectedView.test.js +2 -2
  72. package/src/commons/Device/__test__/FlatListItems.test.js +1 -1
  73. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +1 -1
  74. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  75. package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
  76. package/src/commons/FlatListDnD/index.js +37 -0
  77. package/src/commons/FlatListDnD/styles.js +12 -0
  78. package/src/commons/Form/__test__/CurrencyInput.test.js +2 -2
  79. package/src/commons/Form/__test__/TextInput.test.js +3 -3
  80. package/src/commons/Form/__test__/TextInputPassword.test.js +2 -2
  81. package/src/commons/FullLoading/__test__/index.test.js +2 -2
  82. package/src/commons/Header/HeaderCustom.js +2 -1
  83. package/src/commons/HorizontalPicker/index.js +65 -38
  84. package/src/commons/IconComponent/index.js +3 -2
  85. package/src/commons/ImageButton/__test__/ImageButton.test.js +1 -1
  86. package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
  87. package/src/commons/MediaPlayer/index.js +11 -7
  88. package/src/commons/MenuActionMore/index.js +6 -4
  89. package/src/commons/Modal/ModalBottom.js +2 -3
  90. package/src/commons/Modal/ModalCustom.js +2 -3
  91. package/src/commons/NavBar/index.js +48 -50
  92. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  93. package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
  94. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +5 -5
  95. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
  96. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +5 -5
  97. package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
  98. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +2 -2
  99. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
  100. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +2 -2
  101. package/src/commons/PreventAccess/index.js +1 -1
  102. package/src/commons/RowItem/__test__/RowItem.test.js +1 -1
  103. package/src/commons/RowUser/__test__/RowUser.test.js +1 -1
  104. package/src/commons/Section/Section.test.js +2 -2
  105. package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -1
  106. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +3 -3
  107. package/src/commons/Sharing/StationDevicePermissions.js +4 -4
  108. package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
  109. package/src/commons/Sharing/__test__/ButtonRemoveMember.test.js +1 -1
  110. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +3 -3
  111. package/src/commons/Sharing/__test__/MemberList.test.js +6 -4
  112. package/src/commons/Sharing/__test__/RowMember.test.js +2 -2
  113. package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +4 -2
  114. package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -11
  115. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +13 -16
  116. package/src/commons/SubUnit/OneTap/index.js +22 -7
  117. package/src/commons/TextButton/__test__/TextButton.test.js +2 -2
  118. package/src/commons/Today/__test__/Today.test.js +1 -1
  119. package/src/commons/TouchableScale/__test__/TouchableScale.test.js +1 -1
  120. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
  121. package/src/commons/UnitSummary/AirQuality/index.js +2 -2
  122. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  123. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +0 -6
  124. package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +1 -1
  125. package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +1 -1
  126. package/src/commons/ViewButtonBottom/__test__/ViewButtonBottom.test.js +1 -1
  127. package/src/configs/API.js +14 -31
  128. package/src/configs/AccessibilityLabel.js +1 -0
  129. package/src/configs/Colors.js +1 -1
  130. package/src/configs/Constants.js +14 -48
  131. package/src/context/reducer.ts +3 -1
  132. package/src/hoc/__test__/withRemoteControl.test.js +1 -1
  133. package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
  134. package/src/hooks/Common/index.js +0 -2
  135. package/src/hooks/Common/useKeyboardShow.js +4 -4
  136. package/src/hooks/Common/useStatusBar.js +2 -2
  137. package/src/hooks/Common/useTitleHeader.js +5 -7
  138. package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
  139. package/src/hooks/IoT/useBluetoothConnection.js +6 -3
  140. package/src/hooks/index.js +1 -2
  141. package/src/navigations/UnitStack.js +51 -17
  142. package/src/screens/ActivityLog/FilterPopup.js +4 -4
  143. package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
  144. package/src/screens/ActivityLog/__test__/index.test.js +2 -2
  145. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +3 -3
  146. package/src/screens/AddCommon/__test__/SelectUnit.test.js +5 -5
  147. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +9 -33
  148. package/src/screens/AddNewAutoSmart/index.js +33 -89
  149. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +1 -1
  150. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +1 -1
  151. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +1 -1
  152. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
  153. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
  154. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +1 -1
  155. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +2 -2
  156. package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +3 -3
  157. package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +2 -2
  158. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +8 -16
  159. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +10 -12
  160. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
  161. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
  162. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +1 -1
  163. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
  164. package/src/screens/AddNewGateway/index.js +1 -1
  165. package/src/screens/AllCamera/__test__/index.test.js +18 -57
  166. package/src/screens/AllCamera/index.js +100 -33
  167. package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
  168. package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
  169. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
  170. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
  171. package/src/screens/Automate/AddNewAction/ChooseAction.js +139 -0
  172. package/src/screens/Automate/AddNewAction/ChooseConfig.js +179 -0
  173. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
  174. package/src/screens/Automate/AddNewAction/Components/SelectDevices.js +75 -0
  175. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
  176. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +4 -4
  177. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
  178. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +56 -0
  179. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +69 -0
  180. package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +110 -0
  181. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +196 -0
  182. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
  183. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
  184. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +5 -3
  185. package/src/screens/{AddNewAction/__test__/SelectAction.test.js → Automate/AddNewAction/__test__/ChooseAction.test.js} +101 -122
  186. package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +210 -0
  187. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +130 -0
  188. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +92 -0
  189. package/src/screens/Automate/AddNewAction/__test__/SetupSensor.test.js +131 -0
  190. package/src/screens/Automate/Components/InputName.js +64 -0
  191. package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +2 -2
  192. package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
  193. package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +20 -12
  194. package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +18 -19
  195. package/src/screens/Automate/MultiUnits.js +70 -68
  196. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
  197. package/src/screens/Automate/OneTap/index.js +16 -0
  198. package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
  199. package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
  200. package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
  201. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
  202. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
  203. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +67 -76
  204. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
  205. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
  206. package/src/screens/Automate/ScriptDetail/index.js +346 -0
  207. package/src/screens/Automate/ScriptDetail/utils.js +113 -0
  208. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
  209. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
  210. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
  211. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
  212. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
  213. package/src/screens/Automate/SetSchedule/index.js +140 -0
  214. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
  215. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
  216. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
  217. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
  218. package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
  219. package/src/screens/Automate/__test__/MultiUnits.test.js +78 -122
  220. package/src/screens/Automate/__test__/index.test.js +21 -47
  221. package/src/screens/Automate/constants.js +0 -0
  222. package/src/screens/Automate/index.js +18 -24
  223. package/src/screens/ChangePosition/__test__/index.test.js +75 -0
  224. package/src/screens/ChangePosition/index.js +112 -0
  225. package/src/screens/ChangePosition/styles.js +87 -0
  226. package/src/screens/Device/__test__/DetailHistoryChart.test.js +2 -2
  227. package/src/screens/Device/__test__/EmergencyCountdown.test.js +4 -2
  228. package/src/screens/Device/__test__/detail.test.js +202 -257
  229. package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -10
  230. package/src/screens/Device/components/ChartWrapper.js +3 -3
  231. package/src/screens/Device/components/SensorDisplayItem.js +2 -1
  232. package/src/screens/Device/components/VisualChart.js +56 -9
  233. package/src/screens/Device/components/__test__/VisualChart.test.js +1 -1
  234. package/src/screens/Device/detail.js +14 -0
  235. package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
  236. package/src/screens/Device/hooks/useEvaluateValue.js +28 -2
  237. package/src/screens/Device/styles.js +7 -0
  238. package/src/screens/DeviceInfo/__test__/index.test.js +16 -18
  239. package/src/screens/DeviceInfo/index.js +6 -5
  240. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
  241. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
  242. package/src/screens/Notification/__test__/Notification.test.js +64 -73
  243. package/src/screens/Notification/index.js +14 -14
  244. package/src/screens/PlayBackCamera/index.js +2 -3
  245. package/src/screens/SelectUnit/__test__/index.test.js +0 -5
  246. package/src/screens/SelectUnit/index.js +1 -2
  247. package/src/screens/SharedUnit/index.js +5 -4
  248. package/src/screens/Sharing/Components/TitleCheckBox.js +2 -2
  249. package/src/screens/Sharing/SelectUser.js +2 -2
  250. package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
  251. package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
  252. package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
  253. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
  254. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +3 -3
  255. package/src/screens/SmartAccount/__test__/Connecting.test.js +1 -1
  256. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +3 -3
  257. package/src/screens/SmartAccount/index.js +1 -0
  258. package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +1 -1
  259. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +5 -5
  260. package/src/screens/SmartIr/__test__/SelectBrand.test.js +2 -2
  261. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +2 -2
  262. package/src/screens/SmartIr/__test__/SmartIr.test.js +2 -2
  263. package/src/screens/SubUnit/ManageSubUnit.js +4 -4
  264. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
  265. package/src/screens/TDSGuide/index.js +1 -1
  266. package/src/screens/Template/GatewayList.js +4 -1
  267. package/src/screens/Template/__test__/detail.test.js +24 -22
  268. package/src/screens/Template/detail.js +1 -0
  269. package/src/screens/UVIndexGuide/index.js +2 -2
  270. package/src/screens/Unit/Detail.js +6 -5
  271. package/src/screens/Unit/SelectAddToFavorites.js +1 -1
  272. package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
  273. package/src/screens/Unit/__test__/Detail.test.js +10 -14
  274. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
  275. package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
  276. package/src/screens/Unit/components/__test__/Header.test.js +4 -4
  277. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -1
  278. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +14 -6
  279. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +1 -1
  280. package/src/screens/UnitSummary/components/Temperature/index.js +2 -2
  281. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
  282. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
  283. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
  284. package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -2
  285. package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +1 -1
  286. package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +1 -1
  287. package/src/screens/UnitSummary/components/__test__/index.test.js +2 -2
  288. package/src/screens/WaterQualityGuide/index.js +10 -5
  289. package/src/utils/Apis/axios.js +3 -0
  290. package/src/utils/I18n/translations/en.json +24 -18
  291. package/src/utils/I18n/translations/vi.json +22 -18
  292. package/src/utils/Route/index.js +9 -3
  293. package/src/utils/Utils.js +29 -0
  294. package/src/utils/__test__/Utils.test.js +6 -0
  295. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
  296. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
  297. package/src/commons/Auth/SocialButton.js +0 -54
  298. package/src/commons/Auth/__test__/SocialButton.test.js +0 -44
  299. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
  300. package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
  301. package/src/hooks/useInitDeepLink.js +0 -25
  302. package/src/screens/AddNewAction/SelectAction.js +0 -570
  303. package/src/screens/AddNewAction/SelectSensorDevices.js +0 -236
  304. package/src/screens/AddNewAction/SetupSensor.js +0 -263
  305. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +0 -181
  306. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +0 -114
  307. package/src/screens/AddNewOneTap/index.js +0 -147
  308. package/src/screens/ScriptDetail/hooks/index.js +0 -136
  309. package/src/screens/ScriptDetail/index.js +0 -525
  310. package/src/screens/SetSchedule/index.js +0 -200
  311. /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
  312. /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.3.90",
4
+ "version": "0.3.92",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3 15H21V13H3V15ZM3 19H21V17H3V19ZM3 11H21V9H3V11ZM3 5V7H21V5H3Z" fill="#262626"/>
3
+ </svg>
@@ -18,7 +18,7 @@ export default StyleSheet.create({
18
18
  textYourDoor: {
19
19
  fontSize: 12,
20
20
  color: Colors.Gray8,
21
- maginBottom: 16,
21
+ marginBottom: 16,
22
22
  },
23
23
  slider: {
24
24
  marginTop: 20,
@@ -46,7 +46,9 @@ describe('Test AutoLock', () => {
46
46
 
47
47
  const instance = tree.root;
48
48
  const switchs = instance.findByType(Switch);
49
- await switchs.props.onValueChange();
49
+ await act(async () => {
50
+ await switchs.props.onValueChange();
51
+ });
50
52
 
51
53
  const { buttonEnable, buttonInstant, buttonRelockTiming } =
52
54
  getElement(instance);
@@ -1,4 +1,4 @@
1
- import React, { memo, useCallback, useState } from 'react';
1
+ import React, { useCallback, useState } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { Slider } from '@miblanchard/react-native-slider';
4
4
  import Text from '../../../Text';
@@ -9,7 +9,7 @@ import styles from './AutoLockStyles';
9
9
  import t from '../../../../hooks/Common/useTranslations';
10
10
  import { Colors } from '../../../../configs';
11
11
 
12
- const AutoLock = memo(() => {
12
+ const AutoLock = () => {
13
13
  const [isEnabled, setIsEnabled] = useState(false);
14
14
 
15
15
  const handleToggleSwitch = useCallback(() => {
@@ -52,6 +52,6 @@ const AutoLock = memo(() => {
52
52
  </View>
53
53
  </View>
54
54
  );
55
- });
55
+ };
56
56
 
57
57
  export default AutoLock;
@@ -7,16 +7,7 @@ import { SCProvider } from '../../../../../context';
7
7
  import PasscodeList from '../index';
8
8
  import { TouchableOpacity } from 'react-native';
9
9
  import Routes from '../../../../../utils/Route';
10
-
11
- const mockNavigate = jest.fn();
12
- jest.mock('@react-navigation/native', () => {
13
- return {
14
- ...jest.requireActual('@react-navigation/native'),
15
- useNavigation: () => ({
16
- navigate: mockNavigate,
17
- }),
18
- };
19
- });
10
+ import { useNavigation } from '@react-navigation/native';
20
11
 
21
12
  const wrapComponent = () => (
22
13
  <SCProvider initState={mockSCStore({})}>
@@ -27,6 +18,8 @@ const wrapComponent = () => (
27
18
  describe('Test SetupGeneratePasscode', () => {
28
19
  let tree;
29
20
 
21
+ const mockNavigate = useNavigation().navigate;
22
+
30
23
  beforeEach(() => {
31
24
  mockNavigate.mockClear();
32
25
  });
@@ -52,6 +52,7 @@ const PasscodeList = memo(() => {
52
52
  onPress={handleClickButton(item)}
53
53
  style={styles.buttonWrapper}
54
54
  accessibilityLabel={AccessibilityLabel.PASSCODE_LIST}
55
+ key={item.code}
55
56
  >
56
57
  <View>
57
58
  <Text style={styles.textCode}>{item.code}</Text>
@@ -89,7 +89,7 @@ export default StyleSheet.create({
89
89
  bottom: 0,
90
90
  left: 0,
91
91
  right: 0,
92
- paddingBottom: getBottomSpace() > 0 ? getBottomSpace() : 32,
92
+ paddingBottom: getBottomSpace() || 32,
93
93
  paddingTop: 29,
94
94
  backgroundColor: Colors.White,
95
95
  borderColor: Colors.ShadownTransparent,
@@ -1,15 +1,14 @@
1
- import React, { memo, useCallback, useState } from 'react';
1
+ import React, { memo, useCallback, useEffect, useState } from 'react';
2
2
  import { Switch, View } from 'react-native';
3
3
 
4
4
  import Text from '../../Text';
5
5
  import { Colors } from '../../../configs';
6
6
  import styles from './OnOffButtonTemplateStyle';
7
7
  import AccessibilityLabel from '../../../configs/AccessibilityLabel';
8
+ import { useConfigGlobalState } from '../../../iot/states';
8
9
 
9
10
  const SwitchButtonTemplate = memo(
10
- ({ isOn, triggerAction, actionGroup = {}, isLight = false, doAction }) => {
11
- const [_isOn, setIsOn] = useState(isOn);
12
-
11
+ ({ actionGroup = {}, isLight = false, doAction }) => {
13
12
  const { configuration = {}, id } = actionGroup;
14
13
  const {
15
14
  action_off_data,
@@ -18,8 +17,13 @@ const SwitchButtonTemplate = memo(
18
17
  text_off,
19
18
  color_on,
20
19
  color_off,
20
+ config,
21
21
  } = configuration;
22
22
 
23
+ const [configValues] = useConfigGlobalState('configValues');
24
+ const configValue = configValues[config];
25
+ const [_isOn, setIsOn] = useState(configValue?.value);
26
+
23
27
  const onChangeSwitch = useCallback(() => {
24
28
  if (_isOn) {
25
29
  setIsOn(false);
@@ -30,6 +34,10 @@ const SwitchButtonTemplate = memo(
30
34
  setIsOn(true);
31
35
  }, [action_off_data, action_on_data, doAction, _isOn]);
32
36
 
37
+ useEffect(() => {
38
+ configValue && setIsOn(configValue?.value);
39
+ }, [configValue]);
40
+
33
41
  return (
34
42
  <>
35
43
  <View style={styles.barrierControlContainer}>
@@ -37,7 +45,7 @@ const SwitchButtonTemplate = memo(
37
45
  trackColor={{ false: color_off, true: color_on }}
38
46
  ios_backgroundColor={_isOn ? color_on : color_off}
39
47
  onValueChange={onChangeSwitch}
40
- value={_isOn}
48
+ value={!!_isOn}
41
49
  />
42
50
  <Text
43
51
  style={[
@@ -1,91 +1,122 @@
1
- import React, { memo, useCallback, useState, useEffect } from 'react';
1
+ import React, {
2
+ memo,
3
+ useCallback,
4
+ useState,
5
+ useEffect,
6
+ useMemo,
7
+ useRef,
8
+ } from 'react';
9
+ import { Slider } from '@miblanchard/react-native-slider';
10
+
2
11
  import { View } from 'react-native';
3
12
  import { useTranslations } from '../../hooks/Common/useTranslations';
4
13
  import styles from './SliderRangeTemplateStyles';
5
14
  import Text from '../Text';
6
15
  import { Colors } from '../../configs';
7
- import SvgBrightness from '../../../assets/images/brightness.svg';
8
- import { Slider } from '@miblanchard/react-native-slider';
9
16
  import { useConfigGlobalState } from '../../iot/states';
10
17
  import { DEVICE_TYPE } from '../../configs/Constants';
18
+ import _TextInput from '../Form/TextInput';
19
+
20
+ const SliderRangeTemplate = memo(
21
+ ({ actionGroup = {}, doAction, sensor, item }) => {
22
+ const t = useTranslations();
23
+ const { configuration = {} } = actionGroup;
24
+ const [configValues] = useConfigGlobalState('configValues');
25
+ const {
26
+ config = undefined,
27
+ min_value = 0,
28
+ max_value = 100,
29
+ action_data,
30
+ } = configuration;
31
+ const timeout = useRef(null);
11
32
 
12
- let percentTemp = 0;
13
- const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
14
- const t = useTranslations();
15
- const { configuration = {} } = actionGroup;
16
- const [configValues] = useConfigGlobalState('configValues');
17
- const { config = undefined } = configuration;
33
+ const getPercent = useCallback(() => {
34
+ return configValues[config]?.value || 0;
35
+ }, [config, configValues]);
18
36
 
19
- const getPercent = useCallback(() => {
20
- const { value } = configValues[config] || { value: 0 };
21
- return value;
22
- }, [config, configValues]);
37
+ const [valueBrightness, setValueBrightness] = useState(getPercent());
38
+
39
+ const onChangeBrightness = useCallback(
40
+ async (value) => {
41
+ const value_brness = value[0];
42
+ await doAction(
43
+ action_data,
44
+ JSON.stringify({ value_brness: value_brness, value: value_brness })
45
+ );
46
+ },
47
+ [action_data, doAction]
48
+ );
49
+
50
+ useEffect(() => {
51
+ const value = configValues[config]?.value || 0;
52
+ if (sensor?.device_type !== DEVICE_TYPE.LG_THINQ) {
53
+ setValueBrightness(value);
54
+ }
55
+ }, [config, configValues, sensor?.device_type]);
23
56
 
24
- const [valueBrightness, setValueBrightness] = useState(getPercent());
25
- const [isFirstTime, setIsFirstTime] = useState(true);
57
+ const getTextInputValue = useMemo(() => {
58
+ if ([null, undefined, NaN].includes(valueBrightness)) {
59
+ return 0;
60
+ }
26
61
 
27
- const onChangeBrightness = useCallback(
28
- async (value) => {
29
- const value_brness = value[0];
30
- await doAction(
31
- configuration?.action_data,
32
- JSON.stringify({ value_brness: value_brness, value: value_brness })
33
- );
34
- },
35
- [configuration?.action_data, doAction]
36
- );
62
+ return valueBrightness;
63
+ }, [valueBrightness]);
37
64
 
38
- useEffect(() => {
39
- percentTemp = valueBrightness;
40
- }, [valueBrightness]);
65
+ const onValueChange = (value) => setValueBrightness(value[0]);
41
66
 
42
- useEffect(() => {
43
- const { value } = configValues[config] || { value: 0 };
44
- if (value && isFirstTime) {
67
+ const onInputChange = (value) => {
68
+ if (isNaN(value)) {
69
+ return;
70
+ }
45
71
  setValueBrightness(value);
46
- setIsFirstTime(false);
47
- return;
48
- }
49
- if (sensor?.device_type !== DEVICE_TYPE.LG_THINQ) {
50
- if (percentTemp !== value) {
51
- setValueBrightness(value);
72
+ if (timeout.current) {
73
+ clearTimeout(timeout.current);
52
74
  }
53
- percentTemp = value;
54
- }
55
- // eslint-disable-next-line react-hooks/exhaustive-deps
56
- }, [configValues]);
75
+ if (value !== '') {
76
+ timeout.current = setTimeout(() => {
77
+ doAction(
78
+ action_data,
79
+ JSON.stringify({
80
+ value_brness: parseInt(value),
81
+ value: parseInt(value),
82
+ })
83
+ );
84
+ }, 300);
85
+ }
86
+ };
57
87
 
58
- return (
59
- <View style={styles.viewBrightness}>
60
- <View style={styles.LeftBrightness}>
61
- <SvgBrightness />
88
+ return (
89
+ <View style={styles.viewBrightness}>
62
90
  <Text type="H4" style={styles.LeftTextBrightness}>
63
- {actionGroup.title || t('brightness')}
91
+ {actionGroup?.title || item?.label || t('brightness')}
64
92
  </Text>
65
- </View>
66
- <View style={styles.RightBrightness}>
67
- <Slider
68
- containerStyle={styles.slider}
69
- value={valueBrightness}
70
- onSlidingComplete={onChangeBrightness}
71
- onValueChange={setValueBrightness}
72
- step={1}
73
- minimumValue={0}
74
- maximumValue={100}
75
- thumbTintColor={Colors.Gray3}
76
- minimumTrackTintColor={Colors.Primary}
77
- maximumTrackTintColor={Colors.Gray4}
78
- trackStyle={styles.trackSlider}
79
- thumbStyle={styles.thumbSlider}
80
- />
81
- <View style={styles.valuePercent}>
82
- <Text type="Label" style={styles.textValuePercent}>
83
- {`${valueBrightness}%`}
84
- </Text>
93
+
94
+ <View style={styles.wrap}>
95
+ <Slider
96
+ step={1}
97
+ minimumValue={min_value}
98
+ maximumValue={max_value}
99
+ value={valueBrightness < min_value ? min_value : valueBrightness}
100
+ onValueChange={onValueChange}
101
+ onSlidingComplete={onChangeBrightness}
102
+ minimumTrackTintColor={Colors.Primary}
103
+ maximumTrackTintColor={Colors.Gray3}
104
+ trackStyle={styles.trackSlider}
105
+ thumbStyle={styles.thumbSlider}
106
+ containerStyle={styles.slider}
107
+ />
108
+ <_TextInput
109
+ keyboardType="numeric"
110
+ style={styles.text}
111
+ wrapStyle={styles.wrapInputStyle}
112
+ textInputStyle={styles.textInputStyle}
113
+ value={getTextInputValue.toString()}
114
+ onChange={onInputChange}
115
+ />
85
116
  </View>
86
117
  </View>
87
- </View>
88
- );
89
- });
118
+ );
119
+ }
120
+ );
90
121
 
91
122
  export default SliderRangeTemplate;
@@ -6,44 +6,44 @@ export default StyleSheet.create({
6
6
  marginBottom: 16,
7
7
  marginHorizontal: 16,
8
8
  padding: 16,
9
- flexDirection: 'row',
10
- alignItems: 'center',
11
- justifyContent: 'space-around',
12
9
  borderWidth: 1,
13
10
  borderColor: Colors.Gray4,
14
11
  borderRadius: 10,
15
12
  },
16
- slider: {
17
- width: 131,
18
- },
19
13
  trackSlider: {
20
- height: 8,
21
- borderRadius: 30,
14
+ height: 4,
22
15
  },
23
16
  thumbSlider: {
24
- backgroundColor: Colors.Primary,
25
- width: 20,
26
- height: 20,
27
- },
28
- valuePercent: {
29
- width: 45,
30
- flexDirection: 'row',
31
- paddingLeft: 16,
17
+ backgroundColor: Colors.White,
18
+ borderColor: Colors.Primary,
19
+ borderWidth: 3,
32
20
  },
33
- textValuePercent: {
34
- width: 45,
35
- },
36
- LeftBrightness: {
37
- flex: 1,
21
+ wrap: {
38
22
  flexDirection: 'row',
39
23
  alignItems: 'center',
24
+ width: '100%',
25
+ flexWrap: 'nowrap',
40
26
  },
41
- LeftTextBrightness: {
42
- paddingTop: 4,
43
- paddingLeft: 8,
27
+ text: {
28
+ marginTop: 8,
44
29
  },
45
- RightBrightness: {
46
- flexDirection: 'row',
47
- alignItems: 'center',
30
+ slider: {
31
+ width: '77%',
32
+ },
33
+ wrapInputStyle: {
34
+ marginTop: 0,
35
+ width: '23%',
36
+ },
37
+ textInputStyle: {
38
+ marginTop: 0,
39
+ marginLeft: 10,
40
+ borderRadius: 4,
41
+ paddingTop: 5,
42
+ paddingBottom: 5,
43
+ paddingHorizontal: 20,
44
+
45
+ shadowColor: Colors.Gray13,
46
+ borderColor: Colors.Gray5,
47
+ borderWidth: 1,
48
48
  },
49
49
  });
@@ -38,6 +38,7 @@ const GridItem = ({ item, doAction, sensor }) => {
38
38
  } = item;
39
39
  const buttonOnOffStyle = active ? buttonStyle.ON : buttonStyle.OFF;
40
40
  const checkIcon = /\d/.test(icon); // to do check icon svg and icon antDesign
41
+
41
42
  const doActionAndWatchConfig = useCallback(
42
43
  (actionData) => {
43
44
  let data = null;
@@ -76,9 +77,10 @@ const GridItem = ({ item, doAction, sensor }) => {
76
77
  case 'air-dry-1':
77
78
  return <SvgAirDry width={24} height={24} />;
78
79
  default:
79
- return () => <></>;
80
+ return null;
80
81
  }
81
82
  }, [icon]);
83
+
82
84
  return (
83
85
  <View
84
86
  accessibilityLabel={AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM}
@@ -142,6 +144,7 @@ const StatesGridActionTemplate = ({
142
144
  >
143
145
  {options.map((item, index) => (
144
146
  <GridItem
147
+ key={index}
145
148
  item={item}
146
149
  index={index}
147
150
  doAction={doAction}
@@ -19,7 +19,7 @@ jest.mock('@react-navigation/native', () => {
19
19
  };
20
20
  });
21
21
 
22
- describe('Test NumberUpDownActionTemplate', () => {
22
+ describe('Test NumberUpDownTemplate', () => {
23
23
  const action_data = {
24
24
  color: '#00979D',
25
25
  command_prefer_over_bluetooth: true,
@@ -77,6 +77,7 @@ describe('Test OnOffTemplate', () => {
77
77
 
78
78
  beforeEach(() => {
79
79
  watchMultiConfigs.mockClear();
80
+ jest.useFakeTimers();
80
81
 
81
82
  actionGroup = {
82
83
  template: 'OnOffSimpleActionTemplate',
@@ -265,7 +266,9 @@ describe('Test OnOffTemplate', () => {
265
266
  await act(async () => {
266
267
  await template[0].props.triggerAction();
267
268
  });
268
- jest.runAllTimers();
269
+ await act(async () => {
270
+ jest.runAllTimers();
271
+ });
269
272
  expect(mockDoAction).toHaveBeenCalledWith(action_data, {
270
273
  value: 0,
271
274
  state: 0,
@@ -6,6 +6,7 @@ import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
7
  import { useConfigGlobalState } from '../../../iot/states';
8
8
  import { Slider } from '@miblanchard/react-native-slider';
9
+ import _TextInput from '../../Form/TextInput';
9
10
 
10
11
  jest.mock('../../../iot/Monitor');
11
12
  const mockDoAction = jest.fn();
@@ -36,6 +37,7 @@ describe('Test SliderRangeTemplate', () => {
36
37
  };
37
38
 
38
39
  beforeEach(() => {
40
+ jest.useFakeTimers();
39
41
  watchMultiConfigs.mockClear();
40
42
  mockDoAction.mockClear();
41
43
  actionGroup = {
@@ -83,4 +85,58 @@ describe('Test SliderRangeTemplate', () => {
83
85
  const silderRange = instance.findByType(Slider);
84
86
  expect(silderRange.props.value).toBe(50);
85
87
  });
88
+
89
+ it('test change input invalid number', async () => {
90
+ useConfigGlobalState.mockImplementation(() => [
91
+ {
92
+ 5: {
93
+ value: 50,
94
+ },
95
+ },
96
+ jest.fn(),
97
+ ]);
98
+ const sensor = { is_managed_by_backend: true, name: 'Sensor' };
99
+
100
+ await act(async () => {
101
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
102
+ });
103
+ const instance = wrapper.root;
104
+ const textInput = instance.findByType(_TextInput);
105
+ expect(textInput.props.value).toEqual('50');
106
+
107
+ await act(async () => {
108
+ await textInput.props.onChange('aaaa');
109
+ });
110
+ expect(textInput.props.value).toEqual('50'); // not change value
111
+ });
112
+
113
+ it('test change input called doAction', async () => {
114
+ useConfigGlobalState.mockImplementation(() => [
115
+ {
116
+ 5: {
117
+ value: 50,
118
+ },
119
+ },
120
+ jest.fn(),
121
+ ]);
122
+ const sensor = { is_managed_by_backend: true, name: 'Sensor' };
123
+
124
+ await act(async () => {
125
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
126
+ });
127
+
128
+ const instance = wrapper.root;
129
+ let textInput = instance.findByType(_TextInput);
130
+
131
+ await act(async () => {
132
+ await textInput.props.onChange('60');
133
+ });
134
+ await act(async () => {
135
+ jest.runAllTimers();
136
+ });
137
+ expect(mockDoAction).toHaveBeenCalledWith(
138
+ action_data,
139
+ JSON.stringify({ value_brness: 60, value: 60 })
140
+ );
141
+ });
86
142
  });
@@ -20,7 +20,7 @@ describe('Test StatesGridActionTemplate', () => {
20
20
  configuration: {
21
21
  options: [
22
22
  {
23
- config: true,
23
+ config: 1,
24
24
  active: false,
25
25
  text: 'item 1',
26
26
  icon_kit_data: 'icon_kit_data',
@@ -28,7 +28,7 @@ describe('Test StatesGridActionTemplate', () => {
28
28
  action_data: mockActionData,
29
29
  },
30
30
  {
31
- config: false,
31
+ config: 2,
32
32
  active: true,
33
33
  text: 'item 2',
34
34
  icon_kit_data: 'icon_kit_data',
@@ -1,13 +1,23 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
+ import { Switch } from 'react-native';
3
4
 
4
5
  import { mockSCStore } from '../../../context/mockStore';
5
6
  import { SCProvider } from '../../../context';
6
7
  import SwitchButtonTemplate from '../OnOffTemplate/SwitchButtonTemplate';
8
+ import { useConfigGlobalState } from '../../../iot/states';
7
9
 
8
- const wrapComponent = (actionGroup, mockDoAction) => (
10
+ jest.mock('../../../iot/states', () => ({
11
+ useConfigGlobalState: jest.fn(),
12
+ }));
13
+
14
+ const wrapComponent = (actionGroup, mockDoAction, isOn) => (
9
15
  <SCProvider initState={mockSCStore({})}>
10
- <SwitchButtonTemplate actionGroup={actionGroup} doAction={mockDoAction} />
16
+ <SwitchButtonTemplate
17
+ actionGroup={actionGroup}
18
+ doAction={mockDoAction}
19
+ isOn={isOn}
20
+ />
11
21
  </SCProvider>
12
22
  );
13
23
 
@@ -50,37 +60,64 @@ describe('Test SwitchButtonTemplate', () => {
50
60
  action_off_data: action_off_data,
51
61
  icon_off: 'caret-up',
52
62
  text_off: 'OFF',
63
+ config: 1,
53
64
  },
54
65
  };
55
66
  let wrapper;
56
67
 
57
- const assertRender = async () => {
68
+ const assertRender = async (state) => {
58
69
  const mockDoAction = jest.fn();
59
70
 
60
71
  await act(async () => {
61
- wrapper = create(wrapComponent(actionGroup, mockDoAction));
72
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction));
62
73
  });
63
74
 
64
75
  const renderJson = wrapper.toJSON();
76
+ const switchButton = wrapper.root.findByType(Switch);
77
+
65
78
  expect(renderJson[1].props?.visible).toEqual(false);
66
79
  expect(renderJson[1]?.type).toEqual('Modal');
80
+ expect(switchButton.props.value).toEqual(state);
67
81
  };
68
82
 
69
83
  it('render state on', async () => {
70
- await assertRender(true, 'ON');
84
+ useConfigGlobalState.mockImplementation(() => [
85
+ {
86
+ 1: {
87
+ value: 1,
88
+ },
89
+ },
90
+ jest.fn(),
91
+ ]);
92
+ await assertRender(true);
71
93
  });
72
94
 
73
95
  it('render state off', async () => {
74
- await assertRender(false, 'OFF');
96
+ useConfigGlobalState.mockImplementation(() => [
97
+ {
98
+ 1: {
99
+ value: 0,
100
+ },
101
+ },
102
+ jest.fn(),
103
+ ]);
104
+ await assertRender(false);
75
105
  });
76
106
 
77
107
  const assertActionCall = async (state, action_data) => {
78
108
  const mockDoAction = jest.fn();
79
109
  await act(async () => {
80
- wrapper = create(wrapComponent(actionGroup, mockDoAction));
110
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, state));
81
111
  });
82
-
83
112
  expect(mockDoAction).not.toHaveBeenCalled();
113
+ const root = wrapper.root;
114
+
115
+ const item = root.findByType(Switch);
116
+ await act(async () => {
117
+ item.props.onValueChange();
118
+ });
119
+
120
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, null);
84
121
  };
85
122
 
86
123
  it('action state on', async () => {