@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,16 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
|
|
5
5
|
import SelectAction from '../SelectAction';
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
9
9
|
import { TESTID } from '../../../configs/Constants';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import ActionTemplate from '../../../commons/ActionTemplate';
|
|
11
|
+
import NumberUpDownActionTemplate from '../../../commons/OneTapTemplate/NumberUpDownActionTemplate';
|
|
12
|
+
import OptionsDropdownActionTemplate from '../../../commons/OneTapTemplate/OptionsDropdownActionTemplate';
|
|
13
|
+
import StatesGridActionTemplate from '../../../commons/OneTapTemplate/StatesGridActionTemplate';
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
jest.mock('axios');
|
|
14
16
|
|
|
15
17
|
const mockedNavigate = jest.fn();
|
|
16
18
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -47,21 +49,38 @@ describe('Test SelectAction', () => {
|
|
|
47
49
|
},
|
|
48
50
|
};
|
|
49
51
|
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
axios.get.mockClear();
|
|
54
|
+
});
|
|
55
|
+
|
|
50
56
|
test('test onSave have automateId', async () => {
|
|
51
|
-
|
|
57
|
+
const response = {
|
|
58
|
+
status: 200,
|
|
59
|
+
success: true,
|
|
60
|
+
};
|
|
61
|
+
axios.post.mockImplementation(async () => {
|
|
62
|
+
return response;
|
|
63
|
+
});
|
|
52
64
|
await act(async () => {
|
|
53
65
|
tree = await renderer.create(wrapComponent(route));
|
|
54
66
|
});
|
|
55
67
|
const instance = tree.root;
|
|
68
|
+
|
|
56
69
|
const bottomButton = instance.findByType(BottomButtonView);
|
|
57
70
|
await act(async () => {
|
|
58
71
|
bottomButton.props.onPressMain();
|
|
59
72
|
});
|
|
73
|
+
expect(axios.post).toHaveBeenCalled();
|
|
60
74
|
expect(mockedNavigate).toHaveBeenCalled();
|
|
61
75
|
});
|
|
62
76
|
|
|
63
77
|
test('test onSave fail not permission', async () => {
|
|
64
|
-
|
|
78
|
+
const response = {
|
|
79
|
+
status: 404,
|
|
80
|
+
};
|
|
81
|
+
axios.post.mockImplementation(async () => {
|
|
82
|
+
return response;
|
|
83
|
+
});
|
|
65
84
|
await act(async () => {
|
|
66
85
|
tree = await renderer.create(wrapComponent(route));
|
|
67
86
|
});
|
|
@@ -71,7 +90,7 @@ describe('Test SelectAction', () => {
|
|
|
71
90
|
await act(async () => {
|
|
72
91
|
bottomButton.props.onPressMain();
|
|
73
92
|
});
|
|
74
|
-
expect(
|
|
93
|
+
expect(axios.post).toHaveBeenCalled();
|
|
75
94
|
});
|
|
76
95
|
|
|
77
96
|
test('test fetchData', async () => {
|
|
@@ -84,11 +103,13 @@ describe('Test SelectAction', () => {
|
|
|
84
103
|
{ template: 'three_button_action_template' },
|
|
85
104
|
],
|
|
86
105
|
};
|
|
87
|
-
|
|
106
|
+
axios.get.mockImplementation(async () => {
|
|
107
|
+
return response;
|
|
108
|
+
});
|
|
88
109
|
await act(async () => {
|
|
89
110
|
tree = await renderer.create(wrapComponent(route));
|
|
90
111
|
});
|
|
91
|
-
expect(
|
|
112
|
+
expect(axios.get).toHaveBeenCalled();
|
|
92
113
|
});
|
|
93
114
|
|
|
94
115
|
test('test RenderActionItem', async () => {
|
|
@@ -165,7 +186,9 @@ describe('Test SelectAction', () => {
|
|
|
165
186
|
},
|
|
166
187
|
],
|
|
167
188
|
};
|
|
168
|
-
|
|
189
|
+
axios.get.mockImplementation(async () => {
|
|
190
|
+
return response;
|
|
191
|
+
});
|
|
169
192
|
await act(async () => {
|
|
170
193
|
tree = renderer.create(wrapComponent(route));
|
|
171
194
|
});
|
|
@@ -173,6 +196,64 @@ describe('Test SelectAction', () => {
|
|
|
173
196
|
const renderActionItem = instance.find(
|
|
174
197
|
(el) => el.props.testID === TESTID.ACTION_ITEM
|
|
175
198
|
);
|
|
199
|
+
const actionTemplate = instance.findByType(ActionTemplate);
|
|
200
|
+
const numberUpDownActionTemplate = instance.findByType(
|
|
201
|
+
NumberUpDownActionTemplate
|
|
202
|
+
);
|
|
203
|
+
const optionsDropdownActionTemplate = instance.findByType(
|
|
204
|
+
OptionsDropdownActionTemplate
|
|
205
|
+
);
|
|
206
|
+
const statesGridActionTemplate = instance.findByType(
|
|
207
|
+
StatesGridActionTemplate
|
|
208
|
+
);
|
|
209
|
+
|
|
176
210
|
expect(renderActionItem.props.data.length).toBe(4);
|
|
211
|
+
expect(actionTemplate).toBeDefined();
|
|
212
|
+
expect(numberUpDownActionTemplate).toBeDefined();
|
|
213
|
+
expect(optionsDropdownActionTemplate).toBeDefined();
|
|
214
|
+
expect(statesGridActionTemplate).toBeDefined();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('test onPress handleOnSelectAction', async () => {
|
|
218
|
+
const response = {
|
|
219
|
+
status: 200,
|
|
220
|
+
success: true,
|
|
221
|
+
data: [
|
|
222
|
+
{
|
|
223
|
+
title: '',
|
|
224
|
+
template: 'three_button_action_template',
|
|
225
|
+
configuration: {
|
|
226
|
+
action1: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
227
|
+
action2: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
228
|
+
action3: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
229
|
+
icon1: 'up',
|
|
230
|
+
icon2: 'stop',
|
|
231
|
+
icon3: 'down',
|
|
232
|
+
text1: 'OPEN',
|
|
233
|
+
text2: 'STOP',
|
|
234
|
+
text3: 'CLOSE',
|
|
235
|
+
text_lock: 'Door lock',
|
|
236
|
+
is_display_lock: true,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
};
|
|
241
|
+
axios.get.mockImplementation(async () => {
|
|
242
|
+
return response;
|
|
243
|
+
});
|
|
244
|
+
await act(async () => {
|
|
245
|
+
tree = await renderer.create(wrapComponent(route));
|
|
246
|
+
});
|
|
247
|
+
const instance = tree.root;
|
|
248
|
+
const actionTemplate = instance.findByType(ActionTemplate);
|
|
249
|
+
const bottomButton = instance.findByType(BottomButtonView);
|
|
250
|
+
act(() => {
|
|
251
|
+
actionTemplate.props.onSelectAction({
|
|
252
|
+
name: 'OPEN',
|
|
253
|
+
action: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
254
|
+
template: 'three_button_action_template',
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
expect(bottomButton.props.typeMain).toEqual('primary');
|
|
177
258
|
});
|
|
178
259
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
|
|
5
5
|
import SelectSensorDevices from '../SelectSensorDevices';
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
@@ -9,22 +9,18 @@ import Device from '../Device';
|
|
|
9
9
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
10
10
|
import NavBar from '../../../commons/NavBar';
|
|
11
11
|
import API from '../../../configs/API';
|
|
12
|
-
import {
|
|
12
|
+
import { TESTID } from '../../../configs/Constants';
|
|
13
13
|
import { TouchableOpacity } from 'react-native';
|
|
14
14
|
import Routes from '../../../utils/Route';
|
|
15
|
-
import api from '../../../utils/Apis/axios';
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
jest.mock('axios');
|
|
18
17
|
|
|
19
18
|
const mockedNavigate = jest.fn();
|
|
20
|
-
const mockedDispatch = jest.fn();
|
|
21
|
-
|
|
22
19
|
jest.mock('@react-navigation/native', () => {
|
|
23
20
|
return {
|
|
24
21
|
...jest.requireActual('@react-navigation/native'),
|
|
25
22
|
useNavigation: () => ({
|
|
26
23
|
navigate: mockedNavigate,
|
|
27
|
-
dispatch: mockedDispatch,
|
|
28
24
|
}),
|
|
29
25
|
};
|
|
30
26
|
});
|
|
@@ -49,9 +45,6 @@ describe('Test SelectSensorDevices', () => {
|
|
|
49
45
|
unit: { id: 1, name: 'Unit test' },
|
|
50
46
|
automateId: 1,
|
|
51
47
|
scriptName: 'scriptName test',
|
|
52
|
-
automate: {
|
|
53
|
-
sensor_id: 1,
|
|
54
|
-
},
|
|
55
48
|
},
|
|
56
49
|
};
|
|
57
50
|
const response = {
|
|
@@ -70,21 +63,29 @@ describe('Test SelectSensorDevices', () => {
|
|
|
70
63
|
};
|
|
71
64
|
|
|
72
65
|
beforeEach(() => {
|
|
66
|
+
axios.get.mockClear();
|
|
73
67
|
mockedNavigate.mockClear();
|
|
74
68
|
});
|
|
75
69
|
|
|
76
70
|
test('fetch Device success', async () => {
|
|
77
|
-
|
|
71
|
+
axios.get.mockImplementation(async () => {
|
|
72
|
+
return response;
|
|
73
|
+
});
|
|
74
|
+
|
|
78
75
|
await act(async () => {
|
|
79
76
|
tree = renderer.create(wrapComponent(route));
|
|
80
77
|
});
|
|
81
78
|
const instance = tree.root;
|
|
82
79
|
const navBar = instance.findByType(NavBar);
|
|
80
|
+
|
|
81
|
+
expect(axios.get).toHaveBeenCalledWith(API.UNIT.DEVICE_CONTROL(1), {});
|
|
83
82
|
expect(navBar.props.listStation).toHaveLength(1);
|
|
84
83
|
});
|
|
85
84
|
|
|
86
85
|
test('onPress continue', async () => {
|
|
87
|
-
|
|
86
|
+
axios.get.mockImplementation(async () => {
|
|
87
|
+
return response;
|
|
88
|
+
});
|
|
88
89
|
await act(async () => {
|
|
89
90
|
tree = renderer.create(wrapComponent(route));
|
|
90
91
|
});
|
|
@@ -98,7 +99,9 @@ describe('Test SelectSensorDevices', () => {
|
|
|
98
99
|
});
|
|
99
100
|
|
|
100
101
|
test('test onPressDevice', async () => {
|
|
101
|
-
|
|
102
|
+
axios.get.mockImplementation(async () => {
|
|
103
|
+
return response;
|
|
104
|
+
});
|
|
102
105
|
await act(async () => {
|
|
103
106
|
tree = renderer.create(wrapComponent(route));
|
|
104
107
|
});
|
|
@@ -110,6 +113,7 @@ describe('Test SelectSensorDevices', () => {
|
|
|
110
113
|
device[0].props.onPress({ id: 1, name: 'sensor' });
|
|
111
114
|
});
|
|
112
115
|
expect(device[0].props.isSelectDevice).toEqual(true);
|
|
116
|
+
|
|
113
117
|
act(() => {
|
|
114
118
|
device[0].props.onPress({ id: 1, name: 'sensor' });
|
|
115
119
|
});
|
|
@@ -117,12 +121,16 @@ describe('Test SelectSensorDevices', () => {
|
|
|
117
121
|
});
|
|
118
122
|
|
|
119
123
|
test('test onSnapItem', async () => {
|
|
120
|
-
|
|
124
|
+
axios.get.mockImplementation(async () => {
|
|
125
|
+
return response;
|
|
126
|
+
});
|
|
127
|
+
|
|
121
128
|
await act(async () => {
|
|
122
129
|
tree = renderer.create(wrapComponent(route));
|
|
123
130
|
});
|
|
124
131
|
const instance = tree.root;
|
|
125
132
|
const navBar = instance.findByType(NavBar);
|
|
133
|
+
|
|
126
134
|
act(() => {
|
|
127
135
|
navBar.props.onSnapToItem({ id: 1, name: 'sensor' }, 0);
|
|
128
136
|
});
|
|
@@ -130,7 +138,9 @@ describe('Test SelectSensorDevices', () => {
|
|
|
130
138
|
});
|
|
131
139
|
|
|
132
140
|
test('test onPressClose user already has an automateId', async () => {
|
|
133
|
-
|
|
141
|
+
axios.get.mockImplementation(async () => {
|
|
142
|
+
return response;
|
|
143
|
+
});
|
|
134
144
|
await act(async () => {
|
|
135
145
|
tree = renderer.create(wrapComponent(route));
|
|
136
146
|
});
|
|
@@ -144,6 +154,7 @@ describe('Test SelectSensorDevices', () => {
|
|
|
144
154
|
await act(async () => {
|
|
145
155
|
iconClose[0].props.onPress();
|
|
146
156
|
});
|
|
157
|
+
|
|
147
158
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
|
|
148
159
|
havePermission: true,
|
|
149
160
|
id: 1,
|
|
@@ -155,29 +166,4 @@ describe('Test SelectSensorDevices', () => {
|
|
|
155
166
|
unit: { id: 1, name: 'Unit test' },
|
|
156
167
|
});
|
|
157
168
|
});
|
|
158
|
-
|
|
159
|
-
test('test onPressClose user already has not an automateId', async () => {
|
|
160
|
-
mock.onGet(API.UNIT.DEVICE_SENSOR(1)).reply(200, response.data);
|
|
161
|
-
const new_route = {
|
|
162
|
-
...route,
|
|
163
|
-
params: {
|
|
164
|
-
...route.params,
|
|
165
|
-
automateId: null,
|
|
166
|
-
title: AUTOMATE_SELECT.SELECT_SENSOR,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
await act(async () => {
|
|
170
|
-
tree = renderer.create(wrapComponent(new_route));
|
|
171
|
-
});
|
|
172
|
-
const instance = tree.root;
|
|
173
|
-
const iconClose = instance.findAll(
|
|
174
|
-
(el) =>
|
|
175
|
-
el.props.testID === TESTID.ICON_CLOSE && el.type === TouchableOpacity
|
|
176
|
-
);
|
|
177
|
-
expect(iconClose).toHaveLength(1);
|
|
178
|
-
await act(async () => {
|
|
179
|
-
iconClose[0].props.onPress();
|
|
180
|
-
});
|
|
181
|
-
expect(mockedDispatch).toBeCalled();
|
|
182
|
-
});
|
|
183
169
|
});
|
|
@@ -69,13 +69,12 @@ describe('test AddNewAutoSmart', () => {
|
|
|
69
69
|
automate: {},
|
|
70
70
|
automateId: undefined,
|
|
71
71
|
title: 'select_sensor',
|
|
72
|
-
|
|
72
|
+
type: 'value_change',
|
|
73
73
|
scriptName: undefined,
|
|
74
74
|
unit: { id: 1 },
|
|
75
75
|
isAutomateTab: undefined,
|
|
76
76
|
isMultiUnits: undefined,
|
|
77
77
|
routeName: 'SelectSensorDevices',
|
|
78
|
-
type: 'value_change',
|
|
79
78
|
});
|
|
80
79
|
});
|
|
81
80
|
|
|
@@ -103,7 +102,6 @@ describe('test AddNewAutoSmart', () => {
|
|
|
103
102
|
automate: {},
|
|
104
103
|
automateId: undefined,
|
|
105
104
|
type: 'schedule',
|
|
106
|
-
oldType: 'value_change',
|
|
107
105
|
routeName: 'SetSchedule',
|
|
108
106
|
scriptName: undefined,
|
|
109
107
|
unit: route.params.unit,
|
|
@@ -25,7 +25,6 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
25
25
|
automate = {},
|
|
26
26
|
scriptName,
|
|
27
27
|
} = route.params;
|
|
28
|
-
|
|
29
28
|
const typeAutoSmart = {
|
|
30
29
|
[AUTOMATE_TYPE.AUTOMATE]: [
|
|
31
30
|
{
|
|
@@ -97,7 +96,6 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
97
96
|
routeName: dataAutomate?.route,
|
|
98
97
|
automate,
|
|
99
98
|
scriptName,
|
|
100
|
-
oldType: type,
|
|
101
99
|
};
|
|
102
100
|
|
|
103
101
|
if (
|
|
@@ -109,15 +107,14 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
109
107
|
navigate(dataAutomate.route, params);
|
|
110
108
|
}
|
|
111
109
|
}, [
|
|
112
|
-
|
|
110
|
+
navigate,
|
|
113
111
|
selectedIndex,
|
|
112
|
+
data,
|
|
114
113
|
unit,
|
|
115
114
|
isAutomateTab,
|
|
116
115
|
isMultiUnits,
|
|
117
116
|
automate,
|
|
118
117
|
scriptName,
|
|
119
|
-
type,
|
|
120
|
-
navigate,
|
|
121
118
|
]);
|
|
122
119
|
|
|
123
120
|
const handleSelectIndex = (index) => {
|
|
@@ -12,12 +12,12 @@ import Routes from '../../utils/Route';
|
|
|
12
12
|
const ConnectingDevices = memo(({ route }) => {
|
|
13
13
|
const t = useTranslations();
|
|
14
14
|
const { navigate } = useNavigation();
|
|
15
|
-
const { new_sensor } = route.params
|
|
15
|
+
const { new_sensor } = route.params;
|
|
16
16
|
|
|
17
17
|
useEffect(() => {
|
|
18
18
|
const checkSensorConnected = setInterval(async () => {
|
|
19
19
|
const { success } = await axiosGet(
|
|
20
|
-
API.
|
|
20
|
+
API.SENSOR.CHECK_CONNECTION(new_sensor.id),
|
|
21
21
|
{},
|
|
22
22
|
true
|
|
23
23
|
);
|
|
@@ -26,7 +26,7 @@ const ConnectingDevices = memo(({ route }) => {
|
|
|
26
26
|
}
|
|
27
27
|
}, 3000);
|
|
28
28
|
return () => clearInterval(checkSensorConnected);
|
|
29
|
-
}, [navigate, new_sensor
|
|
29
|
+
}, [navigate, new_sensor.id, route.params]);
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<View style={styles.wrap}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
|
|
5
5
|
import AddNewDevice from '../index';
|
|
6
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
@@ -11,8 +11,6 @@ import Routes from '../../../utils/Route';
|
|
|
11
11
|
import { getTranslate } from '../../../utils/I18n';
|
|
12
12
|
import { SCProvider } from '../../../context';
|
|
13
13
|
import { mockSCStore } from '../../../context/mockStore';
|
|
14
|
-
import api from '../../../utils/Apis/axios';
|
|
15
|
-
import { Platform } from 'react-native';
|
|
16
14
|
|
|
17
15
|
const wrapComponent = (route) => (
|
|
18
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -20,7 +18,7 @@ const wrapComponent = (route) => (
|
|
|
20
18
|
</SCProvider>
|
|
21
19
|
);
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
jest.mock('axios');
|
|
24
22
|
|
|
25
23
|
jest.mock('react', () => {
|
|
26
24
|
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
@@ -44,6 +42,7 @@ describe('Test AddNewDevice', () => {
|
|
|
44
42
|
let route;
|
|
45
43
|
|
|
46
44
|
afterEach(() => {
|
|
45
|
+
axios.get.mockClear();
|
|
47
46
|
mockedNavigate.mockClear();
|
|
48
47
|
});
|
|
49
48
|
|
|
@@ -53,7 +52,6 @@ describe('Test AddNewDevice', () => {
|
|
|
53
52
|
unit_id: 1,
|
|
54
53
|
},
|
|
55
54
|
};
|
|
56
|
-
mock.resetHistory();
|
|
57
55
|
});
|
|
58
56
|
|
|
59
57
|
const getText = (instance, id) => {
|
|
@@ -80,16 +78,23 @@ describe('Test AddNewDevice', () => {
|
|
|
80
78
|
});
|
|
81
79
|
|
|
82
80
|
test('fetchDetails success', async () => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
const response = {
|
|
82
|
+
status: 200,
|
|
83
|
+
data: {
|
|
84
|
+
id: 1,
|
|
85
|
+
name: 'Unit name',
|
|
86
|
+
stations: [{ id: 2, name: 'Station name' }],
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
axios.get.mockImplementation(async () => {
|
|
90
|
+
return response;
|
|
87
91
|
});
|
|
88
92
|
|
|
89
93
|
await act(async () => {
|
|
90
94
|
tree = await create(wrapComponent(route));
|
|
91
95
|
});
|
|
92
96
|
const instance = tree.root;
|
|
97
|
+
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
93
98
|
|
|
94
99
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
95
100
|
expect(groupCheckBox.props.data).toEqual([
|
|
@@ -98,19 +103,21 @@ describe('Test AddNewDevice', () => {
|
|
|
98
103
|
});
|
|
99
104
|
|
|
100
105
|
test('fetchDetails fail', async () => {
|
|
101
|
-
|
|
106
|
+
const response = {
|
|
107
|
+
data: {},
|
|
108
|
+
};
|
|
109
|
+
axios.get.mockImplementation(async () => {
|
|
110
|
+
return response;
|
|
111
|
+
});
|
|
112
|
+
|
|
102
113
|
await act(async () => {
|
|
103
114
|
tree = await create(wrapComponent(route));
|
|
104
115
|
});
|
|
105
116
|
const instance = tree.root;
|
|
117
|
+
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
118
|
+
|
|
106
119
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
107
|
-
expect(groupCheckBox.props.data).toEqual([
|
|
108
|
-
{
|
|
109
|
-
id: 2,
|
|
110
|
-
name: 'Station name',
|
|
111
|
-
title: 'Station name',
|
|
112
|
-
},
|
|
113
|
-
]);
|
|
120
|
+
expect(groupCheckBox.props.data).toEqual([]);
|
|
114
121
|
});
|
|
115
122
|
|
|
116
123
|
test('ViewButtonBottom', async () => {
|
|
@@ -153,10 +160,16 @@ describe('Test AddNewDevice', () => {
|
|
|
153
160
|
});
|
|
154
161
|
|
|
155
162
|
test('ViewButtonBottom onRightClick with stationId', async () => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
const response = {
|
|
164
|
+
status: 200,
|
|
165
|
+
data: {
|
|
166
|
+
id: 1,
|
|
167
|
+
name: 'Unit name',
|
|
168
|
+
stations: [{ id: 2, name: 'Station name' }],
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
axios.get.mockImplementation(async () => {
|
|
172
|
+
return response;
|
|
160
173
|
});
|
|
161
174
|
|
|
162
175
|
await act(async () => {
|
|
@@ -179,25 +192,4 @@ describe('Test AddNewDevice', () => {
|
|
|
179
192
|
unit_name: 'Unit name',
|
|
180
193
|
});
|
|
181
194
|
});
|
|
182
|
-
|
|
183
|
-
test('handleOnSelect with id = -1', async () => {
|
|
184
|
-
Platform.OS = 'android';
|
|
185
|
-
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, {
|
|
186
|
-
id: 1,
|
|
187
|
-
name: 'Unit name',
|
|
188
|
-
stations: [{ id: 2, name: 'Station name' }],
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
await act(async () => {
|
|
192
|
-
tree = await create(wrapComponent(route));
|
|
193
|
-
});
|
|
194
|
-
const instance = tree.root;
|
|
195
|
-
|
|
196
|
-
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
197
|
-
await act(async () => {
|
|
198
|
-
groupCheckBox.props.onSelect({ id: -1 }); // select stationId
|
|
199
|
-
});
|
|
200
|
-
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
201
|
-
expect(viewButtonBottom.props.rightDisabled).toBeTruthy();
|
|
202
|
-
});
|
|
203
195
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import axios from 'axios';
|
|
3
4
|
|
|
4
5
|
import ConnectDevices from '../ConnectDevices';
|
|
5
6
|
import { TESTID } from '../../../configs/Constants';
|
|
@@ -10,6 +11,8 @@ import { SCProvider } from '../../../context';
|
|
|
10
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
11
12
|
import { getTranslate } from '../../../utils/I18n';
|
|
12
13
|
|
|
14
|
+
jest.mock('axios');
|
|
15
|
+
|
|
13
16
|
const mockedNavigate = jest.fn();
|
|
14
17
|
jest.mock('@react-navigation/native', () => {
|
|
15
18
|
return {
|
|
@@ -31,6 +34,7 @@ describe('Test ConnectDevices', () => {
|
|
|
31
34
|
let route;
|
|
32
35
|
|
|
33
36
|
afterEach(() => {
|
|
37
|
+
axios.get.mockClear();
|
|
34
38
|
mockedNavigate.mockClear();
|
|
35
39
|
});
|
|
36
40
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
|
|
5
5
|
import { API } from '../../../configs';
|
|
6
6
|
import ConnectingDevices from '../ConnectingDevices';
|
|
@@ -9,9 +9,8 @@ import Routes from '../../../utils/Route';
|
|
|
9
9
|
import { SCProvider } from '../../../context';
|
|
10
10
|
import { mockSCStore } from '../../../context/mockStore';
|
|
11
11
|
import { getTranslate } from '../../../utils/I18n';
|
|
12
|
-
import api from '../../../utils/Apis/axios';
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
jest.mock('axios');
|
|
15
14
|
|
|
16
15
|
const mockedNavigate = jest.fn();
|
|
17
16
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -34,6 +33,7 @@ describe('Test ConnectingDevices', () => {
|
|
|
34
33
|
let route;
|
|
35
34
|
|
|
36
35
|
afterEach(() => {
|
|
36
|
+
axios.get.mockClear();
|
|
37
37
|
mockedNavigate.mockClear();
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -62,25 +62,16 @@ describe('Test ConnectingDevices', () => {
|
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test('create with out new sensor', () => {
|
|
66
|
-
act(() => {
|
|
67
|
-
tree = create(wrapComponent({}));
|
|
68
|
-
});
|
|
69
|
-
const instance = tree.root;
|
|
70
|
-
const texts = instance.findAllByType(Text);
|
|
71
|
-
expect(texts).toHaveLength(4);
|
|
72
|
-
expect(texts[0].props.children).toEqual(
|
|
73
|
-
getTranslate('en', 'connecting_your_device')
|
|
74
|
-
);
|
|
75
|
-
expect(texts[1].props.children).toEqual(
|
|
76
|
-
getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
|
|
77
|
-
);
|
|
78
|
-
tree.unmount();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
65
|
test('call setInterval api success', async () => {
|
|
82
66
|
jest.useFakeTimers();
|
|
83
|
-
|
|
67
|
+
const response = {
|
|
68
|
+
status: 200,
|
|
69
|
+
data: {},
|
|
70
|
+
};
|
|
71
|
+
axios.get.mockImplementation(async () => {
|
|
72
|
+
return response;
|
|
73
|
+
});
|
|
74
|
+
|
|
84
75
|
await act(async () => {
|
|
85
76
|
tree = await create(wrapComponent(route));
|
|
86
77
|
});
|
|
@@ -88,6 +79,7 @@ describe('Test ConnectingDevices', () => {
|
|
|
88
79
|
await jest.runOnlyPendingTimers();
|
|
89
80
|
});
|
|
90
81
|
expect(setInterval).toHaveBeenCalled();
|
|
82
|
+
expect(axios.get).toHaveBeenCalledWith(API.SENSOR.CHECK_CONNECTION(1), {});
|
|
91
83
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectDevices, {
|
|
92
84
|
new_sensor: { id: 1 },
|
|
93
85
|
});
|
|
@@ -95,7 +87,14 @@ describe('Test ConnectingDevices', () => {
|
|
|
95
87
|
|
|
96
88
|
test('call setInterval api fail', async () => {
|
|
97
89
|
jest.useFakeTimers();
|
|
98
|
-
|
|
90
|
+
const response = {
|
|
91
|
+
status: 400,
|
|
92
|
+
data: {},
|
|
93
|
+
};
|
|
94
|
+
axios.get.mockImplementation(async () => {
|
|
95
|
+
return response;
|
|
96
|
+
});
|
|
97
|
+
|
|
99
98
|
await act(async () => {
|
|
100
99
|
tree = await create(wrapComponent(route));
|
|
101
100
|
});
|
|
@@ -103,7 +102,8 @@ describe('Test ConnectingDevices', () => {
|
|
|
103
102
|
await jest.runOnlyPendingTimers();
|
|
104
103
|
});
|
|
105
104
|
expect(setInterval).toHaveBeenCalled();
|
|
106
|
-
expect(
|
|
105
|
+
expect(axios.get).toHaveBeenCalledWith(API.SENSOR.CHECK_CONNECTION(1), {});
|
|
106
|
+
expect(mockedNavigate).not.toHaveBeenCalledWith(Routes.ConnectDevices, {
|
|
107
107
|
new_sensor: { id: 1 },
|
|
108
108
|
});
|
|
109
109
|
});
|
|
@@ -23,7 +23,7 @@ const useConnectDevices = (new_sensor, station_id, unit_id) => {
|
|
|
23
23
|
const updateSensorName = useCallback(
|
|
24
24
|
async (name) => {
|
|
25
25
|
const { success: updateSuccess } = await axiosPatch(
|
|
26
|
-
API.
|
|
26
|
+
API.SENSOR.UPDATE_SENSOR(unit_id, station_id, new_sensor.id),
|
|
27
27
|
{
|
|
28
28
|
name,
|
|
29
29
|
}
|
|
@@ -90,7 +90,6 @@ const AddNewDevice = memo(({ route }) => {
|
|
|
90
90
|
<ScrollView
|
|
91
91
|
style={styles.scrollContainer}
|
|
92
92
|
showsVerticalScrollIndicator={false}
|
|
93
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
94
93
|
>
|
|
95
94
|
<Section type={'border'}>
|
|
96
95
|
<GroupCheckBox data={stations} onSelect={handleOnSelect} />
|