@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,118 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import { TESTID } from '../../../../configs/Constants';
|
|
5
|
-
import { mockSCStore } from '../../../../context/mockStore';
|
|
6
|
-
import { SCProvider } from '../../../../context';
|
|
7
|
-
import ChooseUserField from '../index';
|
|
8
|
-
import { TouchableOpacity } from 'react-native';
|
|
9
|
-
import { ModalCustom } from '../../../Modal';
|
|
10
|
-
import api from '../../../../utils/Apis/axios';
|
|
11
|
-
import { API } from '../../../../configs';
|
|
12
|
-
|
|
13
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
14
|
-
|
|
15
|
-
const wrapComponent = (
|
|
16
|
-
unit = { id: 1 },
|
|
17
|
-
dataItem = {
|
|
18
|
-
type: 'choose_user',
|
|
19
|
-
key: 'user_id',
|
|
20
|
-
action: {
|
|
21
|
-
type: 'action_zigbee',
|
|
22
|
-
id: 1,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
index = 0,
|
|
26
|
-
setDataForm,
|
|
27
|
-
dataForm = [
|
|
28
|
-
{
|
|
29
|
-
type: 'choose_user',
|
|
30
|
-
key: 'user_id',
|
|
31
|
-
action: {
|
|
32
|
-
type: 'action_zigbee',
|
|
33
|
-
id: 1,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
]
|
|
37
|
-
) => (
|
|
38
|
-
<SCProvider initState={mockSCStore({})}>
|
|
39
|
-
<ChooseUserField
|
|
40
|
-
unit={unit}
|
|
41
|
-
dataItem={dataItem}
|
|
42
|
-
index={index}
|
|
43
|
-
setDataForm={jest.fn()}
|
|
44
|
-
dataForm={dataForm}
|
|
45
|
-
/>
|
|
46
|
-
</SCProvider>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
describe('Test ChooseUserField', () => {
|
|
50
|
-
let tree;
|
|
51
|
-
|
|
52
|
-
const onPressCancel = async (instance, popup) => {
|
|
53
|
-
const buttonCancel = instance.find(
|
|
54
|
-
(el) =>
|
|
55
|
-
el.props.testID ===
|
|
56
|
-
TESTID.CHOOSE_POPUP + TESTID.BOTTOM_VIEW_SECONDARY &&
|
|
57
|
-
el.type === TouchableOpacity
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
await act(async () => {
|
|
61
|
-
await buttonCancel.props.onPress();
|
|
62
|
-
});
|
|
63
|
-
expect(popup.props.isVisible).toBeFalsy();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const onPressApply = async (instance, popup) => {
|
|
67
|
-
const buttonApply = instance.find(
|
|
68
|
-
(el) =>
|
|
69
|
-
el.props.testID === TESTID.CHOOSE_POPUP + TESTID.BOTTOM_VIEW_MAIN &&
|
|
70
|
-
el.type === TouchableOpacity
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
await act(async () => {
|
|
74
|
-
await buttonApply.props.onPress();
|
|
75
|
-
});
|
|
76
|
-
expect(popup.props.isVisible).toBeFalsy();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
test('render ChooseUserField handleOnApply', async () => {
|
|
80
|
-
mock.onGet(API.SHARE.UNITS_MEMBERS(1)).reply(200, [{ id: 1, name: 'Ken' }]);
|
|
81
|
-
await act(async () => {
|
|
82
|
-
tree = create(wrapComponent());
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const instance = tree.root;
|
|
86
|
-
|
|
87
|
-
const ChooseField = instance.find(
|
|
88
|
-
(item) =>
|
|
89
|
-
item.props.testID === TESTID.CHOOSE_FIELD &&
|
|
90
|
-
item.type === TouchableOpacity
|
|
91
|
-
);
|
|
92
|
-
await act(async () => {
|
|
93
|
-
await ChooseField.props.onPress();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const popup = instance.find(
|
|
97
|
-
(item) =>
|
|
98
|
-
item.props.testID === TESTID.CHOOSE_POPUP && item.type === ModalCustom
|
|
99
|
-
);
|
|
100
|
-
expect(popup.props.isVisible).toBeTruthy();
|
|
101
|
-
await onPressCancel(instance, popup);
|
|
102
|
-
await onPressApply(instance, popup);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test('fetch unit_members error', async () => {
|
|
106
|
-
mock.onGet(API.SHARE.UNITS_MEMBERS(1)).reply(new Error('Network Error'));
|
|
107
|
-
await act(async () => {
|
|
108
|
-
tree = create(wrapComponent());
|
|
109
|
-
});
|
|
110
|
-
const instance = tree.root;
|
|
111
|
-
const ChooseField = instance.findAll(
|
|
112
|
-
(item) =>
|
|
113
|
-
item.props.testID === TESTID.CHOOSE_ITEM &&
|
|
114
|
-
item.type === TouchableOpacity
|
|
115
|
-
);
|
|
116
|
-
expect(ChooseField).toHaveLength(0);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { memo, useEffect, useState } from 'react';
|
|
2
|
-
import { IconOutline } from '@ant-design/icons-react-native';
|
|
3
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import styles from './ChooseFieldStyles';
|
|
6
|
-
import ChoosePopup from './ChoosePopup';
|
|
7
|
-
import { useBoolean } from '../../../hooks/Common';
|
|
8
|
-
import { axiosGet } from '../../../utils/Apis/axios';
|
|
9
|
-
import { API, Colors } from '../../../configs';
|
|
10
|
-
import { TESTID } from '../../../configs/Constants';
|
|
11
|
-
import Text from '../../Text';
|
|
12
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
13
|
-
|
|
14
|
-
const ChooseUserField = ({ unit, dataItem, index, setDataForm, dataForm }) => {
|
|
15
|
-
const [showFilterPopup, setShowFilterPopup, setHideFilterPopup] =
|
|
16
|
-
useBoolean();
|
|
17
|
-
const [choose, setChoose] = useState({});
|
|
18
|
-
const [members, setMembers] = useState([]);
|
|
19
|
-
const t = useTranslations();
|
|
20
|
-
const fetchMembers = async () => {
|
|
21
|
-
const { success, data } = await axiosGet(API.SHARE.UNITS_MEMBERS(unit.id));
|
|
22
|
-
if (success) {
|
|
23
|
-
setMembers(data);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!members.length) {
|
|
29
|
-
fetchMembers();
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
dataItem.data = choose.id;
|
|
34
|
-
dataItem.valid = true;
|
|
35
|
-
dataItem[dataItem.action.type] = dataItem.action.id;
|
|
36
|
-
dataForm[index] = dataItem;
|
|
37
|
-
setDataForm([...dataForm]);
|
|
38
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
-
}, [choose]);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<View style={styles.wrapper}>
|
|
43
|
-
<Text style={styles.textHeadLine}>{t('choose_user')}</Text>
|
|
44
|
-
<TouchableOpacity
|
|
45
|
-
testID={TESTID.CHOOSE_FIELD}
|
|
46
|
-
style={styles.buttonValue}
|
|
47
|
-
onPress={setShowFilterPopup}
|
|
48
|
-
>
|
|
49
|
-
<Text style={styles.value}>{choose.name}</Text>
|
|
50
|
-
<IconOutline name="right" size={20} color={Colors.Gray8} />
|
|
51
|
-
</TouchableOpacity>
|
|
52
|
-
<ChoosePopup
|
|
53
|
-
isVisible={showFilterPopup}
|
|
54
|
-
onHide={setHideFilterPopup}
|
|
55
|
-
members={members}
|
|
56
|
-
title={t('choose_user')}
|
|
57
|
-
onApply={setChoose}
|
|
58
|
-
/>
|
|
59
|
-
</View>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
export default memo(ChooseUserField);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../../configs';
|
|
3
|
-
|
|
4
|
-
export default StyleSheet.create({
|
|
5
|
-
wrapper: {
|
|
6
|
-
flexDirection: 'row',
|
|
7
|
-
justifyContent: 'space-between',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
paddingTop: 30,
|
|
10
|
-
},
|
|
11
|
-
invalid: {
|
|
12
|
-
width: 90,
|
|
13
|
-
textAlign: 'center',
|
|
14
|
-
borderWidth: 0,
|
|
15
|
-
borderBottomWidth: 1,
|
|
16
|
-
borderBottomColor: Colors.Red,
|
|
17
|
-
},
|
|
18
|
-
valid: {
|
|
19
|
-
width: 90,
|
|
20
|
-
textAlign: 'center',
|
|
21
|
-
borderWidth: 0,
|
|
22
|
-
borderBottomWidth: 1,
|
|
23
|
-
borderBottomColor: Colors.Primary,
|
|
24
|
-
},
|
|
25
|
-
textHeadLine: {
|
|
26
|
-
fontSize: 16,
|
|
27
|
-
color: Colors.Gray9,
|
|
28
|
-
fontWeight: 'bold',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import { TESTID } from '../../../../configs/Constants';
|
|
4
|
-
import { mockSCStore } from '../../../../context/mockStore';
|
|
5
|
-
import { SCProvider } from '../../../../context';
|
|
6
|
-
import PasscodeField from '../index';
|
|
7
|
-
|
|
8
|
-
const mockSetState = jest.fn();
|
|
9
|
-
|
|
10
|
-
const wrapComponent = (
|
|
11
|
-
dataItem = {
|
|
12
|
-
type: 'passcode',
|
|
13
|
-
key: 'passcode',
|
|
14
|
-
action: {
|
|
15
|
-
type: 'action_zigbee',
|
|
16
|
-
id: 1,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
index = 0,
|
|
20
|
-
dataForm = [
|
|
21
|
-
{
|
|
22
|
-
type: 'passcode',
|
|
23
|
-
key: 'passcode',
|
|
24
|
-
action: {
|
|
25
|
-
type: 'action_zigbee',
|
|
26
|
-
id: 1,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
]
|
|
30
|
-
) => (
|
|
31
|
-
<SCProvider initState={mockSCStore({})}>
|
|
32
|
-
<PasscodeField
|
|
33
|
-
dataItem={dataItem}
|
|
34
|
-
index={index}
|
|
35
|
-
setDataForm={mockSetState}
|
|
36
|
-
dataForm={dataForm}
|
|
37
|
-
/>
|
|
38
|
-
</SCProvider>
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
describe('Test PasscodeField', () => {
|
|
42
|
-
let tree;
|
|
43
|
-
|
|
44
|
-
afterEach(() => {
|
|
45
|
-
mockSetState.mockClear();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('render PasscodeField', async () => {
|
|
49
|
-
await act(async () => {
|
|
50
|
-
tree = create(wrapComponent());
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const instance = tree.root;
|
|
54
|
-
const inputPasscode = instance.find(
|
|
55
|
-
(item) => item.props.testID === TESTID.PASSCODE_FIELD
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
await act(async () => {
|
|
59
|
-
await inputPasscode.props.onChangeText('123');
|
|
60
|
-
});
|
|
61
|
-
expect(mockSetState).toBeCalledWith([
|
|
62
|
-
{
|
|
63
|
-
key: 'passcode',
|
|
64
|
-
type: 'passcode',
|
|
65
|
-
valid: false,
|
|
66
|
-
action: {
|
|
67
|
-
id: 1,
|
|
68
|
-
type: 'action_zigbee',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
await act(async () => {
|
|
74
|
-
await inputPasscode.props.onChangeText('123456');
|
|
75
|
-
});
|
|
76
|
-
expect(mockSetState).toBeCalledWith([
|
|
77
|
-
{
|
|
78
|
-
key: 'passcode',
|
|
79
|
-
type: 'passcode',
|
|
80
|
-
data: '123456',
|
|
81
|
-
valid: true,
|
|
82
|
-
action: {
|
|
83
|
-
id: 1,
|
|
84
|
-
type: 'action_zigbee',
|
|
85
|
-
},
|
|
86
|
-
action_zigbee: 1,
|
|
87
|
-
},
|
|
88
|
-
]);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useState } from 'react';
|
|
2
|
-
import { Text, TextInput, View } from 'react-native';
|
|
3
|
-
import { TESTID } from '../../../configs/Constants';
|
|
4
|
-
|
|
5
|
-
import styles from './PasscodeFieldStyles';
|
|
6
|
-
|
|
7
|
-
const PasscodeField = ({ dataItem, index, setDataForm, dataForm }) => {
|
|
8
|
-
const [invalid, setInvaild] = useState(false);
|
|
9
|
-
const onChangeText = useCallback(
|
|
10
|
-
(value) => {
|
|
11
|
-
if (value.length >= 4 && value.length <= 10) {
|
|
12
|
-
dataItem.data = value;
|
|
13
|
-
dataItem.valid = true;
|
|
14
|
-
dataItem[dataItem.action.type] = dataItem.action.id;
|
|
15
|
-
dataForm[index] = dataItem;
|
|
16
|
-
setInvaild(false);
|
|
17
|
-
setDataForm([...dataForm]);
|
|
18
|
-
} else {
|
|
19
|
-
dataItem.valid = false;
|
|
20
|
-
dataForm[index] = dataItem;
|
|
21
|
-
setInvaild(true);
|
|
22
|
-
setDataForm([...dataForm]);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
-
[]
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<View style={styles.wrapper}>
|
|
31
|
-
<Text style={styles.textHeadLine}>{'Passcode'}</Text>
|
|
32
|
-
<TextInput
|
|
33
|
-
testID={TESTID.PASSCODE_FIELD}
|
|
34
|
-
style={invalid ? styles.invalid : styles.valid}
|
|
35
|
-
placeholder={'******'}
|
|
36
|
-
keyboardType={'numeric'}
|
|
37
|
-
maxLength={10}
|
|
38
|
-
onChangeText={onChangeText}
|
|
39
|
-
/>
|
|
40
|
-
</View>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
export default memo(PasscodeField);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../../configs';
|
|
3
|
-
|
|
4
|
-
export default StyleSheet.create({
|
|
5
|
-
wrapper: {
|
|
6
|
-
paddingTop: 30,
|
|
7
|
-
},
|
|
8
|
-
textHeadLine: {
|
|
9
|
-
fontSize: 16,
|
|
10
|
-
color: Colors.Gray9,
|
|
11
|
-
fontWeight: 'bold',
|
|
12
|
-
},
|
|
13
|
-
});
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import { mockSCStore } from '../../../../context/mockStore';
|
|
4
|
-
import { SCProvider } from '../../../../context';
|
|
5
|
-
import ScheduleField from '../index';
|
|
6
|
-
import { TESTID } from '../../../../configs/Constants';
|
|
7
|
-
import { TouchableOpacity } from 'react-native';
|
|
8
|
-
|
|
9
|
-
const mockSetState = jest.fn();
|
|
10
|
-
|
|
11
|
-
const wrapComponent = (
|
|
12
|
-
dataItem = {
|
|
13
|
-
type: 'schedule',
|
|
14
|
-
key: 'schedule',
|
|
15
|
-
action: {
|
|
16
|
-
type: 'action_zigbee',
|
|
17
|
-
id: {
|
|
18
|
-
always: 2,
|
|
19
|
-
recurring: 4,
|
|
20
|
-
temporary: 5,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
index = 0,
|
|
25
|
-
dataForm = [
|
|
26
|
-
{
|
|
27
|
-
type: 'schedule',
|
|
28
|
-
key: 'schedule',
|
|
29
|
-
action: {
|
|
30
|
-
type: 'action_zigbee',
|
|
31
|
-
id: {
|
|
32
|
-
always: 2,
|
|
33
|
-
recurring: 4,
|
|
34
|
-
temporary: 5,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
]
|
|
39
|
-
) => (
|
|
40
|
-
<SCProvider initState={mockSCStore({})}>
|
|
41
|
-
<ScheduleField
|
|
42
|
-
dataItem={dataItem}
|
|
43
|
-
index={index}
|
|
44
|
-
setDataForm={mockSetState}
|
|
45
|
-
dataForm={dataForm}
|
|
46
|
-
/>
|
|
47
|
-
</SCProvider>
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
describe('Test ScheduleField', () => {
|
|
51
|
-
let tree;
|
|
52
|
-
beforeEach(() => {
|
|
53
|
-
Date.now = jest.fn(() => new Date('2022-05-30T15:50:36+01:00'));
|
|
54
|
-
});
|
|
55
|
-
afterEach(() => {
|
|
56
|
-
mockSetState.mockClear();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const onPressRecurring = async (instance, schedule) => {
|
|
60
|
-
await act(async () => {
|
|
61
|
-
await schedule.props.onPress();
|
|
62
|
-
});
|
|
63
|
-
const recurring = instance.find(
|
|
64
|
-
(el) =>
|
|
65
|
-
el.props.testID === '0' + TESTID.RECURRING_REPEAT_ITEM &&
|
|
66
|
-
el.type === TouchableOpacity
|
|
67
|
-
);
|
|
68
|
-
await act(async () => {
|
|
69
|
-
await recurring.props.onPress();
|
|
70
|
-
});
|
|
71
|
-
expect(mockSetState).toBeCalledWith([
|
|
72
|
-
{
|
|
73
|
-
key: 'schedule',
|
|
74
|
-
type: 'schedule',
|
|
75
|
-
data: {
|
|
76
|
-
access_schedule: 'recurring',
|
|
77
|
-
recurring_time_end: '2022-05-30T16:50:36+01:00',
|
|
78
|
-
recurring_time_repeat: ['6'],
|
|
79
|
-
recurring_time_start: '2022-05-30T15:50:36+01:00',
|
|
80
|
-
},
|
|
81
|
-
valid: true,
|
|
82
|
-
action: {
|
|
83
|
-
id: {
|
|
84
|
-
always: 2,
|
|
85
|
-
recurring: 4,
|
|
86
|
-
temporary: 5,
|
|
87
|
-
},
|
|
88
|
-
type: 'action_zigbee',
|
|
89
|
-
},
|
|
90
|
-
action_zigbee: 4,
|
|
91
|
-
},
|
|
92
|
-
]);
|
|
93
|
-
mockSetState.mockClear();
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const onPressTemporary = async (instance, schedule) => {
|
|
97
|
-
await act(async () => {
|
|
98
|
-
await schedule.props.onPress();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
expect(mockSetState).toBeCalledWith([
|
|
102
|
-
{
|
|
103
|
-
key: 'schedule',
|
|
104
|
-
type: 'schedule',
|
|
105
|
-
data: {
|
|
106
|
-
access_schedule: 'temporary',
|
|
107
|
-
temporary_time_end: '2022-05-31T15:50:36+01:00',
|
|
108
|
-
temporary_time_start: '2022-05-30T15:50:36+01:00',
|
|
109
|
-
},
|
|
110
|
-
valid: true,
|
|
111
|
-
action: {
|
|
112
|
-
id: {
|
|
113
|
-
always: 2,
|
|
114
|
-
recurring: 4,
|
|
115
|
-
temporary: 5,
|
|
116
|
-
},
|
|
117
|
-
type: 'action_zigbee',
|
|
118
|
-
},
|
|
119
|
-
action_zigbee: 5,
|
|
120
|
-
},
|
|
121
|
-
]);
|
|
122
|
-
const temporaryEnd = instance.find(
|
|
123
|
-
(el) =>
|
|
124
|
-
el.props.testID === TESTID.TEMPORARY_END_TEXT_BUTTON &&
|
|
125
|
-
el.type === TouchableOpacity
|
|
126
|
-
);
|
|
127
|
-
await act(async () => {
|
|
128
|
-
await temporaryEnd.props.onPress();
|
|
129
|
-
});
|
|
130
|
-
const dateTimePicker = instance.find(
|
|
131
|
-
(el) => el.props.testID === TESTID.WHEEL_DATE_TIME_PICKER
|
|
132
|
-
);
|
|
133
|
-
expect(dateTimePicker.props.isVisible).toBeTruthy();
|
|
134
|
-
const popupDateTimePickerDone = instance.find(
|
|
135
|
-
(el) =>
|
|
136
|
-
el.props.testID ===
|
|
137
|
-
`${TESTID.WHEEL_DATE_TIME_PICKER_BUTTON}${TESTID.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}` &&
|
|
138
|
-
el.type === TouchableOpacity
|
|
139
|
-
);
|
|
140
|
-
await act(async () => {
|
|
141
|
-
await popupDateTimePickerDone.props.onPress();
|
|
142
|
-
});
|
|
143
|
-
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
144
|
-
mockSetState.mockClear();
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
test('render ScheduleField choose schedule', async () => {
|
|
148
|
-
await act(async () => {
|
|
149
|
-
tree = await create(wrapComponent());
|
|
150
|
-
});
|
|
151
|
-
expect(mockSetState).toBeCalledWith([
|
|
152
|
-
{
|
|
153
|
-
key: 'schedule',
|
|
154
|
-
type: 'schedule',
|
|
155
|
-
data: { access_schedule: 'always' },
|
|
156
|
-
valid: true,
|
|
157
|
-
action: {
|
|
158
|
-
id: {
|
|
159
|
-
always: 2,
|
|
160
|
-
recurring: 4,
|
|
161
|
-
temporary: 5,
|
|
162
|
-
},
|
|
163
|
-
type: 'action_zigbee',
|
|
164
|
-
},
|
|
165
|
-
action_zigbee: 2,
|
|
166
|
-
},
|
|
167
|
-
]);
|
|
168
|
-
mockSetState.mockClear();
|
|
169
|
-
const instance = tree.root;
|
|
170
|
-
const schedule = instance.findAll(
|
|
171
|
-
(el) =>
|
|
172
|
-
el.props.testID === TESTID.ACCESS_SCHEDULE_RADIO_BUTTON &&
|
|
173
|
-
el.type === TouchableOpacity
|
|
174
|
-
);
|
|
175
|
-
expect(schedule).toHaveLength(3);
|
|
176
|
-
await onPressRecurring(instance, schedule[1]);
|
|
177
|
-
await onPressTemporary(instance, schedule[2]);
|
|
178
|
-
});
|
|
179
|
-
});
|