@eohjsc/react-native-smart-city 0.3.4 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -36
- package/package.json +5 -9
- package/react-native-smart-city.podspec +0 -1
- package/src/commons/Action/ItemQuickAction.js +4 -16
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
- package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
- package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
- package/src/commons/ActionGroup/__test__/index.test.js +4 -142
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +3 -1
- package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
- package/src/commons/ConnectingProcess/index.js +25 -75
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/HistoryChart.js +3 -7
- package/src/commons/Device/ItemDevice.js +12 -19
- package/src/commons/Device/LinearChart.js +0 -15
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
- package/src/commons/Explore/__test__/CityItem.test.js +54 -33
- package/src/commons/Form/CurrencyInput.js +1 -15
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +1 -2
- package/src/commons/Header/HeaderCustom.js +1 -2
- package/src/commons/HeaderAni/index.js +1 -6
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
- package/src/commons/MediaPlayerDetail/index.js +47 -25
- package/src/commons/MenuActionAddnew/index.js +0 -1
- package/src/commons/MenuActionList/index.js +0 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/index.js +1 -9
- package/src/commons/Sharing/MemberList.js +2 -10
- package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
- package/src/commons/SubUnit/Favorites/index.js +3 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
- package/src/commons/SubUnit/OneTap/index.js +2 -1
- package/src/commons/SubUnit/ShortDetail.js +9 -25
- package/src/commons/SubUnit/__test__/Item.test.js +1 -0
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
- package/src/commons/Unit/SharedUnit.js +0 -1
- package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
- package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
- package/src/commons/WheelDateTimePicker/index.js +3 -4
- package/src/configs/API.js +143 -87
- package/src/configs/Constants.js +2 -57
- package/src/configs/SCConfig.js +0 -4
- package/src/context/actionType.ts +0 -8
- package/src/context/mockStore.ts +0 -10
- package/src/context/reducer.ts +2 -38
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useGetIdUser.js +5 -1
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/useReceiveNotifications.js +5 -9
- package/src/iot/Monitor.js +2 -3
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +49 -75
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +20 -11
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +0 -2
- package/src/screens/ActivityLog/__test__/index.test.js +23 -38
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +0 -1
- package/src/screens/AddCommon/SelectUnit.js +0 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
- package/src/screens/AddLocationMaps/index.js +5 -9
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
- package/src/screens/AddNewAutoSmart/index.js +2 -5
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewDevice/index.js +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
- package/src/screens/AddNewGateway/SelectGateway.js +0 -1
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
- package/src/screens/AddNewGateway/index.js +0 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
- package/src/screens/AddNewOneTap/index.js +2 -3
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
- package/src/screens/Automate/__test__/index.test.js +12 -7
- package/src/screens/Automate/index.js +3 -5
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
- package/src/screens/ConfirmUnitDeletion/index.js +1 -7
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
- package/src/screens/Device/EditDevice/index.js +15 -17
- package/src/screens/Device/__test__/detail.test.js +86 -33
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
- package/src/screens/Device/components/SensorDisplayItem.js +2 -5
- package/src/screens/Device/detail.js +24 -80
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
- package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +1 -4
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
- package/src/screens/Explore/index.js +0 -2
- package/src/screens/GuestInfo/__test__/index.test.js +41 -14
- package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +12 -8
- package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +22 -33
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
- package/src/screens/ManageAccess/hooks/index.js +4 -7
- package/src/screens/ManageAccess/index.js +1 -2
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +25 -14
- package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
- package/src/screens/Notification/components/NotificationItem.js +20 -17
- package/src/screens/Notification/index.js +2 -9
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
- package/src/screens/PlayBackCamera/index.js +6 -22
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
- package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
- package/src/screens/ScanChipQR/hooks/index.js +16 -15
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
- package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
- package/src/screens/ScriptDetail/index.js +14 -19
- package/src/screens/SelectUnit/__test__/index.test.js +55 -12
- package/src/screens/SelectUnit/index.js +4 -9
- package/src/screens/SetSchedule/index.js +11 -15
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
- package/src/screens/SharedUnit/index.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +12 -10
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +11 -12
- package/src/screens/Sharing/SelectPermission.js +76 -121
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
- package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
- package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
- package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
- package/src/screens/Sharing/hooks/index.js +0 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +17 -23
- package/src/screens/SubUnit/Detail.js +2 -1
- package/src/screens/SubUnit/EditSubUnit.js +13 -15
- package/src/screens/SubUnit/ManageSubUnit.js +7 -13
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
- package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
- package/src/screens/TDSGuide/index.js +1 -4
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +14 -7
- package/src/screens/Unit/Detail.js +75 -30
- package/src/screens/Unit/ManageUnit.js +0 -1
- package/src/screens/Unit/SelectAddress.js +23 -45
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +0 -4
- package/src/screens/Unit/Summaries.js +2 -18
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
- package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
- package/src/screens/Unit/__test__/Detail.test.js +200 -99
- package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
- package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +0 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
- package/src/screens/Unit/styles.js +0 -4
- package/src/screens/UnitSummary/__test__/index.test.js +30 -91
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
- package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
- package/src/screens/UnitSummary/index.js +1 -15
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +31 -54
- package/src/utils/Converter/time.js +18 -0
- package/src/utils/I18n/translations/en.json +1 -7
- package/src/utils/I18n/translations/vi.json +1 -8
- package/src/utils/Route/index.js +0 -1
- package/src/utils/Utils.js +7 -11
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
- package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
- package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
- package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
- package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
- package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
- package/src/hooks/IoT/index.js +0 -4
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/hooks/IoT/useRemoteControl.js +0 -79
- package/src/hooks/index.js +0 -4
- package/src/navigations/UnitStackStyles.js +0 -21
- package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
- package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
- package/src/screens/SideMenuDetail/index.js +0 -148
- package/src/screens/Unit/__test__/Summaries.test.js +0 -100
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
- package/src/utils/Permission/common.js +0 -67
- package/src/utils/Setting/Location.js +0 -30
- package/src/utils/__test__/Utils.test.js +0 -12
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import styles from './ScheduleFieldStyles';
|
|
4
|
-
import moment from 'moment';
|
|
5
|
-
|
|
6
|
-
import Text from '../../Text';
|
|
7
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
8
|
-
import AccessScheduleItem from '../../../screens/GuestInfo/components/AccessScheduleItem';
|
|
9
|
-
import RecurringDetail from '../../../screens/GuestInfo/components/RecurringDetail';
|
|
10
|
-
import TemporaryDetail from '../../../screens/GuestInfo/components/TemporaryDetail';
|
|
11
|
-
import { useBoolean } from '../../../hooks/Common';
|
|
12
|
-
import WheelDateTimePicker from '../../WheelDateTimePicker';
|
|
13
|
-
import { ACCESS_SCHEDULE } from '../../../screens/GuestInfo/constant';
|
|
14
|
-
|
|
15
|
-
const ScheduleField = ({ dataItem, index, setDataForm, dataForm }) => {
|
|
16
|
-
const t = useTranslations();
|
|
17
|
-
const [accessSchedule, setAccessSchedule] = useState('always');
|
|
18
|
-
const [lockShowing, releaseLockShowing, acquireLockShowing] =
|
|
19
|
-
useBoolean(true);
|
|
20
|
-
|
|
21
|
-
const [stateDateTimePicker, setStateDateTimePicker] = useState({
|
|
22
|
-
isVisible: false,
|
|
23
|
-
mode: 'time',
|
|
24
|
-
defaultValue: moment(),
|
|
25
|
-
setter: null,
|
|
26
|
-
});
|
|
27
|
-
const [recurringTimeStart, setRecurringTimeStart] = useState(moment());
|
|
28
|
-
const [recurringTimeEnd, setRecurringTimeEnd] = useState(
|
|
29
|
-
moment().add(1, 'hours')
|
|
30
|
-
);
|
|
31
|
-
const [recurringTimeRepeat, setRecurringTimeRepeat] = useState([]);
|
|
32
|
-
const [temporaryTimeStart, setTemporaryTimeStart] = useState(moment());
|
|
33
|
-
const [temporaryTimeEnd, setTemporaryTimeEnd] = useState(
|
|
34
|
-
moment().add(1, 'days')
|
|
35
|
-
);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (accessSchedule === ACCESS_SCHEDULE.ALWAYS) {
|
|
38
|
-
dataItem.valid = true;
|
|
39
|
-
dataItem.data = {
|
|
40
|
-
access_schedule: accessSchedule,
|
|
41
|
-
};
|
|
42
|
-
} else if (accessSchedule === ACCESS_SCHEDULE.RECURRING) {
|
|
43
|
-
dataItem.valid = true;
|
|
44
|
-
dataItem.data = {
|
|
45
|
-
access_schedule: accessSchedule,
|
|
46
|
-
recurring_time_start: recurringTimeStart.format(),
|
|
47
|
-
recurring_time_end: recurringTimeEnd.format(),
|
|
48
|
-
recurring_time_repeat: recurringTimeRepeat,
|
|
49
|
-
};
|
|
50
|
-
} else if (accessSchedule === ACCESS_SCHEDULE.TEMPORARY) {
|
|
51
|
-
if (temporaryTimeStart > temporaryTimeEnd) {
|
|
52
|
-
dataItem.valid = false;
|
|
53
|
-
} else {
|
|
54
|
-
dataItem.valid = true;
|
|
55
|
-
dataItem.data = {
|
|
56
|
-
access_schedule: accessSchedule,
|
|
57
|
-
temporary_time_start: temporaryTimeStart.format(),
|
|
58
|
-
temporary_time_end: temporaryTimeEnd.format(),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
dataItem[dataItem.action.type] = dataItem.action.id[accessSchedule];
|
|
63
|
-
dataForm[index] = dataItem;
|
|
64
|
-
setDataForm([...dataForm]);
|
|
65
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
-
}, [
|
|
67
|
-
accessSchedule,
|
|
68
|
-
recurringTimeEnd,
|
|
69
|
-
recurringTimeRepeat,
|
|
70
|
-
recurringTimeStart,
|
|
71
|
-
temporaryTimeEnd,
|
|
72
|
-
temporaryTimeStart,
|
|
73
|
-
]);
|
|
74
|
-
const onShowSetDateTime = useCallback(
|
|
75
|
-
(currentValue, setter, mode) => {
|
|
76
|
-
releaseLockShowing();
|
|
77
|
-
setStateDateTimePicker((state) => ({
|
|
78
|
-
...state,
|
|
79
|
-
isVisible: true,
|
|
80
|
-
mode: mode,
|
|
81
|
-
defaultValue: currentValue,
|
|
82
|
-
setter: setter,
|
|
83
|
-
}));
|
|
84
|
-
},
|
|
85
|
-
[releaseLockShowing]
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const onHideSetDateTime = useCallback(() => {
|
|
89
|
-
acquireLockShowing();
|
|
90
|
-
setStateDateTimePicker((state) => ({
|
|
91
|
-
...state,
|
|
92
|
-
isVisible: false,
|
|
93
|
-
}));
|
|
94
|
-
}, [setStateDateTimePicker, acquireLockShowing]);
|
|
95
|
-
|
|
96
|
-
const onDateTimePicked = useCallback(
|
|
97
|
-
(timeData) => {
|
|
98
|
-
const setter = stateDateTimePicker.setter;
|
|
99
|
-
setter && setter(moment(timeData));
|
|
100
|
-
},
|
|
101
|
-
[stateDateTimePicker]
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const listAccessSchedule = useMemo(
|
|
105
|
-
() => [
|
|
106
|
-
{
|
|
107
|
-
text: t(`${ACCESS_SCHEDULE.ALWAYS}`),
|
|
108
|
-
value: ACCESS_SCHEDULE.ALWAYS,
|
|
109
|
-
detail: () => <></>,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
text: t(`${ACCESS_SCHEDULE.RECURRING}`),
|
|
113
|
-
value: ACCESS_SCHEDULE.RECURRING,
|
|
114
|
-
detail: () => (
|
|
115
|
-
<RecurringDetail
|
|
116
|
-
onShowSetDateTime={onShowSetDateTime}
|
|
117
|
-
recurringTimeStart={recurringTimeStart}
|
|
118
|
-
recurringTimeEnd={recurringTimeEnd}
|
|
119
|
-
recurringTimeRepeat={recurringTimeRepeat}
|
|
120
|
-
setRecurringTimeStart={setRecurringTimeStart}
|
|
121
|
-
setRecurringTimeEnd={setRecurringTimeEnd}
|
|
122
|
-
setRecurringTimeRepeat={setRecurringTimeRepeat}
|
|
123
|
-
/>
|
|
124
|
-
),
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
text: t(`${ACCESS_SCHEDULE.TEMPORARY}`),
|
|
128
|
-
value: ACCESS_SCHEDULE.TEMPORARY,
|
|
129
|
-
detail: () => (
|
|
130
|
-
<TemporaryDetail
|
|
131
|
-
onShowSetDateTime={onShowSetDateTime}
|
|
132
|
-
temporaryTimeStart={temporaryTimeStart}
|
|
133
|
-
temporaryTimeEnd={temporaryTimeEnd}
|
|
134
|
-
setTemporaryTimeStart={setTemporaryTimeStart}
|
|
135
|
-
setTemporaryTimeEnd={setTemporaryTimeEnd}
|
|
136
|
-
/>
|
|
137
|
-
),
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
-
[
|
|
142
|
-
onShowSetDateTime,
|
|
143
|
-
recurringTimeEnd,
|
|
144
|
-
recurringTimeRepeat,
|
|
145
|
-
recurringTimeStart,
|
|
146
|
-
temporaryTimeEnd,
|
|
147
|
-
temporaryTimeStart,
|
|
148
|
-
]
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<View style={styles.wrapper}>
|
|
153
|
-
<Text style={styles.textHeadLine}>{t('access_schedule')}</Text>
|
|
154
|
-
|
|
155
|
-
{listAccessSchedule.map((item, i) => (
|
|
156
|
-
<AccessScheduleItem
|
|
157
|
-
key={i}
|
|
158
|
-
item={item}
|
|
159
|
-
isSelected={item.value === accessSchedule}
|
|
160
|
-
onSelect={setAccessSchedule}
|
|
161
|
-
isSetupGeneratePasscode
|
|
162
|
-
/>
|
|
163
|
-
))}
|
|
164
|
-
<WheelDateTimePicker
|
|
165
|
-
mode={stateDateTimePicker.mode}
|
|
166
|
-
isVisible={stateDateTimePicker.isVisible && lockShowing}
|
|
167
|
-
defaultValue={stateDateTimePicker.defaultValue}
|
|
168
|
-
onPicked={onDateTimePicked}
|
|
169
|
-
onCancel={onHideSetDateTime}
|
|
170
|
-
onHide={releaseLockShowing}
|
|
171
|
-
/>
|
|
172
|
-
</View>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export default memo(ScheduleField);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { create } from 'react-test-renderer';
|
|
3
|
-
import { act } from 'react-test-renderer';
|
|
4
|
-
import PreventAccess from '..';
|
|
5
|
-
import { TESTID } from '../../../configs/Constants';
|
|
6
|
-
import { SCProvider } from '../../../context';
|
|
7
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
-
import Text from '../../Text';
|
|
9
|
-
|
|
10
|
-
const mockGoBack = jest.fn();
|
|
11
|
-
|
|
12
|
-
const wrapComponent = (headerBodyText, visible, hidePreventAccess) => (
|
|
13
|
-
<SCProvider initState={mockSCStore({})}>
|
|
14
|
-
<PreventAccess
|
|
15
|
-
headerBodyText={headerBodyText}
|
|
16
|
-
visible={visible}
|
|
17
|
-
hidePreventAccess={hidePreventAccess}
|
|
18
|
-
/>
|
|
19
|
-
</SCProvider>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
jest.mock('@react-navigation/native', () => {
|
|
23
|
-
return {
|
|
24
|
-
...jest.requireActual('@react-navigation/native'),
|
|
25
|
-
useRoute: jest.fn(),
|
|
26
|
-
useNavigation: () => ({
|
|
27
|
-
goBack: mockGoBack,
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('Test PreventAccess.test', () => {
|
|
33
|
-
let tree;
|
|
34
|
-
let headerBodyText;
|
|
35
|
-
let visible;
|
|
36
|
-
let hidePreventAccess = () => {};
|
|
37
|
-
|
|
38
|
-
test('onItemClick MenuActionList', () => {
|
|
39
|
-
act(() => {
|
|
40
|
-
tree = create(wrapComponent(headerBodyText, visible, hidePreventAccess));
|
|
41
|
-
});
|
|
42
|
-
const instance = tree.root;
|
|
43
|
-
const text = instance.findAllByType(Text);
|
|
44
|
-
expect(text).toHaveLength(5);
|
|
45
|
-
const button1 = instance.find(
|
|
46
|
-
(el) => el.props.testID === TESTID.BUTTON_PREVENT_ACCESS
|
|
47
|
-
);
|
|
48
|
-
const button2 = instance.find(
|
|
49
|
-
(el) => el.props.testID === TESTID.TEXT_PREVENT_ACCESS
|
|
50
|
-
);
|
|
51
|
-
act(() => {
|
|
52
|
-
button1.props.onBackButtonPress();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
act(() => {
|
|
56
|
-
button2.props.onPress();
|
|
57
|
-
});
|
|
58
|
-
expect(button1).toBeDefined();
|
|
59
|
-
expect(button2).toBeDefined();
|
|
60
|
-
expect(mockGoBack).toHaveBeenCalled();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useSCContextSelector } from '../../context';
|
|
2
|
-
|
|
3
|
-
const useGGHomeDeviceConnected = (device) => {
|
|
4
|
-
const connections = useSCContextSelector(
|
|
5
|
-
(state) => state.iot.googlehome.connections
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
const isConnected =
|
|
9
|
-
!!device?.chip_id &&
|
|
10
|
-
device.chip_id in connections &&
|
|
11
|
-
!!connections[device.chip_id];
|
|
12
|
-
|
|
13
|
-
return { isConnected };
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default useGGHomeDeviceConnected;
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import { createConnection, getStates } from 'home-assistant-js-websocket';
|
|
4
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
-
import api from '../../../utils/Apis/axios';
|
|
6
|
-
import { useGGHomeConnection } from '../index';
|
|
7
|
-
import { SCProvider } from '../../../context';
|
|
8
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
-
import { Action } from '../../../context/actionType';
|
|
10
|
-
import { API } from '../../../configs';
|
|
11
|
-
|
|
12
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
13
|
-
|
|
14
|
-
jest.mock('home-assistant-js-websocket', () => {
|
|
15
|
-
return {
|
|
16
|
-
Auth: jest.fn(),
|
|
17
|
-
createConnection: jest.fn(),
|
|
18
|
-
getStates: jest.fn(),
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
getStates.mockImplementation(() => []);
|
|
23
|
-
|
|
24
|
-
const connection = {
|
|
25
|
-
subscribeEvents: jest.fn(),
|
|
26
|
-
addEventListener: jest.fn(),
|
|
27
|
-
sendMessagePromise: jest.fn(),
|
|
28
|
-
close: jest.fn(),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const mockedSetAction = jest.fn();
|
|
32
|
-
|
|
33
|
-
const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
|
|
34
|
-
|
|
35
|
-
const mockUseContext = jest.fn().mockImplementation(() => ({
|
|
36
|
-
stateData: mockSCStore({}),
|
|
37
|
-
setAction: mockedSetAction,
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
React.useContext = mockUseContext;
|
|
41
|
-
|
|
42
|
-
describe('Test useGGHomeConnection', () => {
|
|
43
|
-
let options;
|
|
44
|
-
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
createConnection.mockClear();
|
|
47
|
-
mockedSetAction.mockClear();
|
|
48
|
-
options = [
|
|
49
|
-
{
|
|
50
|
-
auth: {},
|
|
51
|
-
chip_id: 1,
|
|
52
|
-
text_maps: {
|
|
53
|
-
here: 10,
|
|
54
|
-
},
|
|
55
|
-
config_maps: [
|
|
56
|
-
{
|
|
57
|
-
entity_id: 'group.sensor',
|
|
58
|
-
config_id: 1,
|
|
59
|
-
value_type: 'boolean',
|
|
60
|
-
attribute_maps: [
|
|
61
|
-
{
|
|
62
|
-
config_id: 2,
|
|
63
|
-
attribute_name: 'battery',
|
|
64
|
-
value_type: 'int',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
config_id: 3,
|
|
68
|
-
attribute_name: 'name',
|
|
69
|
-
value_type: 'text',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
config_id: 4,
|
|
73
|
-
attribute_name: 'height',
|
|
74
|
-
value_type: 'number',
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
auth: {},
|
|
82
|
-
chip_id: 2,
|
|
83
|
-
text_maps: {
|
|
84
|
-
here: 10,
|
|
85
|
-
},
|
|
86
|
-
config_maps: [
|
|
87
|
-
{
|
|
88
|
-
entity_id: 'group.sensor',
|
|
89
|
-
config_id: 1,
|
|
90
|
-
value_type: 'boolean',
|
|
91
|
-
attribute_maps: [
|
|
92
|
-
{
|
|
93
|
-
config_id: 2,
|
|
94
|
-
attribute_name: 'battery',
|
|
95
|
-
value_type: 'int',
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
config_id: 3,
|
|
99
|
-
attribute_name: 'name',
|
|
100
|
-
value_type: 'text',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
config_id: 4,
|
|
104
|
-
attribute_name: 'height',
|
|
105
|
-
value_type: 'number',
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
];
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('test connectGoogleHome all connected', async () => {
|
|
115
|
-
let conns = {};
|
|
116
|
-
options.forEach((option) => {
|
|
117
|
-
conns[option.chip_id] = connection;
|
|
118
|
-
createConnection.mockImplementationOnce(() => connection);
|
|
119
|
-
});
|
|
120
|
-
const { result } = renderHook(() => useGGHomeConnection(), {
|
|
121
|
-
wrapper,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
await act(async () => {
|
|
125
|
-
await result.current.connectGoogleHome(options);
|
|
126
|
-
});
|
|
127
|
-
expect(mockedSetAction).toBeCalledWith(
|
|
128
|
-
Action.SET_GOOGLE_HOME_CONNECTIONS,
|
|
129
|
-
conns
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('test connectGoogleHome have chip disconnected', async () => {
|
|
134
|
-
let conns = {};
|
|
135
|
-
conns[options[0].chip_id] = connection;
|
|
136
|
-
conns[options[1].chip_id] = 0;
|
|
137
|
-
createConnection.mockImplementationOnce(() => connection);
|
|
138
|
-
createConnection.mockImplementationOnce(async () => {
|
|
139
|
-
throw new Error();
|
|
140
|
-
});
|
|
141
|
-
const { result } = renderHook(() => useGGHomeConnection(), {
|
|
142
|
-
wrapper,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
await act(async () => {
|
|
146
|
-
await result.current.connectGoogleHome(options);
|
|
147
|
-
});
|
|
148
|
-
expect(mockedSetAction).toBeCalledWith(
|
|
149
|
-
Action.SET_GOOGLE_HOME_CONNECTIONS,
|
|
150
|
-
conns
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('test connectGooleHome all chip disconnected', async () => {
|
|
155
|
-
let conns = {};
|
|
156
|
-
options.forEach((option) => {
|
|
157
|
-
conns[option.chip_id] = 0;
|
|
158
|
-
createConnection.mockImplementationOnce(async () => {
|
|
159
|
-
throw new Error();
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
const { result } = renderHook(() => useGGHomeConnection(), {
|
|
163
|
-
wrapper,
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
mock.onPost(API.GOOGLE_HOME.CHECK_SEND_EMAIL()).reply(200);
|
|
167
|
-
await act(async () => {
|
|
168
|
-
await result.current.connectGoogleHome(options);
|
|
169
|
-
});
|
|
170
|
-
expect(mockedSetAction).toBeCalledTimes(2);
|
|
171
|
-
expect(mockedSetAction).toBeCalledWith(
|
|
172
|
-
Action.SET_GOOGLE_HOME_CONNECTIONS,
|
|
173
|
-
conns
|
|
174
|
-
);
|
|
175
|
-
expect(mockedSetAction).toBeCalledWith(Action.LIST_DEVICE_TYPES, {
|
|
176
|
-
chipId: options[0].chip_id,
|
|
177
|
-
sentEmail: true,
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('test disconnectGoogleHome', async () => {
|
|
182
|
-
let conns = {};
|
|
183
|
-
conns[options[0].chip_id] = connection;
|
|
184
|
-
conns[options[1].chip_id] = 0;
|
|
185
|
-
|
|
186
|
-
const { result } = renderHook(() => useGGHomeConnection(), {
|
|
187
|
-
wrapper,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
await act(async () => {
|
|
191
|
-
await result.current.disconnectGoogleHome(conns, options);
|
|
192
|
-
});
|
|
193
|
-
expect(mockedSetAction).toBeCalledWith(
|
|
194
|
-
Action.SET_GOOGLE_HOME_CONNECTIONS,
|
|
195
|
-
{}
|
|
196
|
-
);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import { useRemoteControl } from '../index';
|
|
4
|
-
import {
|
|
5
|
-
sendCommandOverBluetooth,
|
|
6
|
-
SEND_COMMAND_OVER_BLUETOOTH_FAIL,
|
|
7
|
-
} from '../../../iot/RemoteControl/Bluetooth';
|
|
8
|
-
import { sendCommandOverGoogleHome } from '../../../iot/RemoteControl/GoogleHome';
|
|
9
|
-
import { sendCommandOverInternet } from '../../../iot/RemoteControl/Internet';
|
|
10
|
-
import { sendCommandOverLGThinq } from '../../../iot/RemoteControl/LG';
|
|
11
|
-
import { SCProvider } from '../../../context';
|
|
12
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
13
|
-
|
|
14
|
-
jest.mock('../../../iot/RemoteControl/Bluetooth');
|
|
15
|
-
jest.mock('../../../iot/RemoteControl/GoogleHome');
|
|
16
|
-
jest.mock('../../../iot/RemoteControl/Internet');
|
|
17
|
-
jest.mock('../../../iot/RemoteControl/LG');
|
|
18
|
-
|
|
19
|
-
const mockedSetAction = jest.fn();
|
|
20
|
-
|
|
21
|
-
const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
|
|
22
|
-
|
|
23
|
-
const mockUseContext = jest.fn().mockImplementation(() => ({
|
|
24
|
-
stateData: mockSCStore({}),
|
|
25
|
-
setAction: mockedSetAction,
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
React.useContext = mockUseContext;
|
|
29
|
-
|
|
30
|
-
describe('Test useRemoteControl', () => {
|
|
31
|
-
let sensor, action, data, userId, actionName;
|
|
32
|
-
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
sendCommandOverBluetooth.mockClear();
|
|
35
|
-
sendCommandOverGoogleHome.mockClear();
|
|
36
|
-
sendCommandOverInternet.mockClear();
|
|
37
|
-
sendCommandOverLGThinq.mockClear();
|
|
38
|
-
|
|
39
|
-
sensor = {
|
|
40
|
-
id: 1,
|
|
41
|
-
};
|
|
42
|
-
action = {
|
|
43
|
-
color: '#00979D',
|
|
44
|
-
command_prefer_over_bluetooth: true,
|
|
45
|
-
command_prefer_over_googlehome: false,
|
|
46
|
-
command_prefer_over_internet: false,
|
|
47
|
-
googlehome_actions: [],
|
|
48
|
-
icon: 'caret-up',
|
|
49
|
-
id: 1,
|
|
50
|
-
key: '2b949045-8e03-4c07-a855-7794ade2e69c',
|
|
51
|
-
};
|
|
52
|
-
data = null;
|
|
53
|
-
userId = 1;
|
|
54
|
-
actionName = 'action name';
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('test send remote command action null', async () => {
|
|
58
|
-
action = null;
|
|
59
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
60
|
-
wrapper,
|
|
61
|
-
});
|
|
62
|
-
act(() => {
|
|
63
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
64
|
-
});
|
|
65
|
-
expect(sendCommandOverInternet).not.toBeCalled();
|
|
66
|
-
expect(sendCommandOverGoogleHome).not.toBeCalled();
|
|
67
|
-
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
68
|
-
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('test send remote command via bluetooth success', async () => {
|
|
72
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
73
|
-
wrapper,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
sendCommandOverBluetooth.mockImplementation(async () => true);
|
|
77
|
-
act(() => {
|
|
78
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
79
|
-
});
|
|
80
|
-
expect(sendCommandOverBluetooth).toBeCalledWith(
|
|
81
|
-
sensor,
|
|
82
|
-
action,
|
|
83
|
-
data,
|
|
84
|
-
userId
|
|
85
|
-
);
|
|
86
|
-
expect(sendCommandOverInternet).not.toBeCalled();
|
|
87
|
-
expect(sendCommandOverGoogleHome).not.toBeCalled();
|
|
88
|
-
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('test send remote command via bluetooth failed then send via internet', async () => {
|
|
92
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
93
|
-
wrapper,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
sendCommandOverBluetooth.mockImplementation(() => {
|
|
97
|
-
throw SEND_COMMAND_OVER_BLUETOOTH_FAIL;
|
|
98
|
-
});
|
|
99
|
-
sendCommandOverInternet.mockImplementation(async () => true);
|
|
100
|
-
act(() => {
|
|
101
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
102
|
-
});
|
|
103
|
-
expect(sendCommandOverBluetooth).toBeCalledWith(
|
|
104
|
-
sensor,
|
|
105
|
-
action,
|
|
106
|
-
data,
|
|
107
|
-
userId
|
|
108
|
-
);
|
|
109
|
-
expect(sendCommandOverInternet).toBeCalledWith(
|
|
110
|
-
sensor,
|
|
111
|
-
action,
|
|
112
|
-
data,
|
|
113
|
-
'bluetooth',
|
|
114
|
-
actionName
|
|
115
|
-
);
|
|
116
|
-
expect(sendCommandOverGoogleHome).not.toBeCalled();
|
|
117
|
-
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('test send remote command via bluetooth failed throw unhandled error', async () => {
|
|
121
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
122
|
-
wrapper,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
sendCommandOverBluetooth.mockImplementation(() => {
|
|
126
|
-
throw 'ANOTHER_ERROR';
|
|
127
|
-
});
|
|
128
|
-
sendCommandOverInternet.mockImplementation(async () => true);
|
|
129
|
-
act(() => {
|
|
130
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
131
|
-
});
|
|
132
|
-
expect(sendCommandOverBluetooth).toBeCalledWith(
|
|
133
|
-
sensor,
|
|
134
|
-
action,
|
|
135
|
-
data,
|
|
136
|
-
userId
|
|
137
|
-
);
|
|
138
|
-
expect(sendCommandOverInternet).not.toBeCalled();
|
|
139
|
-
expect(sendCommandOverGoogleHome).not.toBeCalled();
|
|
140
|
-
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('test send remote command via internet', async () => {
|
|
144
|
-
action.command_prefer_over_bluetooth = false;
|
|
145
|
-
action.command_prefer_over_internet = true;
|
|
146
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
147
|
-
wrapper,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
sendCommandOverInternet.mockImplementation(async () => true);
|
|
151
|
-
act(() => {
|
|
152
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
153
|
-
});
|
|
154
|
-
expect(sendCommandOverInternet).toBeCalledWith(
|
|
155
|
-
sensor,
|
|
156
|
-
action,
|
|
157
|
-
data,
|
|
158
|
-
'internet'
|
|
159
|
-
);
|
|
160
|
-
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
161
|
-
expect(sendCommandOverGoogleHome).not.toBeCalled();
|
|
162
|
-
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('test send remote command via googlehome', async () => {
|
|
166
|
-
action.command_prefer_over_bluetooth = false;
|
|
167
|
-
action.command_prefer_over_googlehome = true;
|
|
168
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
169
|
-
wrapper,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
sendCommandOverGoogleHome.mockImplementation(async () => true);
|
|
173
|
-
act(() => {
|
|
174
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
175
|
-
});
|
|
176
|
-
expect(sendCommandOverGoogleHome).toBeCalledWith({}, sensor, action, data);
|
|
177
|
-
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
178
|
-
expect(sendCommandOverInternet).not.toBeCalled();
|
|
179
|
-
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('test send remote command via lg', async () => {
|
|
183
|
-
action.command_prefer_over_bluetooth = false;
|
|
184
|
-
action.command_prefer_over_lg = true;
|
|
185
|
-
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
186
|
-
wrapper,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
sendCommandOverLGThinq.mockImplementation(async () => true);
|
|
190
|
-
act(() => {
|
|
191
|
-
sendRemoteCommand.current(sensor, action, data, userId, actionName);
|
|
192
|
-
});
|
|
193
|
-
expect(sendCommandOverLGThinq).toBeCalledWith(sensor, action, data);
|
|
194
|
-
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
195
|
-
expect(sendCommandOverGoogleHome).not.toBeCalled();
|
|
196
|
-
expect(sendCommandOverInternet).not.toBeCalled();
|
|
197
|
-
});
|
|
198
|
-
});
|
package/src/hooks/IoT/index.js
DELETED