@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.
- package/package.json +1 -1
- package/src/Images/Common/reorder.svg +3 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +3 -1
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -10
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +1 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +1 -1
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +13 -5
- package/src/commons/ActionGroup/SliderRangeTemplate.js +100 -69
- package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +27 -27
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -1
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +1 -1
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -1
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +56 -0
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -2
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +45 -8
- package/src/commons/ActionGroup/__test__/index.test.js +0 -19
- package/src/commons/ActionGroup/index.js +0 -3
- package/src/commons/ActionTemplate/CurtainAction.js +5 -5
- package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffButtonAction.js +4 -4
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffSimpleAction.js +4 -4
- package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +4 -4
- package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OneButtonAction.js +3 -3
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/ThreeButtonAction.js +5 -5
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffSimpleAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/index.test.js +21 -70
- package/src/commons/ActionTemplate/index.js +19 -55
- package/src/commons/Alert/__test__/Alert.test.js +1 -1
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Auth/__test__/OtpInputList.test.js +17 -19
- package/src/commons/Automate/ItemAutomate.js +10 -4
- package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
- package/src/commons/BackDefault/__test__/BackDefault.test.js +1 -1
- package/src/commons/Button/__test__/Button.test.js +1 -1
- package/src/commons/ButtonPopup/__test__/ButtonPopup.test.js +1 -1
- package/src/commons/Calendar/__test__/Calendar.test.js +1 -1
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +1 -1
- package/src/commons/CircleButton/__test__/CircleButton.test.js +1 -1
- package/src/commons/CircleView/__test__/CircleView.test.js +1 -1
- package/src/commons/DateTimeRangeChange/__test__/DateTimeButton.test.js +4 -2
- package/src/commons/DateTimeRangeChange/index.js +31 -48
- package/src/commons/Device/DeviceAlertStatus.js +2 -1
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +2 -2
- package/src/commons/Device/HistoryChart.js +6 -49
- package/src/commons/Device/LinearChart/LinearChart.test.js +1 -1
- package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
- package/src/commons/Device/ProgressBar/index.js +5 -11
- package/src/commons/Device/ProgressBar/styles.js +11 -3
- package/src/commons/Device/RainningSensor/__test__/CurrentRainSensor.test.js +5 -5
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +3 -3
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +2 -2
- package/src/commons/Device/WindSpeed/Anemometer/index.js +2 -0
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
- package/src/commons/Device/WindSpeed/LinearChart/index.js +5 -3
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +3 -3
- package/src/commons/Device/__test__/DisconnectedView.test.js +2 -2
- package/src/commons/Device/__test__/FlatListItems.test.js +1 -1
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +1 -1
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
- package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
- package/src/commons/FlatListDnD/index.js +37 -0
- package/src/commons/FlatListDnD/styles.js +12 -0
- package/src/commons/Form/__test__/CurrencyInput.test.js +2 -2
- package/src/commons/Form/__test__/TextInput.test.js +3 -3
- package/src/commons/Form/__test__/TextInputPassword.test.js +2 -2
- package/src/commons/FullLoading/__test__/index.test.js +2 -2
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +65 -38
- package/src/commons/IconComponent/index.js +3 -2
- package/src/commons/ImageButton/__test__/ImageButton.test.js +1 -1
- package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
- package/src/commons/MediaPlayer/index.js +11 -7
- package/src/commons/MenuActionMore/index.js +6 -4
- package/src/commons/Modal/ModalBottom.js +2 -3
- package/src/commons/Modal/ModalCustom.js +2 -3
- package/src/commons/NavBar/index.js +48 -50
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +5 -5
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +5 -5
- package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +2 -2
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +2 -2
- package/src/commons/PreventAccess/index.js +1 -1
- package/src/commons/RowItem/__test__/RowItem.test.js +1 -1
- package/src/commons/RowUser/__test__/RowUser.test.js +1 -1
- package/src/commons/Section/Section.test.js +2 -2
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -1
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +3 -3
- package/src/commons/Sharing/StationDevicePermissions.js +4 -4
- package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
- package/src/commons/Sharing/__test__/ButtonRemoveMember.test.js +1 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +3 -3
- package/src/commons/Sharing/__test__/MemberList.test.js +6 -4
- package/src/commons/Sharing/__test__/RowMember.test.js +2 -2
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +4 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -11
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +13 -16
- package/src/commons/SubUnit/OneTap/index.js +22 -7
- package/src/commons/TextButton/__test__/TextButton.test.js +2 -2
- package/src/commons/Today/__test__/Today.test.js +1 -1
- package/src/commons/TouchableScale/__test__/TouchableScale.test.js +1 -1
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
- package/src/commons/UnitSummary/AirQuality/index.js +2 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +0 -6
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +1 -1
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +1 -1
- package/src/commons/ViewButtonBottom/__test__/ViewButtonBottom.test.js +1 -1
- package/src/configs/API.js +14 -31
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/Colors.js +1 -1
- package/src/configs/Constants.js +14 -48
- package/src/context/reducer.ts +3 -1
- package/src/hoc/__test__/withRemoteControl.test.js +1 -1
- package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useKeyboardShow.js +4 -4
- package/src/hooks/Common/useStatusBar.js +2 -2
- package/src/hooks/Common/useTitleHeader.js +5 -7
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
- package/src/hooks/IoT/useBluetoothConnection.js +6 -3
- package/src/hooks/index.js +1 -2
- package/src/navigations/UnitStack.js +51 -17
- package/src/screens/ActivityLog/FilterPopup.js +4 -4
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +3 -3
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +5 -5
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +9 -33
- package/src/screens/AddNewAutoSmart/index.js +33 -89
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +1 -1
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +2 -2
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +3 -3
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +2 -2
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +8 -16
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +10 -12
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +1 -1
- package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
- package/src/screens/AddNewGateway/index.js +1 -1
- package/src/screens/AllCamera/__test__/index.test.js +18 -57
- package/src/screens/AllCamera/index.js +100 -33
- package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
- package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
- package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
- package/src/screens/Automate/AddNewAction/ChooseAction.js +139 -0
- package/src/screens/Automate/AddNewAction/ChooseConfig.js +179 -0
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
- package/src/screens/Automate/AddNewAction/Components/SelectDevices.js +75 -0
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +4 -4
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +56 -0
- package/src/screens/Automate/AddNewAction/SelectControlDevices.js +69 -0
- package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +110 -0
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +196 -0
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +5 -3
- package/src/screens/{AddNewAction/__test__/SelectAction.test.js → Automate/AddNewAction/__test__/ChooseAction.test.js} +101 -122
- package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +210 -0
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +130 -0
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +92 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupSensor.test.js +131 -0
- package/src/screens/Automate/Components/InputName.js +64 -0
- package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +2 -2
- package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
- package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +20 -12
- package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +18 -19
- package/src/screens/Automate/MultiUnits.js +70 -68
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
- package/src/screens/Automate/OneTap/index.js +16 -0
- package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
- package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
- package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
- package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +67 -76
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
- package/src/screens/Automate/ScriptDetail/index.js +346 -0
- package/src/screens/Automate/ScriptDetail/utils.js +113 -0
- package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
- package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
- package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
- package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
- package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
- package/src/screens/Automate/SetSchedule/index.js +140 -0
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
- package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
- package/src/screens/Automate/__test__/MultiUnits.test.js +78 -122
- package/src/screens/Automate/__test__/index.test.js +21 -47
- package/src/screens/Automate/constants.js +0 -0
- package/src/screens/Automate/index.js +18 -24
- package/src/screens/ChangePosition/__test__/index.test.js +75 -0
- package/src/screens/ChangePosition/index.js +112 -0
- package/src/screens/ChangePosition/styles.js +87 -0
- package/src/screens/Device/__test__/DetailHistoryChart.test.js +2 -2
- package/src/screens/Device/__test__/EmergencyCountdown.test.js +4 -2
- package/src/screens/Device/__test__/detail.test.js +202 -257
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -10
- package/src/screens/Device/components/ChartWrapper.js +3 -3
- package/src/screens/Device/components/SensorDisplayItem.js +2 -1
- package/src/screens/Device/components/VisualChart.js +56 -9
- package/src/screens/Device/components/__test__/VisualChart.test.js +1 -1
- package/src/screens/Device/detail.js +14 -0
- package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
- package/src/screens/Device/hooks/useEvaluateValue.js +28 -2
- package/src/screens/Device/styles.js +7 -0
- package/src/screens/DeviceInfo/__test__/index.test.js +16 -18
- package/src/screens/DeviceInfo/index.js +6 -5
- package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
- package/src/screens/Notification/__test__/Notification.test.js +64 -73
- package/src/screens/Notification/index.js +14 -14
- package/src/screens/PlayBackCamera/index.js +2 -3
- package/src/screens/SelectUnit/__test__/index.test.js +0 -5
- package/src/screens/SelectUnit/index.js +1 -2
- package/src/screens/SharedUnit/index.js +5 -4
- package/src/screens/Sharing/Components/TitleCheckBox.js +2 -2
- package/src/screens/Sharing/SelectUser.js +2 -2
- package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
- package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
- package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +3 -3
- package/src/screens/SmartAccount/__test__/Connecting.test.js +1 -1
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +3 -3
- package/src/screens/SmartAccount/index.js +1 -0
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +1 -1
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +2 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +2 -2
- package/src/screens/SmartIr/__test__/SmartIr.test.js +2 -2
- package/src/screens/SubUnit/ManageSubUnit.js +4 -4
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
- package/src/screens/TDSGuide/index.js +1 -1
- package/src/screens/Template/GatewayList.js +4 -1
- package/src/screens/Template/__test__/detail.test.js +24 -22
- package/src/screens/Template/detail.js +1 -0
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/Detail.js +6 -5
- package/src/screens/Unit/SelectAddToFavorites.js +1 -1
- package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
- package/src/screens/Unit/__test__/Detail.test.js +10 -14
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
- package/src/screens/Unit/components/__test__/Header.test.js +4 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +14 -6
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/Temperature/index.js +2 -2
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
- package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
- package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +1 -1
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/__test__/index.test.js +2 -2
- package/src/screens/WaterQualityGuide/index.js +10 -5
- package/src/utils/Apis/axios.js +3 -0
- package/src/utils/I18n/translations/en.json +24 -18
- package/src/utils/I18n/translations/vi.json +22 -18
- package/src/utils/Route/index.js +9 -3
- package/src/utils/Utils.js +29 -0
- package/src/utils/__test__/Utils.test.js +6 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
- package/src/commons/Auth/SocialButton.js +0 -54
- package/src/commons/Auth/__test__/SocialButton.test.js +0 -44
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
- package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
- package/src/hooks/useInitDeepLink.js +0 -25
- package/src/screens/AddNewAction/SelectAction.js +0 -570
- package/src/screens/AddNewAction/SelectSensorDevices.js +0 -236
- package/src/screens/AddNewAction/SetupSensor.js +0 -263
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +0 -181
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +0 -114
- package/src/screens/AddNewOneTap/index.js +0 -147
- package/src/screens/ScriptDetail/hooks/index.js +0 -136
- package/src/screens/ScriptDetail/index.js +0 -525
- package/src/screens/SetSchedule/index.js +0 -200
- /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
- /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
package/package.json
CHANGED
|
@@ -46,7 +46,9 @@ describe('Test AutoLock', () => {
|
|
|
46
46
|
|
|
47
47
|
const instance = tree.root;
|
|
48
48
|
const switchs = instance.findByType(Switch);
|
|
49
|
-
await
|
|
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, {
|
|
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 =
|
|
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
|
});
|
package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js
CHANGED
|
@@ -89,7 +89,7 @@ export default StyleSheet.create({
|
|
|
89
89
|
bottom: 0,
|
|
90
90
|
left: 0,
|
|
91
91
|
right: 0,
|
|
92
|
-
paddingBottom: getBottomSpace()
|
|
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
|
-
({
|
|
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, {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
57
|
+
const getTextInputValue = useMemo(() => {
|
|
58
|
+
if ([null, undefined, NaN].includes(valueBrightness)) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
26
61
|
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
39
|
-
percentTemp = valueBrightness;
|
|
40
|
-
}, [valueBrightness]);
|
|
65
|
+
const onValueChange = (value) => setValueBrightness(value[0]);
|
|
41
66
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
const onInputChange = (value) => {
|
|
68
|
+
if (isNaN(value)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
45
71
|
setValueBrightness(value);
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
<View style={styles.LeftBrightness}>
|
|
61
|
-
<SvgBrightness />
|
|
88
|
+
return (
|
|
89
|
+
<View style={styles.viewBrightness}>
|
|
62
90
|
<Text type="H4" style={styles.LeftTextBrightness}>
|
|
63
|
-
{actionGroup
|
|
91
|
+
{actionGroup?.title || item?.label || t('brightness')}
|
|
64
92
|
</Text>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
|
|
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
|
-
|
|
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:
|
|
21
|
-
borderRadius: 30,
|
|
14
|
+
height: 4,
|
|
22
15
|
},
|
|
23
16
|
thumbSlider: {
|
|
24
|
-
backgroundColor: Colors.
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
paddingLeft: 8,
|
|
27
|
+
text: {
|
|
28
|
+
marginTop: 8,
|
|
44
29
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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}
|
|
@@ -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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
10
|
+
jest.mock('../../../iot/states', () => ({
|
|
11
|
+
useConfigGlobalState: jest.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const wrapComponent = (actionGroup, mockDoAction, isOn) => (
|
|
9
15
|
<SCProvider initState={mockSCStore({})}>
|
|
10
|
-
<SwitchButtonTemplate
|
|
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
|
-
|
|
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
|
-
|
|
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 () => {
|