@eohjsc/react-native-smart-city 0.2.21 → 0.2.27
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.
- package/README.md +1 -1
- package/assets/images/Add.svg +5 -0
- package/assets/images/AddLocationMaps/Point.svg +3 -0
- package/assets/images/CheckCircle.svg +4 -0
- package/assets/images/Close.svg +3 -0
- package/assets/images/HowToStart.svg +14 -0
- package/assets/images/Illustrations.svg +83 -0
- package/assets/images/OneTap.svg +14 -0
- package/assets/images/OneTap@1x.svg +14 -0
- package/assets/images/Rearrange.svg +3 -0
- package/assets/images/Schedule.svg +39 -0
- package/assets/images/ValueChange.svg +49 -0
- package/index.js +2 -0
- package/package.json +14 -2
- package/src/Images/Common/ActiveButton.png +0 -0
- package/src/Images/Common/ActiveButton@2x.png +0 -0
- package/src/Images/Common/ActiveButton@3x.png +0 -0
- package/src/Images/Common/arrow-back.png +0 -0
- package/src/Images/Common/checked@2x.png +0 -0
- package/src/Images/Common/checked@3x.png +0 -0
- package/src/Images/Common/file.png +0 -0
- package/src/Images/Common/fullscreen.png +0 -0
- package/src/Images/Common/refresh.png +0 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/OnOffTemplate/index.js +9 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +4 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +13 -6
- package/src/commons/ActionGroup/ThreeButtonTemplateStyle.js +1 -1
- package/src/commons/ActionGroup/TimerActionTemplate.js +158 -33
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +294 -0
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +60 -0
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +8 -13
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +26 -45
- package/src/commons/ActionGroup/__test__/ThreeButtonTemplate.test.js +11 -5
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +14 -8
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +17 -23
- package/src/commons/ActionGroup/__test__/__snapshots__/ThreeButtonTemplate.test.js.snap +241 -223
- package/src/commons/ActionGroup/__test__/index.test.js +39 -107
- package/src/commons/ActionGroup/hooks/useDropdownAction.js +2 -1
- package/src/commons/ActionTemplate/ActionTemplateStyles.js +14 -0
- package/src/commons/ActionTemplate/OnOffButtonAction.js +40 -0
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OneButtonAction.js +26 -0
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/ThreeButtonAction.js +55 -0
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +34 -0
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +33 -0
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +35 -0
- package/src/commons/ActionTemplate/__test__/index.test.js +71 -0
- package/src/commons/ActionTemplate/index.js +69 -0
- package/src/commons/AlertAction/__test__/AlertAction.test.js +6 -6
- package/src/commons/AlertAction/index.js +2 -0
- package/src/commons/Automate/ItemAddNewScriptActionStyles.js +38 -0
- package/src/commons/Automate/ItemAutomate.js +39 -0
- package/src/commons/Automate/ItemAutomateStyles.js +33 -0
- package/src/commons/Automate/ItemScriptAction.js +45 -0
- package/src/commons/Automate/ItemScriptActionStyles.js +42 -0
- package/src/commons/Automate/__test__/ItemAutomate.test.js +16 -0
- package/src/commons/Automate/__test__/ItemScriptAction.test.js +16 -0
- package/src/commons/BackDefault/__test__/BackDefault.test.js +21 -0
- package/src/commons/BottomScrollPicker/index.js +62 -0
- package/src/commons/BottomScrollPicker/styles.js +13 -0
- package/src/commons/BottomSheet/index.js +41 -0
- package/src/commons/BottomSheet/styles.js +37 -0
- package/src/commons/Button/index.js +6 -1
- package/src/commons/ButtonPopup/__test__/__snapshots__/ButtonPopup.test.js.snap +2 -0
- package/src/commons/ButtonPopup/index.js +2 -0
- package/src/commons/Calendar/index.js +72 -0
- package/src/commons/Calendar/styles.js +11 -0
- package/src/commons/CameraDevice/index.js +2 -1
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +9 -7
- package/src/commons/ChartLoading/index.js +2 -1
- package/src/commons/DateTimeRangeChange/index.js +2 -1
- package/src/commons/Device/ConnectedViewHeader.js +3 -1
- package/src/commons/Device/DeviceAlertStatus.js +5 -2
- package/src/commons/Device/DisconnectedView.js +34 -26
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -1
- package/src/commons/Device/Emergency/EmergencyDetail.js +2 -1
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +14 -6
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +10 -2
- package/src/commons/Device/FlatListItems.js +3 -2
- package/src/commons/Device/FooterInfo.js +2 -1
- package/src/commons/Device/HistoryChart.js +2 -1
- package/src/commons/Device/ItemAddNew/index.js +8 -3
- package/src/commons/Device/SensorConnectedStatus.js +2 -1
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +19 -11
- package/src/commons/Device/WindDirection/Compass/index.js +1 -1
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +9 -3
- package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap +0 -81
- package/src/commons/Device/WindSpeed/LinearChart/index.js +2 -1
- package/src/commons/Device/__test__/ConnectedViewHeader.test.js +16 -8
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +13 -5
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -5
- package/src/commons/Device/__test__/FlatListItems.test.js +9 -1
- package/src/commons/Device/__test__/FooterInfo.test.js +13 -4
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +9 -1
- package/src/commons/Device/__test__/__snapshots__/DisconnectedView.test.js.snap +20 -20
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +28 -0
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -1
- package/src/commons/EmergencyButton/AlertSent.js +3 -2
- package/src/commons/Explore/CityItem/index.js +2 -1
- package/src/commons/Explore/HeaderExplore/index.js +2 -1
- package/src/commons/Explore/HeaderLabel/index.js +2 -1
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +9 -2
- package/src/commons/Explore/SearchBox/index.js +2 -1
- package/src/commons/Explore/__test__/CityItem.test.js +13 -15
- package/src/commons/Explore/__test__/HeaderExplore.test.js +11 -7
- package/src/commons/Explore/__test__/HeaderLabel.test.js +15 -9
- package/src/commons/Explore/__test__/LocationItem.test.js +31 -0
- package/src/commons/Header/HeaderCustom.js +22 -2
- package/src/commons/Header/Styles/HeaderCustomStyles.js +2 -2
- package/src/commons/Header/__test__/HeaderCT.test.js +12 -4
- package/src/commons/HeaderAni/index.js +36 -5
- package/src/commons/HorizontalPicker/index.js +134 -0
- package/src/commons/HorizontalPicker/styles.js +56 -0
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +19 -13
- package/src/commons/ImagePicker/index.js +3 -1
- package/src/commons/MediaPlayer/index.js +2 -1
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +14 -8
- package/src/commons/MediaPlayerDetail/index.js +4 -1
- package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +11 -20
- package/src/commons/MenuActionAddnew/index.js +2 -1
- package/src/commons/Modal/ModalBottom.js +51 -0
- package/src/commons/Modal/ModalFullVideo.js +2 -1
- package/src/commons/Modal/Styles/ModalBottomStyles.js +35 -0
- package/src/commons/Modal/__test__/ModalBottom.test.js +39 -0
- package/src/commons/Modal/index.js +2 -1
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/RowItem/__test__/RowItem.test.js +16 -0
- package/src/commons/RowItem/index.js +61 -0
- package/src/commons/RowItem/styles.js +53 -0
- package/src/commons/SelectActionCard/SelectActionStyles.js +16 -0
- package/src/commons/SelectActionCard/index.js +30 -0
- package/src/commons/Sharing/DevicePermissionsCheckbox.js +2 -1
- package/src/commons/Sharing/MemberList.js +3 -1
- package/src/commons/Sharing/RowMember.js +3 -2
- package/src/commons/Sharing/StationDevicePermissions.js +2 -1
- package/src/commons/Sharing/WrapHeaderScrollable.js +78 -74
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +15 -9
- package/src/commons/Sharing/__test__/MemberList.test.js +17 -25
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +17 -12
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +0 -9
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +101 -0
- package/src/commons/SubUnit/OneTap/ItemOneTapStyles.js +41 -0
- package/src/commons/SubUnit/OneTap/OneTapStyles.js +36 -0
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +195 -0
- package/src/commons/SubUnit/OneTap/index.js +39 -0
- package/src/commons/SubUnit/ShortDetail.js +11 -6
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +14 -6
- package/src/commons/Today/__test__/Today.test.js +9 -1
- package/src/commons/Today/__test__/__snapshots__/Today.test.js.snap +1 -1
- package/src/commons/Today/index.js +2 -1
- package/src/commons/Unit/SharedUnit.js +2 -1
- package/src/commons/Unit/__test__/SharedUnit.test.js +330 -0
- package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -2
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +16 -17
- package/src/commons/UnitSummary/AirQuality/index.js +5 -120
- package/src/commons/UnitSummary/AirQuality/styles.js +112 -0
- package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -1
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +15 -9
- package/src/commons/WheelDateTimePicker/Picker.js +57 -0
- package/src/commons/WheelDateTimePicker/index.js +168 -0
- package/src/commons/WheelDateTimePicker/styles.js +21 -0
- package/src/commons/index.js +2 -0
- package/src/configs/API.js +29 -0
- package/src/configs/Colors.js +1 -0
- package/src/configs/Constants.js +61 -0
- package/src/configs/Images.js +1 -0
- package/src/configs/SCConfig.js +7 -0
- package/src/configs/Theme.js +20 -0
- package/src/context/SCContext.tsx +9 -39
- package/src/context/actionType.ts +11 -0
- package/src/context/mockStore.ts +51 -0
- package/src/context/reducer.ts +23 -0
- package/src/hooks/Common/__test__/useStatusbar.test.js +28 -0
- package/src/hooks/Common/__test__/useTranslations.test.js +23 -0
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGetIdUser.js +9 -0
- package/src/hooks/Common/useTranslations.ts +34 -0
- package/src/iot/Monitor.js +2 -1
- package/src/iot/RemoteControl/Bluetooth.js +2 -6
- package/src/iot/RemoteControl/GoogleHome.js +1 -1
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/LG.js +57 -15
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +3 -5
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +3 -3
- package/src/iot/RemoteControl/__test__/Internet.test.js +1 -8
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +7 -10
- package/src/iot/RemoteControl/index.js +1 -1
- package/src/iot/states.js +1 -0
- package/src/navigations/AutomateStack.js +45 -0
- package/src/navigations/SharedStack.js +2 -1
- package/src/navigations/UnitStack.js +86 -6
- package/src/navigations/utils.js +8 -0
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +9 -1
- package/src/screens/AQIGuide/index.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +14 -39
- package/src/screens/ActivityLog/index.js +2 -1
- package/src/screens/AddCommon/SelectSubUnit.js +5 -4
- package/src/screens/AddCommon/SelectUnit.js +3 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +61 -0
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +18 -10
- package/src/screens/AddLocationMaps/index.js +2 -1
- package/src/screens/AddNewAction/Components/LoadingSelectAction.js +40 -0
- package/src/screens/AddNewAction/Components/index.js +3 -0
- package/src/screens/AddNewAction/Device/DeviceStyles.js +43 -0
- package/src/screens/AddNewAction/Device/__test__/index.test.js +42 -0
- package/src/screens/AddNewAction/Device/index.js +33 -0
- package/src/screens/AddNewAction/SelectAction.js +237 -0
- package/src/screens/AddNewAction/SelectSensorDevices.js +150 -0
- package/src/screens/AddNewAction/SetupSensor.js +221 -0
- package/src/screens/AddNewAction/Styles/SelectActionStyles.js +62 -0
- package/src/screens/AddNewAction/Styles/SelectSensorDevicesStyles.js +36 -0
- package/src/screens/AddNewAction/Styles/SetupSensorStyles.js +76 -0
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +153 -0
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +191 -0
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +125 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +112 -0
- package/src/screens/AddNewAutoSmart/index.js +113 -0
- package/src/screens/AddNewAutoSmart/styles/AddNewAutoSmartStyles.js +36 -0
- package/src/screens/AddNewDevice/ConnectDevices.js +2 -1
- package/src/screens/AddNewDevice/ConnectingDevices.js +2 -1
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +29 -13
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +19 -7
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +16 -6
- package/src/screens/AddNewDevice/hooks/useStateAlertRename.js +2 -1
- package/src/screens/AddNewDevice/index.js +2 -1
- package/src/screens/AddNewGateway/ConnectedGateway.js +2 -1
- package/src/screens/AddNewGateway/ConnectingGateway.js +99 -24
- package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +92 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +3 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +35 -72
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +14 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +20 -10
- package/src/screens/AddNewGateway/hooks/useStateAlertRename.js +2 -1
- package/src/screens/AddNewGateway/index.js +2 -1
- package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +44 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +130 -0
- package/src/screens/AddNewOneTap/index.js +83 -0
- package/src/screens/AllCamera/__test__/index.test.js +103 -0
- package/src/screens/AllCamera/index.js +2 -1
- package/src/screens/Automate/Components/Loading.js +64 -0
- package/src/screens/Automate/Styles/indexStyles.js +64 -0
- package/src/screens/Automate/__test__/Loading.test.js +16 -0
- package/src/screens/Automate/__test__/index.test.js +93 -0
- package/src/screens/Automate/index.js +148 -0
- package/src/screens/Device/HeaderDevice/styles.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +90 -18
- package/src/screens/Device/detail.js +73 -35
- package/src/screens/Device/hooks/useCountUp.js +4 -0
- package/src/screens/Device/hooks/useEmergencyButton.js +3 -2
- package/src/screens/Device/styles.js +5 -1
- package/src/screens/DeviceInfo/__test__/index.test.js +12 -3
- package/src/screens/DeviceInfo/index.js +2 -1
- package/src/screens/EditActionsList/Styles/indexStyles.js +84 -0
- package/src/screens/EditActionsList/index.js +186 -0
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -2
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +9 -2
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +2 -1
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +15 -18
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +19 -23
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +10 -25
- package/src/screens/EmergencyContacts/hook.js +3 -2
- package/src/screens/Explore/index.js +3 -2
- package/src/screens/GuestInfo/__test__/index.test.js +176 -0
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +32 -0
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +204 -0
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +36 -0
- package/src/screens/GuestInfo/components/RecurringDetail.js +106 -0
- package/src/screens/GuestInfo/components/RowGuestInfo.js +31 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +53 -0
- package/src/screens/GuestInfo/constant.js +59 -0
- package/src/screens/GuestInfo/index.js +150 -0
- package/src/screens/GuestInfo/styles/AccessScheduleDetailStyles.js +31 -0
- package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +22 -0
- package/src/screens/GuestInfo/styles/HeaderGuestInfoStyles.js +31 -0
- package/src/screens/GuestInfo/styles/indexStyles.js +38 -0
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +13 -1
- package/src/screens/ManageAccess/hooks/index.js +4 -0
- package/src/screens/ManageAccess/index.js +49 -20
- package/src/screens/ManageAccess/styles/ManageAccessStyles.js +3 -0
- package/src/screens/PlayBackCamera/Timer.js +1 -1
- package/src/screens/PlayBackCamera/index.js +9 -5
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +2 -11
- package/src/screens/ScanChipQR/components/QRScan/index.js +2 -1
- package/src/screens/ScriptDetail/Styles/indexStyles.js +157 -0
- package/src/screens/ScriptDetail/__test__/index.test.js +119 -0
- package/src/screens/ScriptDetail/hooks/index.js +55 -0
- package/src/screens/ScriptDetail/index.js +344 -0
- package/src/screens/SelectUnit/Styles/indexStyles.js +55 -0
- package/src/screens/SelectUnit/__test__/index.test.js +85 -0
- package/src/screens/SelectUnit/index.js +100 -0
- package/src/screens/SetSchedule/__test__/index.test.js +97 -0
- package/src/screens/SetSchedule/components/RepeatOptionsPopup.js +56 -0
- package/src/screens/SetSchedule/components/RowItem.js +27 -0
- package/src/screens/SetSchedule/components/SelectWeekday.js +65 -0
- package/src/screens/SetSchedule/index.js +139 -0
- package/src/screens/SetSchedule/styles/RepeatOptionsPopupStyles.js +22 -0
- package/src/screens/SetSchedule/styles/RowItemStyles.js +29 -0
- package/src/screens/SetSchedule/styles/SelectWeekdayStyles.js +26 -0
- package/src/screens/SetSchedule/styles/indexStyles.js +22 -0
- package/src/screens/SharedUnit/TabHeader.js +2 -1
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +40 -0
- package/src/screens/SharedUnit/index.js +3 -2
- package/src/screens/Sharing/MemberList.js +2 -1
- package/src/screens/Sharing/SelectPermission.js +2 -1
- package/src/screens/Sharing/SelectUser.js +3 -2
- package/src/screens/Sharing/__test__/MemberList.test.js +25 -28
- package/src/screens/Sharing/__test__/SelectPermission.test.js +16 -8
- package/src/screens/Sharing/__test__/SelectUser.test.js +33 -15
- package/src/screens/Sharing/hooks/index.js +22 -17
- package/src/screens/SubUnit/AddSubUnit.js +3 -2
- package/src/screens/SubUnit/Detail.js +5 -4
- package/src/screens/SubUnit/EditSubUnit.js +274 -0
- package/src/screens/SubUnit/EditSubUnitStyles.js +119 -0
- package/src/screens/SubUnit/ManageSubUnit.js +114 -371
- package/src/screens/SubUnit/ManageSubUnitStyles.js +40 -0
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +17 -11
- package/src/screens/SubUnit/__test__/Detail.test.js +11 -31
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +427 -0
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +51 -384
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +85 -0
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +35 -0
- package/src/screens/SyncLGDevice/AddLGDevice.js +3 -2
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +9 -1
- package/src/screens/TDSGuide/index.js +2 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +9 -1
- package/src/screens/UVIndexGuide/index.js +2 -1
- package/src/screens/Unit/AddMenu.js +3 -2
- package/src/screens/Unit/Detail.js +66 -20
- package/src/screens/Unit/ManageUnit/index.js +4 -3
- package/src/screens/Unit/ManageUnit.js +15 -4
- package/src/screens/Unit/MoreMenu.js +3 -2
- package/src/screens/Unit/SelectLocation.js +8 -2
- package/src/screens/Unit/SelectLocationStyles.js +11 -0
- package/src/screens/Unit/__test__/AddMenu.test.js +15 -15
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +19 -10
- package/src/screens/Unit/__test__/Detail.test.js +92 -33
- package/src/screens/Unit/__test__/ManageUnit.test.js +16 -23
- package/src/screens/Unit/components/Header/index.js +2 -1
- package/src/screens/Unit/components/ListMyAllUnit/index.js +2 -1
- package/src/screens/Unit/components/MyUnit/index.js +2 -1
- package/src/screens/Unit/components/SearchLocation/__test__/RowLocation.test.js +36 -0
- package/src/screens/Unit/components/SearchLocation/index.js +2 -1
- package/src/screens/Unit/components/SharedUnit/index.js +2 -1
- package/src/screens/Unit/components/__test__/MyUnit.test.js +22 -72
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +32 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +11 -2
- package/src/screens/UnitSummary/__test__/index.test.js +12 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +13 -3
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -12
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/components/Temperature/index.js +2 -1
- package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -1
- package/src/screens/UnitSummary/components/UvIndex/__test__/__snapshots__/index.test.js.snap +37 -37
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +14 -6
- package/src/screens/UnitSummary/components/UvIndex/index.js +2 -1
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +11 -5
- package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -1
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +13 -7
- package/src/screens/UnitSummary/components/__test__/UnitSummary.test.js +67 -0
- package/src/screens/UnitSummary/components/__test__/index.test.js +48 -0
- package/src/screens/UnitSummary/components/index.js +1 -37
- package/src/screens/UnitSummary/components/indexstyles.js +39 -0
- package/src/screens/UnitSummary/index.js +2 -1
- package/src/screens/WaterQualityGuide/__test__/index.test.js +12 -12
- package/src/screens/WaterQualityGuide/index.js +2 -1
- package/src/utils/Apis/axios.js +0 -4
- package/src/utils/Converter/array.js +4 -0
- package/src/utils/Converter/time.js +29 -4
- package/src/utils/I18n/index.ts +6 -0
- package/src/utils/I18n/translations/en.json +77 -5
- package/src/utils/I18n/translations/vi.json +73 -3
- package/src/utils/I18n/translations.ts +45 -0
- package/src/utils/Route/index.js +13 -0
- package/src/utils/__test__/InitData.test.js +20 -0
- package/src/commons/ChartLoading/__test__/__snapshots__/ChartLoading.test.js.snap +0 -66
- package/src/commons/Device/HistoryChart/__test__/HistoryChart.test.js +0 -57
- package/src/commons/Device/HistoryChart/__test__/__snapshots__/HistoryChart.test.js.snap +0 -593
- package/src/commons/Explore/SearchBox/__test__/__snapshots__/SearchBox.test.js.snap +0 -59
- package/src/commons/Header/__test__/Header.test.js +0 -24
- package/src/commons/MenuActionAddnew/__test__/__snapshots__/MenuActionAddNew.test.js.snap +0 -788
- package/src/commons/Sharing/__test__/__snapshots__/WrapHeaderScrollable.test.js.snap +0 -174
- package/src/commons/UnitSummary/AirQuality/__test__/__snapshots__/index.test.js.snap +0 -26679
- package/src/iot/RemoteControl/__test__/index.test.js +0 -101
- package/src/iot/__test__/Monitor.test.js +0 -119
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactAddNew.test.js.snap +0 -1706
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactList.test.js.snap +0 -4276
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactsSelectContacts.test.js.snap +0 -2240
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +0 -358
- package/src/screens/Unit/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/UnitSummary/components/WaterQuality/__test__/__snapshots__/index.test.js.snap +0 -1574
- package/src/screens/WaterQualityGuide/__test__/__snapshots__/index.test.js.snap +0 -3375
- package/src/utils/Converter/__test__/time.test.js +0 -126
- package/src/utils/I18n/index.js +0 -19
- package/src/utils/I18n/index.test.js +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { memo, useCallback, useState } from 'react';
|
|
2
2
|
import { TouchableOpacity, View, Switch } from 'react-native';
|
|
3
3
|
import { Icon } from '@ant-design/react-native';
|
|
4
|
-
import {
|
|
4
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
5
5
|
import styles from './ThreeButtonTemplateStyle';
|
|
6
6
|
import Text from '../Text';
|
|
7
7
|
import { TESTID } from '../../configs/Constants';
|
|
@@ -9,10 +9,15 @@ import { Colors } from '../../configs';
|
|
|
9
9
|
import { Card } from '../../commons/CardShadow';
|
|
10
10
|
|
|
11
11
|
const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
12
|
+
const t = useTranslations();
|
|
12
13
|
const { configuration } = actionGroup;
|
|
13
14
|
const [lock, setLock] = useState(false);
|
|
14
|
-
const
|
|
15
|
-
return
|
|
15
|
+
const iconCustom = (icon) => {
|
|
16
|
+
return icon === 'stop' ? (
|
|
17
|
+
<View style={styles.squareStop} />
|
|
18
|
+
) : (
|
|
19
|
+
<Icon name={icon} size={30} color={Colors.Primary} />
|
|
20
|
+
);
|
|
16
21
|
};
|
|
17
22
|
const onButton1Press = useCallback(
|
|
18
23
|
() => doAction(configuration.action1_data),
|
|
@@ -72,7 +77,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
72
77
|
onPress={onButton1Press}
|
|
73
78
|
underlayColor={Colors.Gray2}
|
|
74
79
|
>
|
|
75
|
-
<View style={styles.
|
|
80
|
+
<View style={styles.imageButton}>
|
|
76
81
|
<Icon
|
|
77
82
|
name={configuration.icon1}
|
|
78
83
|
size={30}
|
|
@@ -88,7 +93,9 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
88
93
|
onPress={onButton2Press}
|
|
89
94
|
underlayColor={Colors.Gray2}
|
|
90
95
|
>
|
|
91
|
-
<View style={styles.
|
|
96
|
+
<View style={styles.imageButton}>
|
|
97
|
+
{iconCustom(configuration.icon2)}
|
|
98
|
+
</View>
|
|
92
99
|
<Text style={styles.text}>{configuration.text2}</Text>
|
|
93
100
|
</TouchableOpacity>
|
|
94
101
|
|
|
@@ -98,7 +105,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
98
105
|
onPress={onButton3Press}
|
|
99
106
|
underlayColor={Colors.Gray2}
|
|
100
107
|
>
|
|
101
|
-
<View style={styles.
|
|
108
|
+
<View style={styles.imageButton}>
|
|
102
109
|
<Icon
|
|
103
110
|
name={configuration.icon3}
|
|
104
111
|
size={30}
|
|
@@ -3,58 +3,173 @@ import { Switch, TouchableOpacity, View } from 'react-native';
|
|
|
3
3
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
6
|
+
import { watchMultiConfigs } from '../../iot/Monitor';
|
|
7
|
+
|
|
8
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
9
|
|
|
7
10
|
import styles from './TimerActionTemplateStyles';
|
|
8
11
|
import Text from '../Text';
|
|
9
12
|
import { Colors } from '../../configs';
|
|
10
13
|
import { useConfigGlobalState } from '../../iot/states';
|
|
14
|
+
import BottomScrollPicker from '../BottomScrollPicker';
|
|
11
15
|
|
|
12
|
-
const TimerActionTemplate = ({ actionGroup, doAction }) => {
|
|
16
|
+
const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
17
|
+
const t = useTranslations();
|
|
13
18
|
const { configuration, title } = actionGroup;
|
|
14
|
-
const [
|
|
19
|
+
const [showTime, setShowTime] = useState(false);
|
|
20
|
+
const [showHour, setShowHour] = useState(false);
|
|
21
|
+
|
|
15
22
|
// eslint-disable-next-line no-unused-vars
|
|
16
23
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
24
|
+
const configHour = configValues[configuration.config_hour];
|
|
25
|
+
const configMinute = configValues[configuration.config_minute];
|
|
17
26
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const dataTime = useMemo(() => {
|
|
28
|
+
if (
|
|
29
|
+
!configuration.config_hour ||
|
|
30
|
+
!configuration.config_minute ||
|
|
31
|
+
configHour === undefined ||
|
|
32
|
+
configHour === null ||
|
|
33
|
+
configHour === -1 ||
|
|
34
|
+
configMinute === undefined ||
|
|
35
|
+
configMinute === null ||
|
|
36
|
+
configMinute === -1
|
|
37
|
+
) {
|
|
22
38
|
return undefined;
|
|
23
39
|
}
|
|
24
40
|
return moment(`${configHour}:${configMinute}`, 'HH:mm');
|
|
25
|
-
}, [
|
|
41
|
+
}, [
|
|
42
|
+
configHour,
|
|
43
|
+
configMinute,
|
|
44
|
+
configuration.config_hour,
|
|
45
|
+
configuration.config_minute,
|
|
46
|
+
]);
|
|
26
47
|
|
|
27
|
-
const
|
|
28
|
-
|
|
48
|
+
const dataHour = useMemo(() => {
|
|
49
|
+
if (
|
|
50
|
+
!configuration.config_hour ||
|
|
51
|
+
configuration.config_minute ||
|
|
52
|
+
configHour === undefined ||
|
|
53
|
+
configHour === null ||
|
|
54
|
+
configHour === -1
|
|
55
|
+
) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return configHour;
|
|
59
|
+
}, [configHour, configuration.config_hour, configuration.config_minute]);
|
|
60
|
+
|
|
61
|
+
const onShowHour = useCallback(() => {
|
|
62
|
+
setShowHour(true);
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const onHideHour = useCallback(() => {
|
|
66
|
+
setShowHour(false);
|
|
29
67
|
}, []);
|
|
30
68
|
|
|
31
|
-
const
|
|
32
|
-
|
|
69
|
+
const onShowTime = useCallback(() => {
|
|
70
|
+
setShowTime(true);
|
|
33
71
|
}, []);
|
|
34
72
|
|
|
35
|
-
const
|
|
73
|
+
const onHideTime = useCallback(() => {
|
|
74
|
+
setShowTime(false);
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
const onShowTimer = useCallback(() => {
|
|
78
|
+
if (configuration.config_hour && configuration.config_minute) {
|
|
79
|
+
onShowTime();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
onShowHour();
|
|
83
|
+
}, [
|
|
84
|
+
configuration.config_hour,
|
|
85
|
+
configuration.config_minute,
|
|
86
|
+
onShowHour,
|
|
87
|
+
onShowTime,
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
const doActionTime = useCallback(
|
|
91
|
+
(hour, minute) => {
|
|
92
|
+
doAction(configuration.action_data, [hour, minute]);
|
|
93
|
+
if (sensor.is_managed_by_backend) {
|
|
94
|
+
hour &&
|
|
95
|
+
minute &&
|
|
96
|
+
watchMultiConfigs([
|
|
97
|
+
configuration.config_hour,
|
|
98
|
+
configuration.config_minute,
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
[
|
|
103
|
+
configuration.action_data,
|
|
104
|
+
configuration.config_hour,
|
|
105
|
+
configuration.config_minute,
|
|
106
|
+
doAction,
|
|
107
|
+
sensor.is_managed_by_backend,
|
|
108
|
+
]
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const doActionHour = useCallback(
|
|
112
|
+
(hour) => {
|
|
113
|
+
doAction(configuration.action_data, hour);
|
|
114
|
+
if (sensor.is_managed_by_backend) {
|
|
115
|
+
hour && watchMultiConfigs([configuration.config_hour]);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
[
|
|
119
|
+
configuration.action_data,
|
|
120
|
+
configuration.config_hour,
|
|
121
|
+
doAction,
|
|
122
|
+
sensor.is_managed_by_backend,
|
|
123
|
+
]
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const onConfirmTime = useCallback(
|
|
36
127
|
(timeData) => {
|
|
37
|
-
|
|
128
|
+
onHideTime();
|
|
38
129
|
const timeObj = moment(timeData);
|
|
39
|
-
|
|
130
|
+
doActionTime(timeObj.hour(), timeObj.minute());
|
|
131
|
+
},
|
|
132
|
+
[doActionTime, onHideTime]
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const onConfirmHour = useCallback(
|
|
136
|
+
(number) => {
|
|
137
|
+
onHideHour();
|
|
138
|
+
doActionHour(number);
|
|
40
139
|
},
|
|
41
|
-
[
|
|
140
|
+
[doActionHour, onHideHour]
|
|
42
141
|
);
|
|
43
142
|
|
|
143
|
+
const onSwitchOff = useCallback(() => {
|
|
144
|
+
if (!isTimerOn) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
doActionTime(-1, -1);
|
|
148
|
+
}, [doActionTime, isTimerOn]);
|
|
149
|
+
|
|
44
150
|
const isTimerOn = useMemo(() => {
|
|
45
|
-
return !!
|
|
46
|
-
}, [
|
|
151
|
+
return !!dataTime;
|
|
152
|
+
}, [dataTime]);
|
|
153
|
+
|
|
154
|
+
const textTimer = useMemo(() => {
|
|
155
|
+
if (dataTime) {
|
|
156
|
+
return `${t('setting_at')} ${dataTime.format('HH:mm')}`;
|
|
157
|
+
}
|
|
158
|
+
if (dataHour) {
|
|
159
|
+
return `${t('setting_at')} ${dataHour} ${t('hours')}`;
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}, [dataHour, dataTime, t]);
|
|
47
163
|
|
|
48
164
|
return (
|
|
49
165
|
<View style={styles.wrap}>
|
|
50
166
|
<TouchableOpacity style={styles.timerButton} onPress={onShowTimer}>
|
|
51
167
|
<View style={styles.timerTitle}>
|
|
52
168
|
<Text>{title}</Text>
|
|
53
|
-
{
|
|
54
|
-
<Text
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
>{`Setting at ${currentTime.format('HH:mm')}`}</Text>
|
|
169
|
+
{textTimer && (
|
|
170
|
+
<Text type="Label" color={Colors.Gray7}>
|
|
171
|
+
{textTimer}
|
|
172
|
+
</Text>
|
|
58
173
|
)}
|
|
59
174
|
</View>
|
|
60
175
|
<View style={styles.timerButton}>
|
|
@@ -64,21 +179,31 @@ const TimerActionTemplate = ({ actionGroup, doAction }) => {
|
|
|
64
179
|
</Text>
|
|
65
180
|
</View>
|
|
66
181
|
</TouchableOpacity>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
182
|
+
{configuration.config_hour && configuration.config_minute && (
|
|
183
|
+
<Switch
|
|
184
|
+
trackColor={{ false: Colors.Gray4, true: Colors.Primary }}
|
|
185
|
+
thumbColor={isTimerOn ? Colors.White : Colors.Gray6}
|
|
186
|
+
ios_backgroundColor={Colors.Gray4}
|
|
187
|
+
value={isTimerOn}
|
|
188
|
+
onValueChange={onSwitchOff}
|
|
189
|
+
disabled={!isTimerOn}
|
|
190
|
+
/>
|
|
191
|
+
)}
|
|
74
192
|
<DateTimePickerModal
|
|
75
|
-
isVisible={
|
|
76
|
-
date={
|
|
193
|
+
isVisible={showTime}
|
|
194
|
+
date={dataTime ? dataTime.valueOf() : moment().valueOf()}
|
|
77
195
|
mode="time"
|
|
78
|
-
onConfirm={
|
|
79
|
-
onCancel={
|
|
196
|
+
onConfirm={onConfirmTime}
|
|
197
|
+
onCancel={onHideTime}
|
|
80
198
|
display="spinner"
|
|
81
199
|
/>
|
|
200
|
+
<BottomScrollPicker
|
|
201
|
+
min={configuration.min}
|
|
202
|
+
max={configuration.max}
|
|
203
|
+
isVisible={showHour}
|
|
204
|
+
onHide={onHideHour}
|
|
205
|
+
onPicked={onConfirmHour}
|
|
206
|
+
/>
|
|
82
207
|
</View>
|
|
83
208
|
);
|
|
84
209
|
};
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import Text from '../../../commons/Text';
|
|
5
|
+
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
6
|
+
import NumberUpDownActionTemplate from '../NumberUpDownActionTemplate';
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../iot/Monitor');
|
|
9
|
+
|
|
10
|
+
jest.mock('../../../iot/states', () => ({
|
|
11
|
+
useConfigGlobalState: () => [{ 5: 25 }, null],
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
describe('Test NumberUpDownActionTemplate', () => {
|
|
15
|
+
const action_data = {
|
|
16
|
+
color: '#00979D',
|
|
17
|
+
command_prefer_over_bluetooth: true,
|
|
18
|
+
command_prefer_over_googlehome: false,
|
|
19
|
+
command_prefer_over_internet: false,
|
|
20
|
+
googlehome_actions: [],
|
|
21
|
+
icon: 'caret-up',
|
|
22
|
+
id: 20,
|
|
23
|
+
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let actionGroup;
|
|
27
|
+
let wrapper;
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
watchMultiConfigs.mockClear();
|
|
31
|
+
actionGroup = {
|
|
32
|
+
configuration: {
|
|
33
|
+
keep_track_config: false,
|
|
34
|
+
config: 5,
|
|
35
|
+
action_data,
|
|
36
|
+
min_value: 16,
|
|
37
|
+
max_value: 30,
|
|
38
|
+
text_format: '{number} *C',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('render template', async () => {
|
|
44
|
+
const mockDoAction = jest.fn();
|
|
45
|
+
await act(async () => {
|
|
46
|
+
wrapper = await create(
|
|
47
|
+
<NumberUpDownActionTemplate
|
|
48
|
+
actionGroup={actionGroup}
|
|
49
|
+
doAction={mockDoAction}
|
|
50
|
+
sensor={{ is_managed_by_backend: true }}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
const instance = wrapper.root;
|
|
55
|
+
const text = instance.findByType(Text);
|
|
56
|
+
expect(text.props.children).toEqual('25 *C');
|
|
57
|
+
|
|
58
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
59
|
+
expect(touchs).toHaveLength(2);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('do action call watchConfigs', async () => {
|
|
63
|
+
actionGroup.configuration.keep_track_config = true;
|
|
64
|
+
const mockDoAction = jest.fn();
|
|
65
|
+
await act(async () => {
|
|
66
|
+
wrapper = await create(
|
|
67
|
+
<NumberUpDownActionTemplate
|
|
68
|
+
actionGroup={actionGroup}
|
|
69
|
+
doAction={mockDoAction}
|
|
70
|
+
sensor={{ is_managed_by_backend: true }}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
const instance = wrapper.root;
|
|
75
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
76
|
+
expect(touchs).toHaveLength(2);
|
|
77
|
+
|
|
78
|
+
await act(async () => {
|
|
79
|
+
await touchs[0].props.onPress();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
expect(watchMultiConfigs).toBeCalled();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('do action not call watchConfigs cause is_managed_by_backend false', async () => {
|
|
86
|
+
const mockDoAction = jest.fn();
|
|
87
|
+
await act(async () => {
|
|
88
|
+
wrapper = await create(
|
|
89
|
+
<NumberUpDownActionTemplate
|
|
90
|
+
actionGroup={actionGroup}
|
|
91
|
+
doAction={mockDoAction}
|
|
92
|
+
sensor={{ is_managed_by_backend: false }}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
const instance = wrapper.root;
|
|
97
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
98
|
+
expect(touchs).toHaveLength(2);
|
|
99
|
+
|
|
100
|
+
await act(async () => {
|
|
101
|
+
await touchs[0].props.onPress();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(watchMultiConfigs).not.toBeCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('do action not call watchConfigs cause keep track config false', async () => {
|
|
108
|
+
const mockDoAction = jest.fn();
|
|
109
|
+
await act(async () => {
|
|
110
|
+
wrapper = await create(
|
|
111
|
+
<NumberUpDownActionTemplate
|
|
112
|
+
actionGroup={actionGroup}
|
|
113
|
+
doAction={mockDoAction}
|
|
114
|
+
sensor={{ is_managed_by_backend: true }}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
const instance = wrapper.root;
|
|
119
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
120
|
+
expect(touchs).toHaveLength(2);
|
|
121
|
+
|
|
122
|
+
await act(async () => {
|
|
123
|
+
await touchs[0].props.onPress();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(watchMultiConfigs).not.toBeCalled();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('action down without config', async () => {
|
|
130
|
+
actionGroup.configuration.keep_track_config = true;
|
|
131
|
+
actionGroup.configuration.config = undefined;
|
|
132
|
+
const mockDoAction = jest.fn();
|
|
133
|
+
await act(async () => {
|
|
134
|
+
wrapper = await create(
|
|
135
|
+
<NumberUpDownActionTemplate
|
|
136
|
+
actionGroup={actionGroup}
|
|
137
|
+
doAction={mockDoAction}
|
|
138
|
+
sensor={{ is_managed_by_backend: true }}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
const instance = wrapper.root;
|
|
143
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
144
|
+
expect(touchs).toHaveLength(2);
|
|
145
|
+
|
|
146
|
+
await act(async () => {
|
|
147
|
+
await touchs[0].props.onPress();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(watchMultiConfigs).not.toBeCalled();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('action down without keep track config', async () => {
|
|
154
|
+
const mockDoAction = jest.fn();
|
|
155
|
+
await act(async () => {
|
|
156
|
+
wrapper = await create(
|
|
157
|
+
<NumberUpDownActionTemplate
|
|
158
|
+
actionGroup={actionGroup}
|
|
159
|
+
doAction={mockDoAction}
|
|
160
|
+
sensor={{ is_managed_by_backend: true }}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
const instance = wrapper.root;
|
|
165
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
166
|
+
expect(touchs).toHaveLength(2);
|
|
167
|
+
|
|
168
|
+
await act(async () => {
|
|
169
|
+
await touchs[0].props.onPress();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const text = instance.findByType(Text);
|
|
173
|
+
expect(text.props.children).toEqual('24 *C');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('action up without keep track config', async () => {
|
|
177
|
+
const mockDoAction = jest.fn();
|
|
178
|
+
await act(async () => {
|
|
179
|
+
wrapper = await create(
|
|
180
|
+
<NumberUpDownActionTemplate
|
|
181
|
+
actionGroup={actionGroup}
|
|
182
|
+
doAction={mockDoAction}
|
|
183
|
+
sensor={{ is_managed_by_backend: true }}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
const instance = wrapper.root;
|
|
188
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
189
|
+
expect(touchs).toHaveLength(2);
|
|
190
|
+
|
|
191
|
+
await act(async () => {
|
|
192
|
+
await touchs[1].props.onPress();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const text = instance.findByType(Text);
|
|
196
|
+
expect(text.props.children).toEqual('26 *C');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('action down with keep track config', async () => {
|
|
200
|
+
actionGroup.configuration.keep_track_config = true;
|
|
201
|
+
const mockDoAction = jest.fn();
|
|
202
|
+
await act(async () => {
|
|
203
|
+
wrapper = await create(
|
|
204
|
+
<NumberUpDownActionTemplate
|
|
205
|
+
actionGroup={actionGroup}
|
|
206
|
+
doAction={mockDoAction}
|
|
207
|
+
sensor={{ is_managed_by_backend: true }}
|
|
208
|
+
/>
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
const instance = wrapper.root;
|
|
212
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
213
|
+
expect(touchs).toHaveLength(2);
|
|
214
|
+
|
|
215
|
+
await act(async () => {
|
|
216
|
+
await touchs[0].props.onPress();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const text = instance.findByType(Text);
|
|
220
|
+
expect(text.props.children).toEqual('25 *C'); // TODO should 24, configValues make changes again
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test('action up with keep track config', async () => {
|
|
224
|
+
actionGroup.configuration.keep_track_config = true;
|
|
225
|
+
const mockDoAction = jest.fn();
|
|
226
|
+
await act(async () => {
|
|
227
|
+
wrapper = await create(
|
|
228
|
+
<NumberUpDownActionTemplate
|
|
229
|
+
actionGroup={actionGroup}
|
|
230
|
+
doAction={mockDoAction}
|
|
231
|
+
sensor={{ is_managed_by_backend: true }}
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
const instance = wrapper.root;
|
|
236
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
237
|
+
expect(touchs).toHaveLength(2);
|
|
238
|
+
|
|
239
|
+
await act(async () => {
|
|
240
|
+
await touchs[1].props.onPress();
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const text = instance.findByType(Text);
|
|
244
|
+
expect(text.props.children).toEqual('25 *C'); // TODO should 26, configValues make changes again
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test('action down limit ', async () => {
|
|
248
|
+
actionGroup.configuration.min_value = 25;
|
|
249
|
+
const mockDoAction = jest.fn();
|
|
250
|
+
await act(async () => {
|
|
251
|
+
wrapper = await create(
|
|
252
|
+
<NumberUpDownActionTemplate
|
|
253
|
+
actionGroup={actionGroup}
|
|
254
|
+
doAction={mockDoAction}
|
|
255
|
+
sensor={{ is_managed_by_backend: true }}
|
|
256
|
+
/>
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
const instance = wrapper.root;
|
|
260
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
261
|
+
expect(touchs).toHaveLength(2);
|
|
262
|
+
|
|
263
|
+
await act(async () => {
|
|
264
|
+
await touchs[0].props.onPress();
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const text = instance.findByType(Text);
|
|
268
|
+
expect(text.props.children).toEqual('25 *C');
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test('action up limit ', async () => {
|
|
272
|
+
actionGroup.configuration.max_value = 25;
|
|
273
|
+
const mockDoAction = jest.fn();
|
|
274
|
+
await act(async () => {
|
|
275
|
+
wrapper = await create(
|
|
276
|
+
<NumberUpDownActionTemplate
|
|
277
|
+
actionGroup={actionGroup}
|
|
278
|
+
doAction={mockDoAction}
|
|
279
|
+
sensor={{ is_managed_by_backend: true }}
|
|
280
|
+
/>
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
const instance = wrapper.root;
|
|
284
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
285
|
+
expect(touchs).toHaveLength(2);
|
|
286
|
+
|
|
287
|
+
await act(async () => {
|
|
288
|
+
await touchs[1].props.onPress();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const text = instance.findByType(Text);
|
|
292
|
+
expect(text.props.children).toEqual('25 *C');
|
|
293
|
+
});
|
|
294
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import Text from '../../../commons/Text';
|
|
5
|
+
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
6
|
+
import NumberUpDownActionTemplate from '../NumberUpDownActionTemplate';
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../iot/Monitor');
|
|
9
|
+
|
|
10
|
+
jest.mock('../../../iot/states', () => ({
|
|
11
|
+
useConfigGlobalState: () => [{ 5: null }, null],
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
describe('Test NumberUpDownActionTemplate', () => {
|
|
15
|
+
const action_data = {
|
|
16
|
+
color: '#00979D',
|
|
17
|
+
command_prefer_over_bluetooth: true,
|
|
18
|
+
command_prefer_over_googlehome: false,
|
|
19
|
+
command_prefer_over_internet: false,
|
|
20
|
+
googlehome_actions: [],
|
|
21
|
+
icon: 'caret-up',
|
|
22
|
+
id: 20,
|
|
23
|
+
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let actionGroup;
|
|
27
|
+
let wrapper;
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
watchMultiConfigs.mockClear();
|
|
31
|
+
actionGroup = {
|
|
32
|
+
configuration: {
|
|
33
|
+
config: 5,
|
|
34
|
+
action_data,
|
|
35
|
+
min_value: 16,
|
|
36
|
+
max_value: 30,
|
|
37
|
+
text_format: '{number} *C',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('render template', async () => {
|
|
43
|
+
const mockDoAction = jest.fn();
|
|
44
|
+
await act(async () => {
|
|
45
|
+
wrapper = await create(
|
|
46
|
+
<NumberUpDownActionTemplate
|
|
47
|
+
actionGroup={actionGroup}
|
|
48
|
+
doAction={mockDoAction}
|
|
49
|
+
sensor={{ is_managed_by_backend: true }}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
const instance = wrapper.root;
|
|
54
|
+
const text = instance.findByType(Text);
|
|
55
|
+
expect(text.props.children).toEqual('28 *C');
|
|
56
|
+
|
|
57
|
+
const touchs = instance.findAllByType(TouchableOpacity);
|
|
58
|
+
expect(touchs).toHaveLength(2);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
2
|
import { act, create } from 'react-test-renderer';
|
|
4
3
|
import Index from '../OnOffTemplate';
|
|
5
4
|
|
|
@@ -58,9 +57,13 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
58
57
|
|
|
59
58
|
const renderJson = wrapper.toJSON();
|
|
60
59
|
|
|
61
|
-
expect(renderJson
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
expect(renderJson?.children[0].children[0].children[1].children).toEqual(
|
|
61
|
+
undefined
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(
|
|
65
|
+
renderJson?.children[0].children[0].children[1].children
|
|
66
|
+
).not.toEqual([text]);
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
test('render state on', () => {
|
|
@@ -80,15 +83,7 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
80
83
|
);
|
|
81
84
|
});
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
const buttons = instance.findAllByType(TouchableOpacity);
|
|
85
|
-
|
|
86
|
-
act(() => {
|
|
87
|
-
buttons[0].props.onPress();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
91
|
-
expect(mockDoAction).toHaveBeenCalledWith(action_data);
|
|
86
|
+
expect(mockDoAction).not.toHaveBeenCalled();
|
|
92
87
|
};
|
|
93
88
|
|
|
94
89
|
test('action state on', () => {
|