@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
|
@@ -109,13 +109,13 @@ const Automate = () => {
|
|
|
109
109
|
const isOwner = owner_unit_id
|
|
110
110
|
? owner_unit_id === idUser
|
|
111
111
|
: type === UNIT_TYPES.MULTI;
|
|
112
|
-
const renderItemAutomate = ({ item
|
|
112
|
+
const renderItemAutomate = ({ item }) => {
|
|
113
113
|
return (
|
|
114
114
|
<ItemOneTap
|
|
115
115
|
isOwner={isOwner}
|
|
116
|
-
automate={
|
|
116
|
+
automate={item}
|
|
117
117
|
wrapSyles={styles.wrapAutomateItem}
|
|
118
|
-
onPressItem={onPressItem(
|
|
118
|
+
onPressItem={onPressItem(item, unit_id, type, isOwner)}
|
|
119
119
|
/>
|
|
120
120
|
);
|
|
121
121
|
};
|
|
@@ -147,7 +147,6 @@ const Automate = () => {
|
|
|
147
147
|
showsHorizontalScrollIndicator={false}
|
|
148
148
|
contentContainerStyle={styles.contentContainerStyle2}
|
|
149
149
|
ListFooterComponent={renderListFooterComponent(type, unit_id)}
|
|
150
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
151
150
|
/>
|
|
152
151
|
</View>
|
|
153
152
|
);
|
|
@@ -190,7 +189,6 @@ const Automate = () => {
|
|
|
190
189
|
contentContainerStyle={styles.contentContainerStyle}
|
|
191
190
|
refreshing={false}
|
|
192
191
|
onRefresh={getAutomates}
|
|
193
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
194
192
|
/>
|
|
195
193
|
</View>
|
|
196
194
|
);
|
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import axios from 'axios';
|
|
3
4
|
|
|
4
5
|
import { SCProvider } from '../../../context';
|
|
5
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
6
7
|
import ConfirmUnitDeletion from '../index';
|
|
7
8
|
import _TextInput from '../../../commons/Form/TextInput';
|
|
8
|
-
import { TouchableOpacity } from 'react-native';
|
|
9
|
-
import { TESTID } from '../../../configs/Constants';
|
|
10
|
-
import API from '../../../configs/API';
|
|
11
|
-
import api from '../../../utils/Apis/axios';
|
|
12
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
13
9
|
|
|
14
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
15
10
|
const wrapComponent = (route, navigation) => (
|
|
16
11
|
<SCProvider initState={mockSCStore({})}>
|
|
17
12
|
<ConfirmUnitDeletion route={route} />
|
|
18
13
|
</SCProvider>
|
|
19
14
|
);
|
|
20
15
|
|
|
21
|
-
const
|
|
22
|
-
|
|
16
|
+
const mockedNavigate = jest.fn();
|
|
17
|
+
|
|
23
18
|
jest.mock('@react-navigation/native', () => {
|
|
24
19
|
return {
|
|
25
20
|
...jest.requireActual('@react-navigation/native'),
|
|
26
21
|
useNavigation: () => ({
|
|
27
|
-
|
|
28
|
-
goBack: mockGoBack,
|
|
22
|
+
goBack: mockedNavigate,
|
|
29
23
|
}),
|
|
30
24
|
};
|
|
31
25
|
});
|
|
32
26
|
|
|
33
|
-
const mockSetState = jest.fn();
|
|
34
27
|
jest.mock('react', () => {
|
|
35
28
|
return {
|
|
36
29
|
...jest.requireActual('react'),
|
|
37
|
-
useState: jest.fn((init) => [init, mockSetState]),
|
|
38
30
|
memo: (x) => x,
|
|
39
31
|
};
|
|
40
32
|
});
|
|
41
33
|
|
|
34
|
+
jest.mock('axios');
|
|
42
35
|
describe('Test ConfirmUnitDeletion', () => {
|
|
43
36
|
let tree;
|
|
44
37
|
let route;
|
|
45
38
|
|
|
46
39
|
beforeAll(() => {
|
|
40
|
+
axios.get.mockClear();
|
|
47
41
|
route = {
|
|
48
42
|
params: {
|
|
49
43
|
unit: {
|
|
@@ -54,36 +48,14 @@ describe('Test ConfirmUnitDeletion', () => {
|
|
|
54
48
|
});
|
|
55
49
|
|
|
56
50
|
test('test render ConfirmUnitDeletion', async () => {
|
|
57
|
-
useState.mockImplementationOnce((init) => ['new_name', mockSetState]);
|
|
58
|
-
await act(async () => {
|
|
59
|
-
tree = await renderer.create(wrapComponent(route));
|
|
60
|
-
});
|
|
61
|
-
const instance = tree.root;
|
|
62
|
-
|
|
63
|
-
const textInput = instance.findByType(_TextInput);
|
|
64
|
-
await act(async () => {
|
|
65
|
-
textInput.props.onChange();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
test('Onpress button ConfirmUnitDeletion ', async () => {
|
|
69
|
-
useState.mockImplementationOnce((init) => ['YES', mockSetState]);
|
|
70
51
|
await act(async () => {
|
|
71
52
|
tree = await renderer.create(wrapComponent(route));
|
|
72
53
|
});
|
|
73
54
|
const instance = tree.root;
|
|
74
55
|
|
|
75
|
-
const touchableOpacity = instance.find(
|
|
76
|
-
(el) =>
|
|
77
|
-
el.props.testID === TESTID.CONFIRM_UNIT_DELETION_BUTTON &&
|
|
78
|
-
el.type === TouchableOpacity
|
|
79
|
-
);
|
|
80
56
|
const textInput = instance.findByType(_TextInput);
|
|
81
57
|
await act(async () => {
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
await act(async () => {
|
|
85
|
-
textInput.props.onChange();
|
|
58
|
+
textInput.props.onChange('new_name');
|
|
86
59
|
});
|
|
87
|
-
mock.onDelete(API.UNIT.MANAGE_UNIT(1)).reply(204);
|
|
88
60
|
});
|
|
89
61
|
});
|
|
@@ -12,7 +12,6 @@ import { Button } from '../../commons';
|
|
|
12
12
|
import Routes from '../../utils/Route';
|
|
13
13
|
import { axiosDelete } from '../../utils/Apis/axios';
|
|
14
14
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
15
|
-
import { TESTID } from '../../configs/Constants';
|
|
16
15
|
|
|
17
16
|
const ConfirmUnitDeletion = ({ route }) => {
|
|
18
17
|
const t = useTranslations();
|
|
@@ -56,12 +55,7 @@ const ConfirmUnitDeletion = ({ route }) => {
|
|
|
56
55
|
textInputStyle={styles.textInput}
|
|
57
56
|
/>
|
|
58
57
|
<View style={styles.buttonWrap}>
|
|
59
|
-
<Button
|
|
60
|
-
type="auth"
|
|
61
|
-
title={t('done')}
|
|
62
|
-
onPress={onSendPress}
|
|
63
|
-
testID={TESTID.CONFIRM_UNIT_DELETION_BUTTON}
|
|
64
|
-
/>
|
|
58
|
+
<Button type="auth" title={t('done')} onPress={onSendPress} />
|
|
65
59
|
</View>
|
|
66
60
|
</WrapHeaderScrollable>
|
|
67
61
|
);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { create, act } from 'react-test-renderer';
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import axios from 'axios';
|
|
6
5
|
import { SCProvider } from '../../../../context';
|
|
7
6
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
7
|
import EditDevice from '..';
|
|
@@ -11,9 +10,6 @@ import _TextInput from '../../../../commons/Form/TextInput';
|
|
|
11
10
|
import { TESTID } from '../../../../configs/Constants';
|
|
12
11
|
import { API } from '../../../../configs';
|
|
13
12
|
import { useRoute } from '@react-navigation/native';
|
|
14
|
-
import api from '../../../../utils/Apis/axios';
|
|
15
|
-
import Toast from 'react-native-toast-message';
|
|
16
|
-
import { getTranslate } from '../../../../utils/I18n';
|
|
17
13
|
|
|
18
14
|
const wrapComponent = (route) => (
|
|
19
15
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -21,8 +17,6 @@ const wrapComponent = (route) => (
|
|
|
21
17
|
</SCProvider>
|
|
22
18
|
);
|
|
23
19
|
|
|
24
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
25
|
-
|
|
26
20
|
jest.mock('react', () => {
|
|
27
21
|
return {
|
|
28
22
|
...jest.requireActual('react'),
|
|
@@ -42,10 +36,14 @@ jest.mock('@react-navigation/native', () => {
|
|
|
42
36
|
};
|
|
43
37
|
});
|
|
44
38
|
|
|
39
|
+
jest.mock('axios');
|
|
40
|
+
|
|
45
41
|
describe('Test EditDevice', () => {
|
|
46
42
|
let tree;
|
|
47
43
|
|
|
48
44
|
beforeEach(() => {
|
|
45
|
+
axios.patch.mockClear();
|
|
46
|
+
axios.delete.mockClear();
|
|
49
47
|
useRoute.mockReturnValue({
|
|
50
48
|
params: {
|
|
51
49
|
sensor: {
|
|
@@ -80,47 +78,23 @@ describe('Test EditDevice', () => {
|
|
|
80
78
|
await act(async () => {
|
|
81
79
|
textInput.props.onChange('new_name');
|
|
82
80
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
await act(async () => {
|
|
92
|
-
tree = await create(wrapComponent());
|
|
93
|
-
});
|
|
94
|
-
const instance = tree.root;
|
|
95
|
-
const alertAction = instance.findByType(AlertAction);
|
|
96
|
-
const buttonRename = instance.findAll(
|
|
97
|
-
(el) =>
|
|
98
|
-
el.props.testID === TESTID.DEVICE_SHOW_RENAME &&
|
|
99
|
-
el.type === TouchableOpacity
|
|
100
|
-
);
|
|
101
|
-
expect(buttonRename).toHaveLength(1);
|
|
102
|
-
await act(async () => {
|
|
103
|
-
await buttonRename[0].props.onPress();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
expect(alertAction.props.visible).toBeTruthy();
|
|
107
|
-
|
|
108
|
-
const textInput = instance.findByType(_TextInput);
|
|
109
|
-
await act(async () => {
|
|
110
|
-
textInput.props.onChange('new_name');
|
|
81
|
+
const response = {
|
|
82
|
+
status: 200,
|
|
83
|
+
data: {
|
|
84
|
+
name: 'new_name',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
axios.patch.mockImplementation(async () => {
|
|
88
|
+
return response;
|
|
111
89
|
});
|
|
112
|
-
mock.onPatch(API.DEVICE.SENSOR_DETAIL(1)).reply(400);
|
|
113
90
|
await act(async () => {
|
|
114
91
|
await alertAction.props.rightButtonClick();
|
|
115
92
|
});
|
|
116
|
-
expect(
|
|
117
|
-
|
|
118
|
-
position: 'bottom',
|
|
119
|
-
text1: getTranslate('en', 'rename_failed'),
|
|
120
|
-
visibilityTime: 1000,
|
|
93
|
+
expect(axios.patch).toHaveBeenCalledWith(API.SENSOR.SENSOR_DETAIL(1), {
|
|
94
|
+
name: 'new_name',
|
|
121
95
|
});
|
|
96
|
+
expect(alertAction.props.visible).toBeFalsy();
|
|
122
97
|
});
|
|
123
|
-
|
|
124
98
|
test('test delete EditDevice', async () => {
|
|
125
99
|
await act(async () => {
|
|
126
100
|
tree = await create(wrapComponent());
|
|
@@ -137,39 +111,16 @@ describe('Test EditDevice', () => {
|
|
|
137
111
|
await buttonDelete[0].props.onPress();
|
|
138
112
|
});
|
|
139
113
|
expect(alertAction.props.visible).toBeTruthy();
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
114
|
+
const response = { status: 204 };
|
|
115
|
+
axios.delete.mockImplementation(async () => {
|
|
116
|
+
return response;
|
|
143
117
|
});
|
|
144
|
-
expect(alertAction.props.visible).toBeFalsy();
|
|
145
|
-
expect(mockPop).toHaveBeenCalled();
|
|
146
|
-
});
|
|
147
118
|
|
|
148
|
-
test('test delete EditDevice failure', async () => {
|
|
149
|
-
await act(async () => {
|
|
150
|
-
tree = await create(wrapComponent());
|
|
151
|
-
});
|
|
152
|
-
const instance = tree.root;
|
|
153
|
-
const alertAction = instance.findByType(AlertAction);
|
|
154
|
-
const buttonDelete = instance.findAll(
|
|
155
|
-
(el) =>
|
|
156
|
-
el.props.testID === TESTID.DEVICE_SHOW_REMOVE &&
|
|
157
|
-
el.type === TouchableOpacity
|
|
158
|
-
);
|
|
159
|
-
expect(buttonDelete).toHaveLength(1);
|
|
160
|
-
await act(async () => {
|
|
161
|
-
await buttonDelete[0].props.onPress();
|
|
162
|
-
});
|
|
163
|
-
expect(alertAction.props.visible).toBeTruthy();
|
|
164
|
-
mock.onDelete(API.DEVICE.SENSOR_DETAIL(1)).reply(400);
|
|
165
119
|
await act(async () => {
|
|
166
120
|
await alertAction.props.rightButtonClick();
|
|
167
121
|
});
|
|
168
|
-
expect(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
text1: getTranslate('en', 'remove_failed'),
|
|
172
|
-
visibilityTime: 1000,
|
|
173
|
-
});
|
|
122
|
+
expect(axios.delete).toHaveBeenCalledWith(API.SENSOR.SENSOR_DETAIL(1));
|
|
123
|
+
expect(alertAction.props.visible).toBeFalsy();
|
|
124
|
+
expect(mockPop).toHaveBeenCalled();
|
|
174
125
|
});
|
|
175
126
|
});
|
|
@@ -30,7 +30,7 @@ const EditDevice = memo(() => {
|
|
|
30
30
|
useEditDevice();
|
|
31
31
|
const renameSensor = useCallback(async () => {
|
|
32
32
|
const { success, data } = await axiosPatch(
|
|
33
|
-
API.
|
|
33
|
+
API.SENSOR.SENSOR_DETAIL(sensor?.id),
|
|
34
34
|
{
|
|
35
35
|
name: inputName,
|
|
36
36
|
}
|
|
@@ -55,7 +55,7 @@ const EditDevice = memo(() => {
|
|
|
55
55
|
|
|
56
56
|
const deleteSensor = useCallback(async () => {
|
|
57
57
|
hideAlertAction();
|
|
58
|
-
const { success } = await axiosDelete(API.
|
|
58
|
+
const { success } = await axiosDelete(API.SENSOR.SENSOR_DETAIL(sensor?.id));
|
|
59
59
|
|
|
60
60
|
if (success) {
|
|
61
61
|
navigation.pop(2);
|
|
@@ -104,22 +104,20 @@ const EditDevice = memo(() => {
|
|
|
104
104
|
/>
|
|
105
105
|
</View>
|
|
106
106
|
</TouchableOpacity>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
<TouchableOpacity
|
|
108
|
+
style={styles.removeButton}
|
|
109
|
+
onPress={onShowDelete(sensor?.name)}
|
|
110
|
+
testID={TESTID.DEVICE_SHOW_REMOVE}
|
|
111
|
+
>
|
|
112
|
+
<Text
|
|
113
|
+
type={'H4'}
|
|
114
|
+
semibold
|
|
115
|
+
color={Colors.Red}
|
|
116
|
+
style={styles.removeBorderBottom}
|
|
112
117
|
>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
color={Colors.Red}
|
|
117
|
-
style={styles.removeBorderBottom}
|
|
118
|
-
>
|
|
119
|
-
{t('remove_device')}
|
|
120
|
-
</Text>
|
|
121
|
-
</TouchableOpacity>
|
|
122
|
-
)}
|
|
118
|
+
{t('remove_device')}
|
|
119
|
+
</Text>
|
|
120
|
+
</TouchableOpacity>
|
|
123
121
|
</View>
|
|
124
122
|
<AlertAction
|
|
125
123
|
visible={stateAlertAction.visible}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Alert, ScrollView } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
-
|
|
6
4
|
import DeviceDetail from '../detail';
|
|
5
|
+
import axios from 'axios';
|
|
7
6
|
import { API } from '../../../configs';
|
|
8
7
|
import { AlertSendConfirm } from '../../../commons/EmergencyButton/AlertSendConfirm';
|
|
9
8
|
import { AlertSent } from '../../../commons/EmergencyButton/AlertSent';
|
|
@@ -11,18 +10,18 @@ import { AlertAction, ButtonPopup, MenuActionMore } from '../../../commons';
|
|
|
11
10
|
import { TESTID } from '../../../configs/Constants';
|
|
12
11
|
import Text from '../../../commons/Text';
|
|
13
12
|
import { IconFill } from '@ant-design/icons-react-native';
|
|
13
|
+
// import CurrentRainSensor from 'components/Device/RainningSensor/CurrentRainSensor';
|
|
14
14
|
import CurrentRainSensor from '../../../commons/Device/RainningSensor/CurrentRainSensor';
|
|
15
15
|
import { ConnectedViewHeader } from '../../../commons/Device';
|
|
16
16
|
import { getTranslate } from '../../../utils/I18n';
|
|
17
17
|
import { SCProvider } from '../../../context';
|
|
18
18
|
import { mockSCStore } from '../../../context/mockStore';
|
|
19
19
|
import Routes from '../../../utils/Route';
|
|
20
|
-
import api from '../../../utils/Apis/axios';
|
|
21
20
|
|
|
22
21
|
const mockedNavigate = jest.fn();
|
|
23
22
|
const mockedDispatch = jest.fn();
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
jest.mock('axios');
|
|
26
25
|
|
|
27
26
|
jest.mock('@react-navigation/native', () => {
|
|
28
27
|
return {
|
|
@@ -50,31 +49,30 @@ jest.mock('react', () => ({
|
|
|
50
49
|
memo: (x) => x,
|
|
51
50
|
}));
|
|
52
51
|
|
|
53
|
-
jest.mock('../../../hooks/Common', () => {
|
|
54
|
-
return {
|
|
55
|
-
...jest.requireActual('../../../hooks/Common'),
|
|
56
|
-
useGGHomeDeviceConnected: () => ({ isConnected: true }),
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
52
|
const mockAxios = (
|
|
61
53
|
responseDisplay,
|
|
62
54
|
responseDisplayValueV2,
|
|
63
55
|
responseRemoteControl = {}
|
|
64
56
|
) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
axios.get.mockImplementation((url) => {
|
|
58
|
+
if (url === API.SENSOR.DISPLAY(1)) {
|
|
59
|
+
return responseDisplay;
|
|
60
|
+
} else if (url === API.SENSOR.REMOTE_CONTROL_OPTIONS(1)) {
|
|
61
|
+
return responseRemoteControl;
|
|
62
|
+
} else if (url === API.SENSOR.DISPLAY_VALUES_V2(1)) {
|
|
63
|
+
return responseDisplayValueV2;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
status: 200,
|
|
67
|
+
data: {},
|
|
68
|
+
};
|
|
69
|
+
});
|
|
72
70
|
};
|
|
73
71
|
|
|
74
72
|
let store = mockSCStore({});
|
|
75
73
|
|
|
76
|
-
const wrapComponent = (
|
|
77
|
-
<SCProvider initState={
|
|
74
|
+
const wrapComponent = (store, account, route) => (
|
|
75
|
+
<SCProvider initState={store}>
|
|
78
76
|
<DeviceDetail account={account} route={route} />
|
|
79
77
|
</SCProvider>
|
|
80
78
|
);
|
|
@@ -107,7 +105,6 @@ describe('test DeviceDetail', () => {
|
|
|
107
105
|
is_managed_by_backend: true,
|
|
108
106
|
station: { id: 2, name: 'Station name' },
|
|
109
107
|
name: 'Sensor name',
|
|
110
|
-
chip_id: 1,
|
|
111
108
|
},
|
|
112
109
|
title: 'Button',
|
|
113
110
|
},
|
|
@@ -119,6 +116,8 @@ describe('test DeviceDetail', () => {
|
|
|
119
116
|
const setState = jest.fn();
|
|
120
117
|
const useLayoutEffectSpy = jest.spyOn(React, 'useLayoutEffect');
|
|
121
118
|
useLayoutEffectSpy.mockImplementation(() => setState);
|
|
119
|
+
axios.get.mockClear();
|
|
120
|
+
axios.post.mockClear();
|
|
122
121
|
});
|
|
123
122
|
|
|
124
123
|
afterEach(() => {
|
|
@@ -193,7 +192,6 @@ describe('test DeviceDetail', () => {
|
|
|
193
192
|
type: 'action',
|
|
194
193
|
},
|
|
195
194
|
],
|
|
196
|
-
side_menu_items: [{ id: 1, order: 1, name: 'Setup generate passcode' }],
|
|
197
195
|
};
|
|
198
196
|
test('render DeviceDetail render SensorDisplayItem', async () => {
|
|
199
197
|
const responseDisplay = {
|
|
@@ -227,6 +225,12 @@ describe('test DeviceDetail', () => {
|
|
|
227
225
|
tree = await create(wrapComponent(store, account, route));
|
|
228
226
|
});
|
|
229
227
|
const instance = tree.root;
|
|
228
|
+
expect(axios.get).toHaveBeenCalledTimes(4);
|
|
229
|
+
expect(axios.get).toHaveBeenCalledWith(API.SENSOR.DISPLAY(1), {});
|
|
230
|
+
expect(axios.get).toHaveBeenCalledWith(
|
|
231
|
+
API.SENSOR.REMOTE_CONTROL_OPTIONS(1),
|
|
232
|
+
{}
|
|
233
|
+
);
|
|
230
234
|
const sensorDisplayItem = instance.findAll(
|
|
231
235
|
(el) => el.props.testID === TESTID.SENSOR_DISPLAY_ITEM
|
|
232
236
|
);
|
|
@@ -243,18 +247,38 @@ describe('test DeviceDetail', () => {
|
|
|
243
247
|
await act(async () => {
|
|
244
248
|
await button1.props.onPress();
|
|
245
249
|
});
|
|
250
|
+
expect(axios.post).toHaveBeenCalledWith(API.SENSOR.QUICK_ACTION(1), {
|
|
251
|
+
key: responseDisplay.data.items[1].configuration.configuration.action1,
|
|
252
|
+
data: null,
|
|
253
|
+
source: 'internet',
|
|
254
|
+
action_name: undefined,
|
|
255
|
+
});
|
|
256
|
+
|
|
246
257
|
const button2 = instance.find(
|
|
247
258
|
(el) => el.props.testID === TESTID.BUTTON_TEMPLATE_2
|
|
248
259
|
);
|
|
249
260
|
await act(async () => {
|
|
250
261
|
await button2.props.onPress();
|
|
251
262
|
});
|
|
263
|
+
expect(axios.post).toHaveBeenCalledWith(API.SENSOR.QUICK_ACTION(1), {
|
|
264
|
+
key: responseDisplay.data.items[1].configuration.configuration.action2,
|
|
265
|
+
data: null,
|
|
266
|
+
source: 'internet',
|
|
267
|
+
action_name: undefined,
|
|
268
|
+
});
|
|
269
|
+
|
|
252
270
|
const button3 = instance.find(
|
|
253
271
|
(el) => el.props.testID === TESTID.BUTTON_TEMPLATE_3
|
|
254
272
|
);
|
|
255
273
|
await act(async () => {
|
|
256
274
|
await button3.props.onPress();
|
|
257
275
|
});
|
|
276
|
+
expect(axios.post).toHaveBeenCalledWith(API.SENSOR.QUICK_ACTION(1), {
|
|
277
|
+
key: responseDisplay.data.items[1].configuration.configuration.action3,
|
|
278
|
+
data: null,
|
|
279
|
+
source: 'internet',
|
|
280
|
+
action_name: undefined,
|
|
281
|
+
});
|
|
258
282
|
});
|
|
259
283
|
|
|
260
284
|
test('AlertSendConfirm onSendNowAlert', async () => {
|
|
@@ -272,6 +296,10 @@ describe('test DeviceDetail', () => {
|
|
|
272
296
|
minutes: 0,
|
|
273
297
|
seconds: 5,
|
|
274
298
|
});
|
|
299
|
+
|
|
300
|
+
axios.post.mockImplementation(async () => {
|
|
301
|
+
return { status: 200 };
|
|
302
|
+
});
|
|
275
303
|
await act(async () => {
|
|
276
304
|
await alertSendConfirm.props.onSendNowAlert();
|
|
277
305
|
});
|
|
@@ -279,7 +307,7 @@ describe('test DeviceDetail', () => {
|
|
|
279
307
|
await alertSendConfirm.props.onHide();
|
|
280
308
|
});
|
|
281
309
|
expect(alertSendConfirm.props.showAlertConfirm).toEqual(false);
|
|
282
|
-
expect(alertSent.props.showAlertSent).toEqual(
|
|
310
|
+
expect(alertSent.props.showAlertSent).toEqual(true);
|
|
283
311
|
});
|
|
284
312
|
|
|
285
313
|
test('ButtonPopup onClick', async () => {
|
|
@@ -294,12 +322,16 @@ describe('test DeviceDetail', () => {
|
|
|
294
322
|
);
|
|
295
323
|
const alertAction = instance.findByType(AlertAction);
|
|
296
324
|
expect(buttonPopup.props.visible).toEqual(false);
|
|
325
|
+
|
|
326
|
+
axios.put.mockImplementationOnce(async () => {
|
|
327
|
+
return { status: 200 };
|
|
328
|
+
});
|
|
297
329
|
await act(async () => {
|
|
298
330
|
await alertAction.props.rightButtonClick();
|
|
299
331
|
await alertAction.props.onHide();
|
|
300
332
|
});
|
|
301
333
|
|
|
302
|
-
expect(buttonPopup.props.visible).toEqual(
|
|
334
|
+
expect(buttonPopup.props.visible).toEqual(true);
|
|
303
335
|
expect(buttonPopup.props.mainTitle).toEqual(getTranslate('en', 'ok'));
|
|
304
336
|
await act(async () => {
|
|
305
337
|
await buttonPopup.props.onPressMain();
|
|
@@ -338,10 +370,11 @@ describe('test DeviceDetail', () => {
|
|
|
338
370
|
const instance = tree.root;
|
|
339
371
|
const scrollView = instance.findByType(ScrollView);
|
|
340
372
|
const refreshControl = scrollView.props.refreshControl;
|
|
373
|
+
expect(axios.get).toHaveBeenCalledTimes(5);
|
|
341
374
|
await act(async () => {
|
|
342
375
|
refreshControl.props.onRefresh();
|
|
343
376
|
});
|
|
344
|
-
expect(
|
|
377
|
+
expect(axios.get).toHaveBeenCalledTimes(7);
|
|
345
378
|
});
|
|
346
379
|
|
|
347
380
|
test('Should render SensorDisplayItem', async () => {
|
|
@@ -599,14 +632,12 @@ describe('test DeviceDetail', () => {
|
|
|
599
632
|
|
|
600
633
|
test('not fetch value if not managed by backend', async () => {
|
|
601
634
|
route.params.sensorData.is_managed_by_backend = false;
|
|
635
|
+
|
|
602
636
|
await act(async () => {
|
|
603
637
|
tree = await create(wrapComponent(store, account, route));
|
|
604
638
|
});
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
(el) => el.props.testID === TESTID.SENSOR_DISPLAY_ITEM
|
|
608
|
-
);
|
|
609
|
-
expect(sensorDisplayItem).toHaveLength(0);
|
|
639
|
+
|
|
640
|
+
expect(axios.get).not.toBeCalledWith(API.SENSOR.DISPLAY_VALUES_V2(1));
|
|
610
641
|
});
|
|
611
642
|
|
|
612
643
|
test('render CurrentRainSensor but is other device', async () => {
|
|
@@ -680,6 +711,8 @@ describe('test DeviceDetail', () => {
|
|
|
680
711
|
});
|
|
681
712
|
|
|
682
713
|
test('Add device to Favourites', async () => {
|
|
714
|
+
const unit_id = route.params.unitData.id;
|
|
715
|
+
const station_id = route.params.station.id;
|
|
683
716
|
const sensor = route.params.sensorData;
|
|
684
717
|
sensor.is_favourite = false;
|
|
685
718
|
|
|
@@ -687,16 +720,27 @@ describe('test DeviceDetail', () => {
|
|
|
687
720
|
tree = await create(wrapComponent(store, account, route));
|
|
688
721
|
});
|
|
689
722
|
const instance = tree.root;
|
|
690
|
-
|
|
723
|
+
|
|
724
|
+
const response = {
|
|
725
|
+
status: 200,
|
|
726
|
+
};
|
|
727
|
+
axios.post.mockImplementation(async () => {
|
|
728
|
+
return response;
|
|
729
|
+
});
|
|
691
730
|
const buttonStar = instance.find(
|
|
692
731
|
(el) => el.props.testID === TESTID.HEADER_DEVICE_BUTTON_STAR
|
|
693
732
|
);
|
|
694
733
|
await act(async () => {
|
|
695
734
|
await buttonStar.props.onPress();
|
|
696
735
|
});
|
|
736
|
+
expect(axios.post).toHaveBeenCalledWith(
|
|
737
|
+
API.SENSOR.ADD_TO_FAVOURITES(unit_id, station_id, sensor.id)
|
|
738
|
+
);
|
|
697
739
|
});
|
|
698
740
|
|
|
699
741
|
test('Remove device from Favourites', async () => {
|
|
742
|
+
const unit_id = route.params.unitData.id;
|
|
743
|
+
const station_id = route.params.station.id;
|
|
700
744
|
const sensor = route.params.sensorData;
|
|
701
745
|
store.unit.favoriteDeviceIds = [sensor.id];
|
|
702
746
|
|
|
@@ -704,7 +748,13 @@ describe('test DeviceDetail', () => {
|
|
|
704
748
|
tree = await create(wrapComponent(store, account, route));
|
|
705
749
|
});
|
|
706
750
|
const instance = tree.root;
|
|
707
|
-
|
|
751
|
+
|
|
752
|
+
const response = {
|
|
753
|
+
status: 200,
|
|
754
|
+
};
|
|
755
|
+
axios.post.mockImplementation(async () => {
|
|
756
|
+
return response;
|
|
757
|
+
});
|
|
708
758
|
|
|
709
759
|
const buttonStar = instance.find(
|
|
710
760
|
(el) => el.props.testID === TESTID.HEADER_DEVICE_BUTTON_STAR
|
|
@@ -712,6 +762,9 @@ describe('test DeviceDetail', () => {
|
|
|
712
762
|
await act(async () => {
|
|
713
763
|
await buttonStar.props.onPress();
|
|
714
764
|
});
|
|
765
|
+
expect(axios.post).toHaveBeenCalledWith(
|
|
766
|
+
API.SENSOR.REMOVE_FROM_FAVOURITES(unit_id, station_id, sensor.id)
|
|
767
|
+
);
|
|
715
768
|
});
|
|
716
769
|
|
|
717
770
|
test('Go to ActivityLog', async () => {
|
|
@@ -794,6 +847,6 @@ describe('test DeviceDetail', () => {
|
|
|
794
847
|
await act(async () => {
|
|
795
848
|
await create(wrapComponent(store, account, route));
|
|
796
849
|
});
|
|
797
|
-
expect(mockAlertShow).
|
|
850
|
+
expect(mockAlertShow).toBeCalled();
|
|
798
851
|
});
|
|
799
852
|
});
|
|
@@ -20,7 +20,7 @@ export const DetailHistoryChart = ({ item, sensor }) => {
|
|
|
20
20
|
params.append('date_from', startDate / 1000);
|
|
21
21
|
params.append('date_to', endDate / 1000);
|
|
22
22
|
const { success, data } = await axiosGet(
|
|
23
|
-
API.
|
|
23
|
+
API.SENSOR.DISPLAY_HISTORY(sensor.id),
|
|
24
24
|
{ params }
|
|
25
25
|
);
|
|
26
26
|
if (success) {
|