@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,8 +1,8 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { create, act } from 'react-test-renderer';
|
|
3
4
|
import moment from 'moment';
|
|
4
5
|
import { useNavigation } from '@react-navigation/native';
|
|
5
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
6
6
|
|
|
7
7
|
import SharedUnit from '../SharedUnit';
|
|
8
8
|
import { TESTID } from '../../../configs/Constants';
|
|
@@ -10,9 +10,8 @@ import { API } from '../../../configs';
|
|
|
10
10
|
import Routes from '../../../utils/Route';
|
|
11
11
|
import { SCProvider } from '../../../context';
|
|
12
12
|
import { mockSCStore } from '../../../context/mockStore';
|
|
13
|
-
import api from '../../../utils/Apis/axios';
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
jest.mock('axios');
|
|
16
15
|
|
|
17
16
|
const mockNavigate = jest.fn();
|
|
18
17
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -39,6 +38,8 @@ describe('Test SharedUnit', () => {
|
|
|
39
38
|
let tree, item, unit;
|
|
40
39
|
|
|
41
40
|
beforeEach(() => {
|
|
41
|
+
axios.post.mockClear();
|
|
42
|
+
|
|
42
43
|
unit = {
|
|
43
44
|
background: '',
|
|
44
45
|
icon: '',
|
|
@@ -60,12 +61,6 @@ describe('Test SharedUnit', () => {
|
|
|
60
61
|
|
|
61
62
|
test('test create SharedUnit unit is not pin, not star', async () => {
|
|
62
63
|
const navigation = useNavigation();
|
|
63
|
-
const mockedRenewItem = jest.fn();
|
|
64
|
-
await act(async () => {
|
|
65
|
-
tree = await create(
|
|
66
|
-
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
64
|
|
|
70
65
|
await act(async () => {
|
|
71
66
|
tree = await create(wrapComponent(item, navigation));
|
|
@@ -77,39 +72,34 @@ describe('Test SharedUnit', () => {
|
|
|
77
72
|
act(() => {
|
|
78
73
|
touchSharedUnit.props.onPress();
|
|
79
74
|
});
|
|
75
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
76
|
+
screen: Routes.UnitDetail,
|
|
77
|
+
params: {
|
|
78
|
+
unitId: 3,
|
|
79
|
+
unitData: unit,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
80
83
|
const iconRemovePinSharedUnit = instance.findAll(
|
|
81
84
|
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
82
85
|
);
|
|
86
|
+
expect(iconRemovePinSharedUnit).toHaveLength(0);
|
|
87
|
+
|
|
83
88
|
const iconAddPinSharedUnit = instance.find(
|
|
84
89
|
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
85
90
|
);
|
|
86
|
-
mock.onPost(API.UNIT.PIN_UNIT(3)).reply(200);
|
|
87
|
-
act(() => {
|
|
88
|
-
iconAddPinSharedUnit.props.onPress();
|
|
89
|
-
});
|
|
90
|
-
mock.onPost(API.UNIT.PIN_UNIT(3)).reply(400);
|
|
91
91
|
act(() => {
|
|
92
92
|
iconAddPinSharedUnit.props.onPress();
|
|
93
93
|
});
|
|
94
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.PIN_UNIT(3));
|
|
95
|
+
|
|
94
96
|
const iconAddStarSharedUnit = instance.find(
|
|
95
97
|
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
96
98
|
);
|
|
97
|
-
mock.onPost(API.UNIT.STAR_UNIT(3)).reply(200);
|
|
98
99
|
act(() => {
|
|
99
100
|
iconAddStarSharedUnit.props.onPress();
|
|
100
101
|
});
|
|
101
|
-
|
|
102
|
-
act(() => {
|
|
103
|
-
iconAddStarSharedUnit.props.onPress();
|
|
104
|
-
});
|
|
105
|
-
expect(iconRemovePinSharedUnit).toHaveLength(0);
|
|
106
|
-
expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
107
|
-
screen: Routes.UnitDetail,
|
|
108
|
-
params: {
|
|
109
|
-
unitId: 3,
|
|
110
|
-
unitData: unit,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
102
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.STAR_UNIT(3));
|
|
113
103
|
});
|
|
114
104
|
|
|
115
105
|
test('test create SharedUnit unit without unit owner', async () => {
|
|
@@ -158,28 +148,183 @@ describe('Test SharedUnit', () => {
|
|
|
158
148
|
const iconRemovePinSharedUnit = instance.find(
|
|
159
149
|
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
160
150
|
);
|
|
161
|
-
mock.onPost(API.UNIT.UNPIN_UNIT(3)).reply(200);
|
|
162
|
-
act(() => {
|
|
163
|
-
iconRemovePinSharedUnit.props.onPress();
|
|
164
|
-
});
|
|
165
|
-
mock.onPost(API.UNIT.UNPIN_UNIT(3)).reply(400);
|
|
166
151
|
act(() => {
|
|
167
152
|
iconRemovePinSharedUnit.props.onPress();
|
|
168
153
|
});
|
|
154
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.UNPIN_UNIT(3));
|
|
155
|
+
|
|
169
156
|
const iconRemoveStarSharedUnit = instance.find(
|
|
170
157
|
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
171
158
|
);
|
|
172
|
-
mock.onPost(API.UNIT.UNSTAR_UNIT(3)).reply(200);
|
|
173
159
|
act(() => {
|
|
174
160
|
iconRemoveStarSharedUnit.props.onPress();
|
|
175
161
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
162
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.UNSTAR_UNIT(3));
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('test pin SharedUnit success', async () => {
|
|
166
|
+
const navigation = useNavigation();
|
|
167
|
+
const mockedRenewItem = jest.fn();
|
|
168
|
+
await act(async () => {
|
|
169
|
+
tree = await create(
|
|
170
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
const instance = tree.root;
|
|
174
|
+
|
|
175
|
+
const response = {
|
|
176
|
+
success: true,
|
|
177
|
+
status: 200,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
181
|
+
return response;
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const iconAddPinSharedUnit = instance.find(
|
|
185
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const iconStarUnit = instance.find(
|
|
189
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
await act(async () => {
|
|
193
|
+
await iconAddPinSharedUnit.props.onPress();
|
|
194
|
+
await iconStarUnit.props.onPress();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(2);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('test pin SharedUnit unsuccess', async () => {
|
|
201
|
+
const navigation = useNavigation();
|
|
202
|
+
const mockedRenewItem = jest.fn();
|
|
203
|
+
await act(async () => {
|
|
204
|
+
tree = await create(
|
|
205
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
const instance = tree.root;
|
|
209
|
+
|
|
210
|
+
const response = {
|
|
211
|
+
success: false,
|
|
212
|
+
status: 500,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
216
|
+
return response;
|
|
179
217
|
});
|
|
180
|
-
|
|
218
|
+
|
|
219
|
+
const iconAddPinSharedUnit = instance.find(
|
|
220
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const iconStarUnit = instance.find(
|
|
224
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
await act(async () => {
|
|
228
|
+
await iconAddPinSharedUnit.props.onPress();
|
|
229
|
+
await iconStarUnit.props.onPress();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const iconRemovePinSharedUnit = instance.findAll(
|
|
233
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const iconRemoveStartUnit = instance.findAll(
|
|
237
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(0);
|
|
241
|
+
expect(iconRemovePinSharedUnit).toHaveLength(0);
|
|
242
|
+
expect(iconRemoveStartUnit).toHaveLength(0);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('test unpin SharedUnit success', async () => {
|
|
246
|
+
const navigation = useNavigation();
|
|
247
|
+
item.is_pin = true;
|
|
248
|
+
item.is_star = true;
|
|
249
|
+
const mockedRenewItem = jest.fn();
|
|
250
|
+
|
|
251
|
+
await act(async () => {
|
|
252
|
+
tree = await create(
|
|
253
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
const instance = tree.root;
|
|
257
|
+
|
|
258
|
+
const response = {
|
|
259
|
+
success: true,
|
|
260
|
+
status: 200,
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
264
|
+
return response;
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const iconRemovePinSharedUnit = instance.find(
|
|
268
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const iconRemoveStartUnit = instance.find(
|
|
181
272
|
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
182
273
|
);
|
|
183
|
-
|
|
274
|
+
|
|
275
|
+
await act(async () => {
|
|
276
|
+
await iconRemovePinSharedUnit.props.onPress();
|
|
277
|
+
await iconRemoveStartUnit.props.onPress();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(2);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('test unpin SharedUnit unsuccess', async () => {
|
|
284
|
+
const navigation = useNavigation();
|
|
285
|
+
item.is_pin = true;
|
|
286
|
+
item.is_star = true;
|
|
287
|
+
const mockedRenewItem = jest.fn();
|
|
288
|
+
|
|
289
|
+
await act(async () => {
|
|
290
|
+
tree = await create(
|
|
291
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
const instance = tree.root;
|
|
295
|
+
|
|
296
|
+
const response = {
|
|
297
|
+
success: false,
|
|
298
|
+
status: 500,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
302
|
+
return response;
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
const iconRemovePinSharedUnit = instance.find(
|
|
306
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
const iconRemoveStartUnit = instance.find(
|
|
310
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
await act(async () => {
|
|
314
|
+
await iconRemovePinSharedUnit.props.onPress();
|
|
315
|
+
await iconRemoveStartUnit.props.onPress();
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
const iconAddPinSharedUnit = instance.findAll(
|
|
319
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const iconStarUnit = instance.findAll(
|
|
323
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(0);
|
|
327
|
+
expect(iconAddPinSharedUnit).toHaveLength(0);
|
|
328
|
+
expect(iconStarUnit).toHaveLength(0);
|
|
184
329
|
});
|
|
185
330
|
});
|
|
@@ -4,7 +4,6 @@ import moment from 'moment';
|
|
|
4
4
|
import { API } from '../../../configs';
|
|
5
5
|
import HistoryChart from '../../../commons/Device/HistoryChart';
|
|
6
6
|
import { axiosGet } from '../../../utils/Apis/axios';
|
|
7
|
-
import { updateConfigChart } from '../ConfigHistoryChart';
|
|
8
7
|
|
|
9
8
|
export const dateTimeType = {
|
|
10
9
|
date: 'date',
|
|
@@ -31,7 +30,19 @@ const ConfigHistoryChart = memo(({ configs }) => {
|
|
|
31
30
|
const { success, data } = await axiosGet(API.CONFIG.DISPLAY_HISTORY(), {
|
|
32
31
|
params,
|
|
33
32
|
});
|
|
34
|
-
|
|
33
|
+
if (success) {
|
|
34
|
+
for (let i = 0; i < data.length; i++) {
|
|
35
|
+
for (let j = 0; j < data[i].data.length; j++) {
|
|
36
|
+
data[i].data[j].x = moment(data[i].data[j].x).toDate();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setChartData(
|
|
40
|
+
configuration.map((config) => {
|
|
41
|
+
config.data = data.find((k) => k.config === config.id).data;
|
|
42
|
+
return config;
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
35
46
|
};
|
|
36
47
|
fetchData();
|
|
37
48
|
}, [startDate, endDate, configs]);
|
|
@@ -11,27 +11,6 @@ export const dateTimeType = {
|
|
|
11
11
|
dateTime: 'datetime',
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const updateConfigChart = (
|
|
15
|
-
success,
|
|
16
|
-
data,
|
|
17
|
-
configuration,
|
|
18
|
-
setChartData
|
|
19
|
-
) => {
|
|
20
|
-
if (success) {
|
|
21
|
-
for (let i = 0; i < data.length; i++) {
|
|
22
|
-
for (let j = 0; j < data[i].data.length; j++) {
|
|
23
|
-
data[i].data[j].x = moment(data[i].data[j].x).toDate();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
setChartData(
|
|
27
|
-
configuration.map((config) => {
|
|
28
|
-
config.data = data.find((k) => k.config === config.id).data;
|
|
29
|
-
return config;
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
14
|
const ConfigHistoryChart = memo(({ configs }) => {
|
|
36
15
|
const [chartData, setChartData] = useState(configs);
|
|
37
16
|
const [startDate, setStartDate] = useState(moment().subtract(1, 'days'));
|
|
@@ -49,7 +28,19 @@ const ConfigHistoryChart = memo(({ configs }) => {
|
|
|
49
28
|
const { success, data } = await axiosGet(API.CONFIG.DISPLAY_HISTORY(), {
|
|
50
29
|
params,
|
|
51
30
|
});
|
|
52
|
-
|
|
31
|
+
if (success) {
|
|
32
|
+
for (let i = 0; i < data.length; i++) {
|
|
33
|
+
for (let j = 0; j < data[i].data.length; j++) {
|
|
34
|
+
data[i].data[j].x = moment(data[i].data[j].x).toDate();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setChartData(
|
|
38
|
+
configuration.map((config) => {
|
|
39
|
+
config.data = data.find((k) => k.config === config.id).data;
|
|
40
|
+
return config;
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
}
|
|
53
44
|
};
|
|
54
45
|
fetchData();
|
|
55
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -40,12 +40,12 @@ const WheelDateTimePicker = ({
|
|
|
40
40
|
const date = moment(defaultValue);
|
|
41
41
|
const maximumDate = moment(date).add(15, 'days');
|
|
42
42
|
const minimumDate = moment(date).add(-15, 'days');
|
|
43
|
-
const [
|
|
43
|
+
const [dateData, indexDate] =
|
|
44
44
|
mode === 'datetime'
|
|
45
45
|
? getDateData(date, maximumDate, minimumDate)
|
|
46
46
|
: [[{ value: date }], 0];
|
|
47
47
|
return {
|
|
48
|
-
dateData:
|
|
48
|
+
dateData: dateData,
|
|
49
49
|
indexInitialDate: indexDate,
|
|
50
50
|
indexInitialHour: date.hour(),
|
|
51
51
|
indexInitialMinute: date.minute(),
|
|
@@ -104,7 +104,6 @@ const WheelDateTimePicker = ({
|
|
|
104
104
|
|
|
105
105
|
return (
|
|
106
106
|
<BottomSheet
|
|
107
|
-
testID={TESTID.WHEEL_DATE_TIME_PICKER}
|
|
108
107
|
isVisible={isVisible}
|
|
109
108
|
onBackdropPress={onPickerCancel}
|
|
110
109
|
onHide={onHide}
|
|
@@ -174,7 +173,7 @@ const WheelDateTimePicker = ({
|
|
|
174
173
|
onLeftClick={onPickerCancel}
|
|
175
174
|
rightTitle={t('done')}
|
|
176
175
|
onRightClick={onDone}
|
|
177
|
-
testIDPrefix={TESTID.
|
|
176
|
+
testIDPrefix={TESTID.WHEEL_DATE_TIME_PICKER}
|
|
178
177
|
/>
|
|
179
178
|
</BottomSheet>
|
|
180
179
|
);
|