@eohjsc/react-native-smart-city 0.3.6 → 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/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/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__/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__/TimerActionTemplate.test.js +6 -58
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
- package/src/commons/ActionGroup/__test__/index.test.js +0 -135
- 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 +26 -76
- 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 +1 -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 +40 -46
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +10 -64
- 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__/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,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Switch
|
|
2
|
+
import { Switch } 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
|
-
|
|
8
6
|
import moment from 'moment';
|
|
9
7
|
import Text from '../../Text';
|
|
10
8
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
@@ -17,14 +15,12 @@ jest.mock('../../../iot/states', () => ({
|
|
|
17
15
|
useConfigGlobalState: () => [{ 5: 18, 6: 30 }, null],
|
|
18
16
|
}));
|
|
19
17
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const wrapComponent = (actionGroup, sensor) => (
|
|
18
|
+
const wrapComponent = (actionGroup, mockDoAction, is_managed_by_backend) => (
|
|
23
19
|
<SCProvider initState={mockSCStore({})}>
|
|
24
20
|
<TimerActionTemplate
|
|
25
21
|
actionGroup={actionGroup}
|
|
26
22
|
doAction={mockDoAction}
|
|
27
|
-
sensor={
|
|
23
|
+
sensor={{ is_managed_by_backend }}
|
|
28
24
|
/>
|
|
29
25
|
</SCProvider>
|
|
30
26
|
);
|
|
@@ -43,7 +39,6 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
43
39
|
|
|
44
40
|
let actionGroup;
|
|
45
41
|
let wrapper;
|
|
46
|
-
let sensor;
|
|
47
42
|
|
|
48
43
|
beforeEach(() => {
|
|
49
44
|
watchMultiConfigs.mockClear();
|
|
@@ -55,24 +50,12 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
55
50
|
config_minute: 6,
|
|
56
51
|
},
|
|
57
52
|
};
|
|
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);
|
|
71
53
|
});
|
|
72
54
|
|
|
73
55
|
test('render template', async () => {
|
|
56
|
+
const mockDoAction = jest.fn();
|
|
74
57
|
await act(async () => {
|
|
75
|
-
wrapper = await create(wrapComponent(actionGroup,
|
|
58
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
76
59
|
});
|
|
77
60
|
const instance = wrapper.root;
|
|
78
61
|
|
|
@@ -83,46 +66,11 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
83
66
|
|
|
84
67
|
const switchButton = instance.findByType(Switch);
|
|
85
68
|
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();
|
|
93
69
|
|
|
94
70
|
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
95
|
-
expect(dateTimePicker.props.isVisible).
|
|
71
|
+
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
96
72
|
expect(dateTimePicker.props.date).toEqual(
|
|
97
73
|
moment('18:30', 'HH:mm').valueOf()
|
|
98
74
|
);
|
|
99
75
|
});
|
|
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
|
-
});
|
|
128
76
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import TwoButtonTemplate from '../TwoButtonTemplate';
|
|
6
5
|
|
|
7
6
|
jest.mock('react', () => ({
|
|
@@ -32,10 +31,6 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
32
31
|
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
const sensor = {
|
|
36
|
-
device_type: DEVICE_TYPE.LG_THINQ,
|
|
37
|
-
is_managed_by_backend: true,
|
|
38
|
-
};
|
|
39
34
|
const actionGroup = {
|
|
40
35
|
configuration: {
|
|
41
36
|
button1: {
|
|
@@ -46,9 +41,6 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
46
41
|
icon_on: 'poweroff',
|
|
47
42
|
text_on: 'ON',
|
|
48
43
|
config: 621,
|
|
49
|
-
is_on_value: [true],
|
|
50
|
-
action_on_data,
|
|
51
|
-
action_off_data,
|
|
52
44
|
},
|
|
53
45
|
button2: {
|
|
54
46
|
action_off: 'f49e1577-493d-4bae-a9ab-3b0f96a4ec52',
|
|
@@ -58,9 +50,6 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
58
50
|
icon_on: 'caret-right',
|
|
59
51
|
text_on: 'START',
|
|
60
52
|
config: 621,
|
|
61
|
-
is_on_value: [true],
|
|
62
|
-
action_on_data,
|
|
63
|
-
action_off_data,
|
|
64
53
|
},
|
|
65
54
|
},
|
|
66
55
|
};
|
|
@@ -113,44 +102,7 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
113
102
|
const mockDoAction = jest.fn();
|
|
114
103
|
await act(() => {
|
|
115
104
|
wrapper = create(
|
|
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
|
-
/>
|
|
105
|
+
<TwoButtonTemplate actionGroup={actionGroup} doAction={mockDoAction} />
|
|
154
106
|
);
|
|
155
107
|
});
|
|
156
108
|
const instance = wrapper.root;
|
|
@@ -461,139 +461,4 @@ 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
|
-
});
|
|
599
464
|
});
|
|
@@ -5,7 +5,7 @@ import AccountItem from './AccountItem';
|
|
|
5
5
|
|
|
6
6
|
const AccountList = ({ accounts }) => {
|
|
7
7
|
return (
|
|
8
|
-
<ScrollView
|
|
8
|
+
<ScrollView>
|
|
9
9
|
{accounts.map((account) => (
|
|
10
10
|
<AccountItem key={account.id || account.name} account={account} />
|
|
11
11
|
))}
|
|
@@ -35,7 +35,9 @@ const ItemAutomate = ({
|
|
|
35
35
|
style={[styles.wrap, isSelected && styles.active]}
|
|
36
36
|
>
|
|
37
37
|
<View style={styles.row}>
|
|
38
|
-
<View style={styles.wrapIcon}>
|
|
38
|
+
<View style={styles.wrapIcon}>
|
|
39
|
+
<Icon />
|
|
40
|
+
</View>
|
|
39
41
|
<View style={styles.wrapTitle}>
|
|
40
42
|
<Text type="H4" bold>
|
|
41
43
|
{t(item?.title)}
|
|
@@ -5,19 +5,13 @@ 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) => (
|
|
9
9
|
<SCProvider initState={mockSCStore({})}>
|
|
10
|
-
<Connecting
|
|
11
|
-
route={route}
|
|
12
|
-
isLoading={isLoading}
|
|
13
|
-
isConnect={isConnect}
|
|
14
|
-
isPercentConnect={isPercentConnect}
|
|
15
|
-
/>
|
|
10
|
+
<Connecting route={route} />
|
|
16
11
|
</SCProvider>
|
|
17
12
|
);
|
|
18
13
|
describe('Test Connecting', () => {
|
|
19
14
|
let tree;
|
|
20
|
-
|
|
21
15
|
test('create Connecting', () => {
|
|
22
16
|
act(() => {
|
|
23
17
|
tree = renderer.create(wrapComponent());
|
|
@@ -26,15 +20,4 @@ describe('Test Connecting', () => {
|
|
|
26
20
|
const text = instance.findAllByType(Text);
|
|
27
21
|
expect(text).toHaveLength(4);
|
|
28
22
|
});
|
|
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
|
-
});
|
|
40
23
|
});
|
|
@@ -2,17 +2,13 @@ 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 Text from '../../Text';
|
|
6
6
|
|
|
7
|
-
const DeviceItem = memo(({ icon, name
|
|
7
|
+
const DeviceItem = memo(({ icon, name }) => {
|
|
8
8
|
return (
|
|
9
9
|
<View style={styles.container}>
|
|
10
10
|
{!!icon && <FImage source={{ uri: icon }} style={styles.iconSensor} />}
|
|
11
|
-
<
|
|
12
|
-
value={name}
|
|
13
|
-
textInputStyle={styles.textItem}
|
|
14
|
-
onChange={setNewName}
|
|
15
|
-
/>
|
|
11
|
+
<Text style={styles.textItem}>{name}</Text>
|
|
16
12
|
</View>
|
|
17
13
|
);
|
|
18
14
|
});
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../../configs';
|
|
2
|
+
import { Constants, Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
const marginItem = 12;
|
|
5
|
+
const marginHorizontal = 5;
|
|
6
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
+
const heightItem = (widthItem / 166) * 60;
|
|
3
8
|
|
|
4
9
|
export default StyleSheet.create({
|
|
5
10
|
container: {
|
|
11
|
+
paddingHorizontal: 15,
|
|
6
12
|
borderRadius: 10,
|
|
7
13
|
width: 250,
|
|
14
|
+
height: heightItem,
|
|
8
15
|
borderWidth: 1,
|
|
9
16
|
borderColor: Colors.Gray4,
|
|
10
17
|
backgroundColor: Colors.White,
|
|
11
18
|
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
marginBottom: 16,
|
|
12
21
|
flexDirection: 'row',
|
|
13
22
|
shadowColor: Colors.Shadow,
|
|
14
23
|
shadowOffset: {
|
|
@@ -27,13 +36,7 @@ export default StyleSheet.create({
|
|
|
27
36
|
resizeMode: 'contain',
|
|
28
37
|
},
|
|
29
38
|
textItem: {
|
|
30
|
-
|
|
31
|
-
borderBottomWidth: 1,
|
|
32
|
-
borderBottomColor: Colors.Primary,
|
|
33
|
-
textAlign: 'center',
|
|
34
|
-
marginTop: -10,
|
|
35
|
-
padding: 5,
|
|
39
|
+
marginLeft: 15,
|
|
36
40
|
fontSize: 16,
|
|
37
|
-
height: 50,
|
|
38
41
|
},
|
|
39
42
|
});
|
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
-
|
|
5
3
|
import ConnectingProcess from '../index';
|
|
6
4
|
import { SafeAreaView } from 'react-native';
|
|
7
5
|
import { SCProvider } from '../../../context';
|
|
8
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
-
import api from '../../../utils/Apis/axios';
|
|
10
|
-
import { API } from '../../../configs';
|
|
11
7
|
|
|
12
8
|
const wrapComponent = (route) => (
|
|
13
9
|
<SCProvider initState={mockSCStore({})}>
|
|
14
10
|
<ConnectingProcess route={route} />
|
|
15
11
|
</SCProvider>
|
|
16
12
|
);
|
|
17
|
-
|
|
18
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
19
|
-
|
|
20
13
|
describe('Test ConnectingProcess', () => {
|
|
21
14
|
let tree;
|
|
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 () => {
|
|
15
|
+
test('create ConnectingProcess', () => {
|
|
33
16
|
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
34
17
|
const devicePrefixName = 'SENSOR';
|
|
35
18
|
const gateway = { id: 1, name: 'gateway' };
|
|
@@ -37,124 +20,8 @@ describe('Test ConnectingProcess', () => {
|
|
|
37
20
|
const route = {
|
|
38
21
|
params: { scan_sensor_data, gateway, station, devicePrefixName },
|
|
39
22
|
};
|
|
40
|
-
|
|
41
|
-
|
|
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));
|
|
23
|
+
act(() => {
|
|
24
|
+
tree = renderer.create(wrapComponent(route));
|
|
158
25
|
});
|
|
159
26
|
const instance = tree.root;
|
|
160
27
|
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
@@ -2,8 +2,7 @@ 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
|
|
6
|
-
|
|
5
|
+
import Text from '../../Text';
|
|
7
6
|
describe('Test DeviceItem button', () => {
|
|
8
7
|
let tree;
|
|
9
8
|
test('create DeviceItem button', () => {
|
|
@@ -12,7 +11,7 @@ describe('Test DeviceItem button', () => {
|
|
|
12
11
|
});
|
|
13
12
|
const instance = tree.root;
|
|
14
13
|
const image = instance.findAllByType(FImage);
|
|
15
|
-
const text = instance.findAllByType(
|
|
14
|
+
const text = instance.findAllByType(Text);
|
|
16
15
|
expect(image).toHaveLength(0);
|
|
17
16
|
expect(text).toHaveLength(1);
|
|
18
17
|
});
|