@eohjsc/react-native-smart-city 0.3.8 → 0.3.9
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 +36 -15
- package/package.json +10 -6
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +16 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
- package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +135 -0
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +76 -26
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +7 -3
- package/src/commons/Device/ItemDevice.js +34 -13
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
- package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
- package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/Form/CurrencyInput.js +15 -1
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HeaderAni/index.js +6 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +26 -47
- package/src/commons/MenuActionAddnew/index.js +1 -0
- package/src/commons/MenuActionList/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
- package/src/commons/PreventAccess/index.js +9 -1
- package/src/commons/Sharing/MemberList.js +10 -2
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +4 -3
- package/src/configs/API.js +87 -143
- package/src/configs/Constants.js +61 -1
- package/src/configs/SCConfig.js +4 -0
- package/src/context/actionType.ts +10 -0
- package/src/context/mockStore.ts +11 -0
- package/src/context/reducer.ts +51 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +93 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +11 -20
- package/src/navigations/UnitStackStyles.js +21 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -0
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/index.js +9 -5
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- 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 +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +3 -2
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +5 -3
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/EditDevice/index.js +17 -15
- package/src/screens/Device/__test__/detail.test.js +33 -86
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +85 -26
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/Explore/index.js +2 -0
- package/src/screens/GuestInfo/__test__/index.test.js +14 -41
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- 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 +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- 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 +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +2 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +54 -35
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +19 -14
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +9 -4
- package/src/screens/SetSchedule/index.js +15 -11
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +121 -76
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/Sharing/hooks/index.js +3 -0
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
- package/src/screens/SideMenuDetail/index.js +148 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +23 -17
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/EditSubUnit.js +15 -13
- package/src/screens/SubUnit/ManageSubUnit.js +13 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +31 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +45 -23
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +4 -0
- package/src/screens/Unit/Summaries.js +18 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +98 -199
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +159 -49
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +91 -30
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +54 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +7 -1
- package/src/utils/I18n/translations/vi.json +8 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Setting/Location.js +30 -0
- package/src/utils/Utils.js +11 -7
- package/src/utils/__test__/Utils.test.js +12 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Switch } from 'react-native';
|
|
2
|
+
import { Switch, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import TimerActionTemplate from '../TimerActionTemplate';
|
|
5
5
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
6
|
+
import ScrollPicker from 'react-native-wheel-scrollview-picker';
|
|
7
|
+
|
|
6
8
|
import moment from 'moment';
|
|
7
9
|
import Text from '../../Text';
|
|
8
10
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
@@ -15,12 +17,14 @@ jest.mock('../../../iot/states', () => ({
|
|
|
15
17
|
useConfigGlobalState: () => [{ 5: 18, 6: 30 }, null],
|
|
16
18
|
}));
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const mockDoAction = jest.fn();
|
|
21
|
+
|
|
22
|
+
const wrapComponent = (actionGroup, sensor) => (
|
|
19
23
|
<SCProvider initState={mockSCStore({})}>
|
|
20
24
|
<TimerActionTemplate
|
|
21
25
|
actionGroup={actionGroup}
|
|
22
26
|
doAction={mockDoAction}
|
|
23
|
-
sensor={
|
|
27
|
+
sensor={sensor}
|
|
24
28
|
/>
|
|
25
29
|
</SCProvider>
|
|
26
30
|
);
|
|
@@ -39,6 +43,7 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
39
43
|
|
|
40
44
|
let actionGroup;
|
|
41
45
|
let wrapper;
|
|
46
|
+
let sensor;
|
|
42
47
|
|
|
43
48
|
beforeEach(() => {
|
|
44
49
|
watchMultiConfigs.mockClear();
|
|
@@ -50,12 +55,24 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
50
55
|
config_minute: 6,
|
|
51
56
|
},
|
|
52
57
|
};
|
|
58
|
+
sensor = {
|
|
59
|
+
is_managed_by_backend: true,
|
|
60
|
+
device_type: '',
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('render without params', async () => {
|
|
65
|
+
await act(async () => {
|
|
66
|
+
wrapper = await create(wrapComponent());
|
|
67
|
+
});
|
|
68
|
+
const instance = wrapper.root;
|
|
69
|
+
const texts = instance.findAllByType(Text);
|
|
70
|
+
expect(texts).toHaveLength(6);
|
|
53
71
|
});
|
|
54
72
|
|
|
55
73
|
test('render template', async () => {
|
|
56
|
-
const mockDoAction = jest.fn();
|
|
57
74
|
await act(async () => {
|
|
58
|
-
wrapper = await create(wrapComponent(actionGroup,
|
|
75
|
+
wrapper = await create(wrapComponent(actionGroup, sensor));
|
|
59
76
|
});
|
|
60
77
|
const instance = wrapper.root;
|
|
61
78
|
|
|
@@ -66,11 +83,46 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
66
83
|
|
|
67
84
|
const switchButton = instance.findByType(Switch);
|
|
68
85
|
expect(switchButton.props.value).toBeTruthy();
|
|
86
|
+
await switchButton.props.onValueChange();
|
|
87
|
+
expect(mockDoAction).toBeCalled();
|
|
88
|
+
|
|
89
|
+
const bottomScrollPicker = instance.findByType(ScrollPicker);
|
|
90
|
+
expect(bottomScrollPicker).toBeDefined();
|
|
91
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
92
|
+
await TouchableOpacities[0].props.onPress();
|
|
69
93
|
|
|
70
94
|
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
71
|
-
expect(dateTimePicker.props.isVisible).
|
|
95
|
+
expect(dateTimePicker.props.isVisible).toBeTruthy();
|
|
72
96
|
expect(dateTimePicker.props.date).toEqual(
|
|
73
97
|
moment('18:30', 'HH:mm').valueOf()
|
|
74
98
|
);
|
|
75
99
|
});
|
|
100
|
+
|
|
101
|
+
test('render template with config_hour', async () => {
|
|
102
|
+
actionGroup = {
|
|
103
|
+
...actionGroup,
|
|
104
|
+
configuration: {
|
|
105
|
+
...actionGroup.configuration,
|
|
106
|
+
config_hour: 5,
|
|
107
|
+
config_minute: null,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
await act(async () => {
|
|
111
|
+
wrapper = await create(wrapComponent(actionGroup, sensor));
|
|
112
|
+
});
|
|
113
|
+
const instance = wrapper.root;
|
|
114
|
+
|
|
115
|
+
const bottomScrollPicker = instance.findByType(ScrollPicker);
|
|
116
|
+
expect(bottomScrollPicker).toBeDefined();
|
|
117
|
+
|
|
118
|
+
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
119
|
+
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
120
|
+
await dateTimePicker.props.onConfirm();
|
|
121
|
+
|
|
122
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
123
|
+
expect(TouchableOpacities).toHaveLength(3);
|
|
124
|
+
await TouchableOpacities[0].props.onPress();
|
|
125
|
+
await TouchableOpacities[2].props.onPress(3);
|
|
126
|
+
expect(mockDoAction).toBeCalled();
|
|
127
|
+
});
|
|
76
128
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
4
5
|
import TwoButtonTemplate from '../TwoButtonTemplate';
|
|
5
6
|
|
|
6
7
|
jest.mock('react', () => ({
|
|
@@ -31,6 +32,10 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
31
32
|
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
32
33
|
};
|
|
33
34
|
|
|
35
|
+
const sensor = {
|
|
36
|
+
device_type: DEVICE_TYPE.LG_THINQ,
|
|
37
|
+
is_managed_by_backend: true,
|
|
38
|
+
};
|
|
34
39
|
const actionGroup = {
|
|
35
40
|
configuration: {
|
|
36
41
|
button1: {
|
|
@@ -41,6 +46,9 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
41
46
|
icon_on: 'poweroff',
|
|
42
47
|
text_on: 'ON',
|
|
43
48
|
config: 621,
|
|
49
|
+
is_on_value: [true],
|
|
50
|
+
action_on_data,
|
|
51
|
+
action_off_data,
|
|
44
52
|
},
|
|
45
53
|
button2: {
|
|
46
54
|
action_off: 'f49e1577-493d-4bae-a9ab-3b0f96a4ec52',
|
|
@@ -50,6 +58,9 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
50
58
|
icon_on: 'caret-right',
|
|
51
59
|
text_on: 'START',
|
|
52
60
|
config: 621,
|
|
61
|
+
is_on_value: [true],
|
|
62
|
+
action_on_data,
|
|
63
|
+
action_off_data,
|
|
53
64
|
},
|
|
54
65
|
},
|
|
55
66
|
};
|
|
@@ -102,7 +113,44 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
102
113
|
const mockDoAction = jest.fn();
|
|
103
114
|
await act(() => {
|
|
104
115
|
wrapper = create(
|
|
105
|
-
<TwoButtonTemplate
|
|
116
|
+
<TwoButtonTemplate
|
|
117
|
+
actionGroup={actionGroup}
|
|
118
|
+
doAction={mockDoAction}
|
|
119
|
+
sensor={sensor}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
const instance = wrapper.root;
|
|
124
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
125
|
+
expect(touchableOpacities.length).toEqual(2);
|
|
126
|
+
await touchableOpacities[0].props.onPress();
|
|
127
|
+
await touchableOpacities[1].props.onPress();
|
|
128
|
+
expect(mockDoAction).toBeCalled();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('render TouchableOpacity TwoButtonTemplate without is_on_value', async () => {
|
|
132
|
+
const mockDoAction = jest.fn();
|
|
133
|
+
let new_actionGroup = {
|
|
134
|
+
...actionGroup,
|
|
135
|
+
configuration: {
|
|
136
|
+
...actionGroup.configuration,
|
|
137
|
+
button1: {
|
|
138
|
+
...actionGroup.configuration.button1,
|
|
139
|
+
is_on_value: null,
|
|
140
|
+
},
|
|
141
|
+
button2: {
|
|
142
|
+
...actionGroup.configuration.button2,
|
|
143
|
+
is_on_value: null,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
await act(() => {
|
|
148
|
+
wrapper = create(
|
|
149
|
+
<TwoButtonTemplate
|
|
150
|
+
actionGroup={new_actionGroup}
|
|
151
|
+
doAction={mockDoAction}
|
|
152
|
+
sensor={sensor}
|
|
153
|
+
/>
|
|
106
154
|
);
|
|
107
155
|
});
|
|
108
156
|
const instance = wrapper.root;
|
|
@@ -461,4 +461,139 @@ describe('Test ActionGroup', () => {
|
|
|
461
461
|
moment('2021-09-09T10:00:00.000Z').valueOf()
|
|
462
462
|
);
|
|
463
463
|
});
|
|
464
|
+
|
|
465
|
+
test('render OnOffSmartLock', async () => {
|
|
466
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
467
|
+
const actionGroup = {
|
|
468
|
+
template: 'OnOffSmartLockActionTemplate',
|
|
469
|
+
title: 'Timer',
|
|
470
|
+
configuration: {
|
|
471
|
+
action_off_data: jest.fn(),
|
|
472
|
+
action_on_data: jest.fn(),
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
const mockDoAction = jest.fn();
|
|
476
|
+
await act(() => {
|
|
477
|
+
wrapper = renderer.create(
|
|
478
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
479
|
+
);
|
|
480
|
+
});
|
|
481
|
+
const instance = wrapper.root;
|
|
482
|
+
const texts = instance.findAllByType(Text);
|
|
483
|
+
expect(texts).toHaveLength(5);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test('render OptionsDropdownActionTemplate', async () => {
|
|
487
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
488
|
+
const actionGroup = {
|
|
489
|
+
template: 'OptionsDropdownActionTemplate',
|
|
490
|
+
title: 'Timer',
|
|
491
|
+
configuration: {
|
|
492
|
+
action_data: jest.fn(),
|
|
493
|
+
options: [],
|
|
494
|
+
icon_kit_data: 'icon_kit_data',
|
|
495
|
+
icon: '',
|
|
496
|
+
icon_outlined: 'icon_outlined',
|
|
497
|
+
},
|
|
498
|
+
};
|
|
499
|
+
const mockDoAction = jest.fn();
|
|
500
|
+
await act(() => {
|
|
501
|
+
wrapper = renderer.create(
|
|
502
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
503
|
+
);
|
|
504
|
+
});
|
|
505
|
+
const instance = wrapper.root;
|
|
506
|
+
const texts = instance.findAllByType(Text);
|
|
507
|
+
expect(texts).toHaveLength(7);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
test('render CurtainButtonTemplate', async () => {
|
|
511
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
512
|
+
const actionGroup = {
|
|
513
|
+
template: 'curtain_action_template',
|
|
514
|
+
title: 'Timer',
|
|
515
|
+
configuration: {},
|
|
516
|
+
};
|
|
517
|
+
const mockDoAction = jest.fn();
|
|
518
|
+
await act(() => {
|
|
519
|
+
wrapper = renderer.create(
|
|
520
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
521
|
+
);
|
|
522
|
+
});
|
|
523
|
+
const instance = wrapper.root;
|
|
524
|
+
const texts = instance.findAllByType(Text);
|
|
525
|
+
expect(texts).toHaveLength(2);
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
test('render SmartTiviActionTemplate', async () => {
|
|
529
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
530
|
+
const actionGroup = {
|
|
531
|
+
template: 'SmartTiviActionTemplate',
|
|
532
|
+
title: 'Timer',
|
|
533
|
+
configuration: {},
|
|
534
|
+
};
|
|
535
|
+
const mockDoAction = jest.fn();
|
|
536
|
+
await act(() => {
|
|
537
|
+
wrapper = renderer.create(
|
|
538
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
539
|
+
);
|
|
540
|
+
});
|
|
541
|
+
const instance = wrapper.root;
|
|
542
|
+
const texts = instance.findAllByType(Text);
|
|
543
|
+
expect(texts).toHaveLength(4);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
test('render ColorPickerTemplate', async () => {
|
|
547
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
548
|
+
const actionGroup = {
|
|
549
|
+
template: 'color_picker_template',
|
|
550
|
+
title: 'Timer',
|
|
551
|
+
configuration: {},
|
|
552
|
+
};
|
|
553
|
+
const mockDoAction = jest.fn();
|
|
554
|
+
await act(() => {
|
|
555
|
+
wrapper = renderer.create(
|
|
556
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
557
|
+
);
|
|
558
|
+
});
|
|
559
|
+
const instance = wrapper.root;
|
|
560
|
+
const texts = instance.findAllByType(Text);
|
|
561
|
+
expect(texts).toHaveLength(2);
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
test('render SliderRangeTemplate', async () => {
|
|
565
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
566
|
+
const actionGroup = {
|
|
567
|
+
template: 'slider_range_template',
|
|
568
|
+
title: 'Timer',
|
|
569
|
+
configuration: {},
|
|
570
|
+
};
|
|
571
|
+
const mockDoAction = jest.fn();
|
|
572
|
+
await act(() => {
|
|
573
|
+
wrapper = renderer.create(
|
|
574
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
575
|
+
);
|
|
576
|
+
});
|
|
577
|
+
const instance = wrapper.root;
|
|
578
|
+
const texts = instance.findAllByType(Text);
|
|
579
|
+
expect(texts).toHaveLength(4);
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
test('render TwoButtonTemplate', async () => {
|
|
583
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
584
|
+
const actionGroup = {
|
|
585
|
+
template: 'two_button_action_template',
|
|
586
|
+
title: 'Timer',
|
|
587
|
+
configuration: {},
|
|
588
|
+
};
|
|
589
|
+
const mockDoAction = jest.fn();
|
|
590
|
+
await act(() => {
|
|
591
|
+
wrapper = renderer.create(
|
|
592
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
593
|
+
);
|
|
594
|
+
});
|
|
595
|
+
const instance = wrapper.root;
|
|
596
|
+
const texts = instance.findAllByType(Text);
|
|
597
|
+
expect(texts).toHaveLength(5);
|
|
598
|
+
});
|
|
464
599
|
});
|
|
@@ -5,7 +5,7 @@ import AccountItem from './AccountItem';
|
|
|
5
5
|
|
|
6
6
|
const AccountList = ({ accounts }) => {
|
|
7
7
|
return (
|
|
8
|
-
<ScrollView>
|
|
8
|
+
<ScrollView scrollIndicatorInsets={{ right: 1 }}>
|
|
9
9
|
{accounts.map((account) => (
|
|
10
10
|
<AccountItem key={account.id || account.name} account={account} />
|
|
11
11
|
))}
|
|
@@ -35,9 +35,7 @@ const ItemAutomate = ({
|
|
|
35
35
|
style={[styles.wrap, isSelected && styles.active]}
|
|
36
36
|
>
|
|
37
37
|
<View style={styles.row}>
|
|
38
|
-
<View style={styles.wrapIcon}>
|
|
39
|
-
<Icon />
|
|
40
|
-
</View>
|
|
38
|
+
<View style={styles.wrapIcon}>{!!Icon && <Icon />}</View>
|
|
41
39
|
<View style={styles.wrapTitle}>
|
|
42
40
|
<Text type="H4" bold>
|
|
43
41
|
{t(item?.title)}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import CalendarComponent from '../';
|
|
4
|
+
import { Calendar } from 'react-native-calendars';
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
6
|
+
import BottomSheet from '../../BottomSheet';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
|
|
10
|
+
const mockSetState = jest.fn();
|
|
11
|
+
jest.mock('react', () => {
|
|
12
|
+
return {
|
|
13
|
+
...jest.requireActual('react'),
|
|
14
|
+
useState: jest.fn((init) => [init, mockSetState]),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
const wrapComponent = (route, navigation) => (
|
|
18
|
+
<SCProvider initState={mockSCStore({})}>
|
|
19
|
+
<CalendarComponent route={route} />
|
|
20
|
+
</SCProvider>
|
|
21
|
+
);
|
|
22
|
+
describe('Test Calendar component', () => {
|
|
23
|
+
let tree;
|
|
24
|
+
|
|
25
|
+
test('create Calendar', () => {
|
|
26
|
+
act(() => {
|
|
27
|
+
tree = renderer.create(wrapComponent());
|
|
28
|
+
});
|
|
29
|
+
const instance = tree.root;
|
|
30
|
+
const calendar = instance.findAllByType(Calendar);
|
|
31
|
+
expect(calendar).toHaveLength(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -5,13 +5,19 @@ import Text from '../../Text';
|
|
|
5
5
|
import { SCProvider } from '../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
7
|
|
|
8
|
-
const wrapComponent = (route) => (
|
|
8
|
+
const wrapComponent = (route, isLoading, isConnect, isPercentConnect) => (
|
|
9
9
|
<SCProvider initState={mockSCStore({})}>
|
|
10
|
-
<Connecting
|
|
10
|
+
<Connecting
|
|
11
|
+
route={route}
|
|
12
|
+
isLoading={isLoading}
|
|
13
|
+
isConnect={isConnect}
|
|
14
|
+
isPercentConnect={isPercentConnect}
|
|
15
|
+
/>
|
|
11
16
|
</SCProvider>
|
|
12
17
|
);
|
|
13
18
|
describe('Test Connecting', () => {
|
|
14
19
|
let tree;
|
|
20
|
+
|
|
15
21
|
test('create Connecting', () => {
|
|
16
22
|
act(() => {
|
|
17
23
|
tree = renderer.create(wrapComponent());
|
|
@@ -20,4 +26,15 @@ describe('Test Connecting', () => {
|
|
|
20
26
|
const text = instance.findAllByType(Text);
|
|
21
27
|
expect(text).toHaveLength(4);
|
|
22
28
|
});
|
|
29
|
+
|
|
30
|
+
test('isLoading = true', () => {
|
|
31
|
+
jest.useFakeTimers();
|
|
32
|
+
act(() => {
|
|
33
|
+
tree = renderer.create(wrapComponent({}, true));
|
|
34
|
+
});
|
|
35
|
+
jest.runAllTimers();
|
|
36
|
+
const instance = tree.root;
|
|
37
|
+
const text = instance.findAllByType(Text);
|
|
38
|
+
expect(text).toHaveLength(4);
|
|
39
|
+
});
|
|
23
40
|
});
|
|
@@ -2,13 +2,17 @@ import React, { memo } from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import styles from './DeviceItemStyles';
|
|
4
4
|
import FImage from '../../FImage';
|
|
5
|
-
import
|
|
5
|
+
import _TextInput from '../../Form/TextInput';
|
|
6
6
|
|
|
7
|
-
const DeviceItem = memo(({ icon, name }) => {
|
|
7
|
+
const DeviceItem = memo(({ icon, name, setNewName }) => {
|
|
8
8
|
return (
|
|
9
9
|
<View style={styles.container}>
|
|
10
10
|
{!!icon && <FImage source={{ uri: icon }} style={styles.iconSensor} />}
|
|
11
|
-
<
|
|
11
|
+
<_TextInput
|
|
12
|
+
value={name}
|
|
13
|
+
textInputStyle={styles.textItem}
|
|
14
|
+
onChange={setNewName}
|
|
15
|
+
/>
|
|
12
16
|
</View>
|
|
13
17
|
);
|
|
14
18
|
});
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const marginItem = 12;
|
|
5
|
-
const marginHorizontal = 5;
|
|
6
|
-
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
-
const heightItem = (widthItem / 166) * 60;
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
8
3
|
|
|
9
4
|
export default StyleSheet.create({
|
|
10
5
|
container: {
|
|
11
|
-
paddingHorizontal: 15,
|
|
12
6
|
borderRadius: 10,
|
|
13
7
|
width: 250,
|
|
14
|
-
height: heightItem,
|
|
15
8
|
borderWidth: 1,
|
|
16
9
|
borderColor: Colors.Gray4,
|
|
17
10
|
backgroundColor: Colors.White,
|
|
18
11
|
justifyContent: 'center',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
marginBottom: 16,
|
|
21
12
|
flexDirection: 'row',
|
|
22
13
|
shadowColor: Colors.Shadow,
|
|
23
14
|
shadowOffset: {
|
|
@@ -36,7 +27,13 @@ export default StyleSheet.create({
|
|
|
36
27
|
resizeMode: 'contain',
|
|
37
28
|
},
|
|
38
29
|
textItem: {
|
|
39
|
-
|
|
30
|
+
borderWidth: 0,
|
|
31
|
+
borderBottomWidth: 1,
|
|
32
|
+
borderBottomColor: Colors.Primary,
|
|
33
|
+
textAlign: 'center',
|
|
34
|
+
marginTop: -10,
|
|
35
|
+
padding: 5,
|
|
40
36
|
fontSize: 16,
|
|
37
|
+
height: 50,
|
|
41
38
|
},
|
|
42
39
|
});
|
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
|
|
3
5
|
import ConnectingProcess from '../index';
|
|
4
6
|
import { SafeAreaView } from 'react-native';
|
|
5
7
|
import { SCProvider } from '../../../context';
|
|
6
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
import api from '../../../utils/Apis/axios';
|
|
10
|
+
import { API } from '../../../configs';
|
|
7
11
|
|
|
8
12
|
const wrapComponent = (route) => (
|
|
9
13
|
<SCProvider initState={mockSCStore({})}>
|
|
10
14
|
<ConnectingProcess route={route} />
|
|
11
15
|
</SCProvider>
|
|
12
16
|
);
|
|
17
|
+
|
|
18
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
19
|
+
|
|
13
20
|
describe('Test ConnectingProcess', () => {
|
|
14
21
|
let tree;
|
|
15
|
-
|
|
22
|
+
|
|
23
|
+
test('render without params', () => {
|
|
24
|
+
act(() => {
|
|
25
|
+
tree = renderer.create(wrapComponent({}));
|
|
26
|
+
});
|
|
27
|
+
const instance = tree.root;
|
|
28
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
29
|
+
expect(safeAreaView).toHaveLength(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('create ConnectingProcess with devicePrefixName = SENSOR call api success', async () => {
|
|
16
33
|
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
17
34
|
const devicePrefixName = 'SENSOR';
|
|
18
35
|
const gateway = { id: 1, name: 'gateway' };
|
|
@@ -20,8 +37,124 @@ describe('Test ConnectingProcess', () => {
|
|
|
20
37
|
const route = {
|
|
21
38
|
params: { scan_sensor_data, gateway, station, devicePrefixName },
|
|
22
39
|
};
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
mock.onPost(API.SUB_UNIT.SENSOR_SCAN(1)).reply(200);
|
|
41
|
+
await act(async () => {
|
|
42
|
+
tree = await renderer.create(wrapComponent(route));
|
|
43
|
+
});
|
|
44
|
+
const instance = tree.root;
|
|
45
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
46
|
+
expect(safeAreaView).toHaveLength(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('create ConnectingProcess with devicePrefixName = SENSOR call api fail', async () => {
|
|
50
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
51
|
+
const devicePrefixName = 'SENSOR';
|
|
52
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
53
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
54
|
+
const route = {
|
|
55
|
+
params: { scan_sensor_data, gateway, station, devicePrefixName },
|
|
56
|
+
};
|
|
57
|
+
mock.onPost(API.SUB_UNIT.SENSOR_SCAN(1)).reply(400);
|
|
58
|
+
await act(async () => {
|
|
59
|
+
tree = await renderer.create(wrapComponent(route));
|
|
60
|
+
});
|
|
61
|
+
const instance = tree.root;
|
|
62
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
63
|
+
expect(safeAreaView).toHaveLength(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('create ConnectingProcess with devicePrefixName = ROBOT call api success', async () => {
|
|
67
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
68
|
+
const devicePrefixName = 'ROBOT';
|
|
69
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
70
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
71
|
+
const route = {
|
|
72
|
+
params: {
|
|
73
|
+
scan_sensor_data,
|
|
74
|
+
gateway,
|
|
75
|
+
station,
|
|
76
|
+
devicePrefixName,
|
|
77
|
+
unit_id: 1,
|
|
78
|
+
unit: {
|
|
79
|
+
id: 1,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
mock.onPost(API.UNIT.CHIP_SCAN(1)).reply(200);
|
|
84
|
+
await act(async () => {
|
|
85
|
+
tree = await renderer.create(wrapComponent(route));
|
|
86
|
+
});
|
|
87
|
+
const instance = tree.root;
|
|
88
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
89
|
+
expect(safeAreaView).toHaveLength(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('create ConnectingProcess with devicePrefixName = ROBOT call api fail', async () => {
|
|
93
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
94
|
+
const devicePrefixName = 'ROBOT';
|
|
95
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
96
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
97
|
+
const route = {
|
|
98
|
+
params: {
|
|
99
|
+
scan_sensor_data,
|
|
100
|
+
gateway,
|
|
101
|
+
station,
|
|
102
|
+
devicePrefixName,
|
|
103
|
+
unit_id: 1,
|
|
104
|
+
unit: {
|
|
105
|
+
id: 1,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
mock.onPost(API.UNIT.CHIP_SCAN(1)).reply(400);
|
|
110
|
+
await act(async () => {
|
|
111
|
+
tree = await renderer.create(wrapComponent(route));
|
|
112
|
+
});
|
|
113
|
+
const instance = tree.root;
|
|
114
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
115
|
+
expect(safeAreaView).toHaveLength(1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('create ConnectingProcess with devicePrefixName = LITE call api success', async () => {
|
|
119
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
120
|
+
const devicePrefixName = 'LITE';
|
|
121
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
122
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
123
|
+
const route = {
|
|
124
|
+
params: {
|
|
125
|
+
scan_sensor_data,
|
|
126
|
+
gateway,
|
|
127
|
+
station,
|
|
128
|
+
devicePrefixName,
|
|
129
|
+
unit_id: 1,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
mock.onPost(API.UNIT.ADD_GATEWAY(1)).reply(200);
|
|
133
|
+
await act(async () => {
|
|
134
|
+
tree = await renderer.create(wrapComponent(route));
|
|
135
|
+
});
|
|
136
|
+
const instance = tree.root;
|
|
137
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
138
|
+
expect(safeAreaView).toHaveLength(1);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('create ConnectingProcess with devicePrefixName = LITE call api fail', async () => {
|
|
142
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
143
|
+
const devicePrefixName = 'LITE';
|
|
144
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
145
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
146
|
+
const route = {
|
|
147
|
+
params: {
|
|
148
|
+
scan_sensor_data,
|
|
149
|
+
gateway,
|
|
150
|
+
station,
|
|
151
|
+
devicePrefixName,
|
|
152
|
+
unit_id: 1,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
mock.onPost(API.UNIT.ADD_GATEWAY(1)).reply(400);
|
|
156
|
+
await act(async () => {
|
|
157
|
+
tree = await renderer.create(wrapComponent(route));
|
|
25
158
|
});
|
|
26
159
|
const instance = tree.root;
|
|
27
160
|
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
import DeviceItem from '../DeviceItem/DeviceItem';
|
|
4
4
|
import FImage from '../../FImage';
|
|
5
|
-
import
|
|
5
|
+
import _TextInput from '../../Form/TextInput';
|
|
6
|
+
|
|
6
7
|
describe('Test DeviceItem button', () => {
|
|
7
8
|
let tree;
|
|
8
9
|
test('create DeviceItem button', () => {
|
|
@@ -11,7 +12,7 @@ describe('Test DeviceItem button', () => {
|
|
|
11
12
|
});
|
|
12
13
|
const instance = tree.root;
|
|
13
14
|
const image = instance.findAllByType(FImage);
|
|
14
|
-
const text = instance.findAllByType(
|
|
15
|
+
const text = instance.findAllByType(_TextInput);
|
|
15
16
|
expect(image).toHaveLength(0);
|
|
16
17
|
expect(text).toHaveLength(1);
|
|
17
18
|
});
|