@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
|
@@ -56,7 +56,7 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
56
56
|
const { setAction } = useContext(SCContext);
|
|
57
57
|
|
|
58
58
|
const getPermissionWifiAndroid = useCallback(async () => {
|
|
59
|
-
|
|
59
|
+
const granted = await PermissionsAndroid.request(
|
|
60
60
|
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
|
|
61
61
|
{
|
|
62
62
|
title: t('location_permission_required_wifi_title'),
|
|
@@ -65,21 +65,15 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
65
65
|
buttonPositive: t('allow'),
|
|
66
66
|
}
|
|
67
67
|
);
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
69
|
+
ToastBottomHelper.success('GRANTED');
|
|
70
|
+
} else {
|
|
71
|
+
ToastBottomHelper.error('DENIED');
|
|
72
|
+
}
|
|
73
|
+
}, [t]);
|
|
70
74
|
|
|
71
75
|
useEffect(() => {
|
|
72
|
-
|
|
73
|
-
(async () => {
|
|
74
|
-
const granted = await getPermissionWifiAndroid();
|
|
75
|
-
if (!granted) {
|
|
76
|
-
ToastBottomHelper.error(
|
|
77
|
-
'Fail permission',
|
|
78
|
-
'You need to grant permission to continue'
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
})();
|
|
82
|
-
}
|
|
76
|
+
isAndroid && getPermissionWifiAndroid();
|
|
83
77
|
}, [getPermissionWifiAndroid]);
|
|
84
78
|
|
|
85
79
|
const handleSend = async () => {
|
|
@@ -89,7 +83,7 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
89
83
|
await socket.on('message', (msg, rinfo) => {
|
|
90
84
|
clearInterval(intervalSend);
|
|
91
85
|
const data = JSON.parse(msg.toString());
|
|
92
|
-
if (
|
|
86
|
+
if (data.hasOwnProperty('wifi')) {
|
|
93
87
|
navigate(Routes.GatewayWifiList, {
|
|
94
88
|
list_wifi: data.wifi,
|
|
95
89
|
unit_id: unit_id,
|
|
@@ -119,12 +113,12 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
119
113
|
goBack();
|
|
120
114
|
});
|
|
121
115
|
} else {
|
|
122
|
-
const
|
|
116
|
+
const socket = dgram.createSocket({ type: 'udp4' });
|
|
123
117
|
await setIsPercentConnect(1);
|
|
124
|
-
await
|
|
125
|
-
await
|
|
118
|
+
await socket.bind(54321);
|
|
119
|
+
await socket.on('message', (msg, rinfo) => {
|
|
126
120
|
const data = JSON.parse(msg.toString());
|
|
127
|
-
if (
|
|
121
|
+
if (data.hasOwnProperty('wifi')) {
|
|
128
122
|
navigate(Routes.GatewayWifiList, {
|
|
129
123
|
list_wifi: data.wifi,
|
|
130
124
|
unit_id: unit_id,
|
|
@@ -134,12 +128,12 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
134
128
|
wifi_pass: wifi_pass,
|
|
135
129
|
unit_name: unit_name,
|
|
136
130
|
devicePrefixName: devicePrefixName,
|
|
137
|
-
socket:
|
|
131
|
+
socket: socket,
|
|
138
132
|
});
|
|
139
133
|
}
|
|
140
134
|
});
|
|
141
|
-
await
|
|
142
|
-
await
|
|
135
|
+
await socket.once('listening', async () => {
|
|
136
|
+
await socket.send(
|
|
143
137
|
JSON.stringify({ type: 'scan', data: { wifi: '' } }),
|
|
144
138
|
undefined,
|
|
145
139
|
undefined,
|
|
@@ -148,7 +142,7 @@ const ConnectWifiWarning = memo(({ route }) => {
|
|
|
148
142
|
undefined
|
|
149
143
|
);
|
|
150
144
|
});
|
|
151
|
-
|
|
145
|
+
socket.on('error', () => {
|
|
152
146
|
ToastBottomHelper.error(t('server_error'));
|
|
153
147
|
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
154
148
|
goBack();
|
|
@@ -60,8 +60,8 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const onPasswordChange = useCallback(
|
|
63
|
-
(
|
|
64
|
-
setPassword(
|
|
63
|
+
(password) => {
|
|
64
|
+
setPassword(password?.toString());
|
|
65
65
|
},
|
|
66
66
|
[setPassword]
|
|
67
67
|
);
|
|
@@ -69,7 +69,7 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
69
69
|
const handleSocketOnMsg = useCallback(
|
|
70
70
|
(msg) => {
|
|
71
71
|
const data = JSON.parse(msg.toString());
|
|
72
|
-
if (
|
|
72
|
+
if (data.hasOwnProperty('gateway')) {
|
|
73
73
|
const checkWifiInterval = setInterval(() => {
|
|
74
74
|
// eslint-disable-next-line promise/prefer-await-to-then
|
|
75
75
|
WifiManager.getCurrentWifiSSID().then((ssid) => {
|
|
@@ -224,10 +224,7 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
224
224
|
{t('select_wifi')}
|
|
225
225
|
</Text>
|
|
226
226
|
|
|
227
|
-
<ScrollView
|
|
228
|
-
style={styles.listContainer}
|
|
229
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
230
|
-
>
|
|
227
|
+
<ScrollView style={styles.listContainer}>
|
|
231
228
|
{!!list_wifi.length &&
|
|
232
229
|
list_wifi.map((item, index) => (
|
|
233
230
|
<TouchableOpacity
|
|
@@ -52,7 +52,6 @@ const SetupGatewayWifi = memo(({ route }) => {
|
|
|
52
52
|
setWifiName(ssid);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
// eslint-disable-next-line no-empty
|
|
56
55
|
} catch (err) {}
|
|
57
56
|
};
|
|
58
57
|
wifiPermission();
|
|
@@ -148,7 +147,6 @@ const SetupGatewayWifi = memo(({ route }) => {
|
|
|
148
147
|
<ScrollView
|
|
149
148
|
style={styles.scrollContainer}
|
|
150
149
|
showsVerticalScrollIndicator={false}
|
|
151
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
152
150
|
>
|
|
153
151
|
<Section type={'border'}>
|
|
154
152
|
<Text style={styles.textWifi} bold color={Colors.Primary}>
|
|
@@ -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 AddNewGateway from '../index';
|
|
6
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
@@ -10,7 +10,6 @@ import { TextInput } from 'react-native';
|
|
|
10
10
|
import { getTranslate } from '../../../utils/I18n';
|
|
11
11
|
import { SCProvider } from '../../../context';
|
|
12
12
|
import { mockSCStore } from '../../../context/mockStore';
|
|
13
|
-
import api from '../../../utils/Apis/axios';
|
|
14
13
|
|
|
15
14
|
const wrapComponent = (route) => (
|
|
16
15
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -18,7 +17,7 @@ const wrapComponent = (route) => (
|
|
|
18
17
|
</SCProvider>
|
|
19
18
|
);
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
jest.mock('axios');
|
|
22
21
|
|
|
23
22
|
jest.mock('react', () => {
|
|
24
23
|
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
@@ -42,6 +41,7 @@ describe('Test AddNewGateway', () => {
|
|
|
42
41
|
let route;
|
|
43
42
|
|
|
44
43
|
afterEach(() => {
|
|
44
|
+
axios.get.mockClear();
|
|
45
45
|
mockedNavigate.mockClear();
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -149,7 +149,9 @@ describe('Test AddNewGateway', () => {
|
|
|
149
149
|
stations: [{ id: 2, name: 'Station name' }],
|
|
150
150
|
},
|
|
151
151
|
};
|
|
152
|
-
|
|
152
|
+
axios.get.mockImplementation(async () => {
|
|
153
|
+
return response;
|
|
154
|
+
});
|
|
153
155
|
|
|
154
156
|
await act(async () => {
|
|
155
157
|
tree = await create(wrapComponent(route));
|
|
@@ -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 { TESTID } from '../../../configs/Constants';
|
|
5
6
|
import ConnectedGateway from '../ConnectedGateway';
|
|
@@ -7,6 +8,8 @@ import { SCProvider } from '../../../context';
|
|
|
7
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
9
|
import { getTranslate } from '../../../utils/I18n';
|
|
9
10
|
|
|
11
|
+
jest.mock('axios');
|
|
12
|
+
|
|
10
13
|
const mockedNavigate = jest.fn();
|
|
11
14
|
jest.mock('@react-navigation/native', () => {
|
|
12
15
|
return {
|
|
@@ -28,6 +31,7 @@ describe('Test ConnectedGateway', () => {
|
|
|
28
31
|
let route;
|
|
29
32
|
|
|
30
33
|
afterEach(() => {
|
|
34
|
+
axios.get.mockClear();
|
|
31
35
|
mockedNavigate.mockClear();
|
|
32
36
|
});
|
|
33
37
|
|
|
@@ -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 ConnectingGateway from '../ConnectingGateway';
|
|
6
6
|
import Text from '../../../commons/Text';
|
|
@@ -9,9 +9,8 @@ import Routes from '../../../utils/Route';
|
|
|
9
9
|
import { getTranslate } from '../../../utils/I18n';
|
|
10
10
|
import { SCProvider } from '../../../context';
|
|
11
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
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 ConnectingGateway', () => {
|
|
|
34
33
|
let route;
|
|
35
34
|
|
|
36
35
|
afterEach(() => {
|
|
36
|
+
axios.get.mockClear();
|
|
37
37
|
mockedNavigate.mockClear();
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -64,7 +64,14 @@ describe('Test ConnectingGateway', () => {
|
|
|
64
64
|
|
|
65
65
|
test('call setInterval api success', async () => {
|
|
66
66
|
jest.useFakeTimers();
|
|
67
|
-
|
|
67
|
+
const response = {
|
|
68
|
+
status: 200,
|
|
69
|
+
data: {},
|
|
70
|
+
};
|
|
71
|
+
axios.get.mockImplementation(async () => {
|
|
72
|
+
return response;
|
|
73
|
+
});
|
|
74
|
+
|
|
68
75
|
await act(async () => {
|
|
69
76
|
tree = await create(wrapComponent(route));
|
|
70
77
|
});
|
|
@@ -72,6 +79,11 @@ describe('Test ConnectingGateway', () => {
|
|
|
72
79
|
await jest.runOnlyPendingTimers();
|
|
73
80
|
});
|
|
74
81
|
expect(setInterval).toHaveBeenCalled();
|
|
82
|
+
expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED(), {
|
|
83
|
+
params: {
|
|
84
|
+
chip_id: 1,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
75
87
|
expect(mockedNavigate).not.toHaveBeenCalledWith(
|
|
76
88
|
Routes.ConnectedGateway,
|
|
77
89
|
route.params
|
|
@@ -80,7 +92,14 @@ describe('Test ConnectingGateway', () => {
|
|
|
80
92
|
|
|
81
93
|
test('call setInterval api fail', async () => {
|
|
82
94
|
jest.useFakeTimers();
|
|
83
|
-
|
|
95
|
+
const response = {
|
|
96
|
+
status: 400,
|
|
97
|
+
data: {},
|
|
98
|
+
};
|
|
99
|
+
axios.get.mockImplementation(async () => {
|
|
100
|
+
return response;
|
|
101
|
+
});
|
|
102
|
+
|
|
84
103
|
await act(async () => {
|
|
85
104
|
tree = await create(wrapComponent(route));
|
|
86
105
|
});
|
|
@@ -88,6 +107,11 @@ describe('Test ConnectingGateway', () => {
|
|
|
88
107
|
await jest.runOnlyPendingTimers();
|
|
89
108
|
});
|
|
90
109
|
expect(setInterval).toHaveBeenCalled();
|
|
110
|
+
expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED(), {
|
|
111
|
+
params: {
|
|
112
|
+
chip_id: 1,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
91
115
|
expect(mockedNavigate).not.toHaveBeenCalledWith(
|
|
92
116
|
Routes.ConnectedGateway,
|
|
93
117
|
route.params
|
|
@@ -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 AddNewGatewaySelectGateway from '../SelectGateway';
|
|
5
6
|
import { SCProvider } from '../../../context';
|
|
@@ -12,6 +13,8 @@ const wrapComponent = (route) => (
|
|
|
12
13
|
</SCProvider>
|
|
13
14
|
);
|
|
14
15
|
|
|
16
|
+
jest.mock('axios');
|
|
17
|
+
|
|
15
18
|
jest.mock('react', () => {
|
|
16
19
|
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
17
20
|
});
|
|
@@ -35,6 +38,7 @@ describe('Test AddNewGatewaySelectGateway', () => {
|
|
|
35
38
|
let route;
|
|
36
39
|
|
|
37
40
|
afterEach(() => {
|
|
41
|
+
axios.get.mockClear();
|
|
38
42
|
mockedNavigate.mockClear();
|
|
39
43
|
});
|
|
40
44
|
|
|
@@ -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 { TESTID } from '../../../configs/Constants';
|
|
5
6
|
import { SCProvider } from '../../../context';
|
|
@@ -15,6 +16,8 @@ const wrapComponent = (route) => (
|
|
|
15
16
|
</SCProvider>
|
|
16
17
|
);
|
|
17
18
|
|
|
19
|
+
jest.mock('axios');
|
|
20
|
+
|
|
18
21
|
jest.mock('react', () => {
|
|
19
22
|
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
20
23
|
});
|
|
@@ -56,6 +59,7 @@ describe('Test SetupGatewayWifi', () => {
|
|
|
56
59
|
let route;
|
|
57
60
|
|
|
58
61
|
afterEach(() => {
|
|
62
|
+
axios.get.mockClear();
|
|
59
63
|
mockedNavigate.mockClear();
|
|
60
64
|
});
|
|
61
65
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
3
3
|
import { Platform, TextInput, TouchableOpacity } from 'react-native';
|
|
4
4
|
import { act, create } from 'react-test-renderer';
|
|
5
5
|
|
|
@@ -9,15 +9,13 @@ import { SCProvider } from '../../../context';
|
|
|
9
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
10
10
|
import Routes from '../../../utils/Route';
|
|
11
11
|
import { HeaderCustom } from '../../../commons/Header';
|
|
12
|
-
import api from '../../../utils/Apis/axios';
|
|
13
|
-
import { API } from '../../../configs';
|
|
14
12
|
|
|
15
13
|
const wrapComponent = (route) => (
|
|
16
14
|
<SCProvider initState={mockSCStore({})}>
|
|
17
15
|
<AddNewOneTap route={route} />
|
|
18
16
|
</SCProvider>
|
|
19
17
|
);
|
|
20
|
-
|
|
18
|
+
jest.mock('axios');
|
|
21
19
|
|
|
22
20
|
jest.mock('react-redux', () => {
|
|
23
21
|
return {
|
|
@@ -43,13 +41,14 @@ jest.mock('react', () => {
|
|
|
43
41
|
};
|
|
44
42
|
});
|
|
45
43
|
|
|
44
|
+
jest.mock('axios');
|
|
46
45
|
let tree;
|
|
47
46
|
|
|
48
47
|
describe('test AddNewOneTap', () => {
|
|
49
48
|
beforeEach(() => {
|
|
49
|
+
axios.post.mockClear();
|
|
50
50
|
mockedNavigate.mockClear();
|
|
51
51
|
});
|
|
52
|
-
|
|
53
52
|
test('create AddNewOneTap success', async () => {
|
|
54
53
|
Platform.OS = 'ios';
|
|
55
54
|
let route = {
|
|
@@ -72,7 +71,9 @@ describe('test AddNewOneTap', () => {
|
|
|
72
71
|
},
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
axios.post.mockImplementation(async () => {
|
|
75
|
+
return response;
|
|
76
|
+
});
|
|
76
77
|
|
|
77
78
|
await act(async () => {
|
|
78
79
|
tree = await create(wrapComponent(route));
|
|
@@ -99,14 +100,19 @@ describe('test AddNewOneTap', () => {
|
|
|
99
100
|
await item[0].props.onPress();
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
|
-
|
|
103
103
|
test('create AddNewOneTap fail', async () => {
|
|
104
104
|
Platform.OS = 'android';
|
|
105
105
|
let route = {
|
|
106
106
|
params: { type: 'one_tap' },
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
const response = {
|
|
110
|
+
status: 400,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
axios.post.mockImplementation(async () => {
|
|
114
|
+
return response;
|
|
115
|
+
});
|
|
110
116
|
|
|
111
117
|
await act(async () => {
|
|
112
118
|
tree = await create(wrapComponent(route));
|
|
@@ -138,7 +144,15 @@ describe('test AddNewOneTap', () => {
|
|
|
138
144
|
isAutomateTab: false,
|
|
139
145
|
},
|
|
140
146
|
};
|
|
141
|
-
|
|
147
|
+
|
|
148
|
+
const response = {
|
|
149
|
+
status: 400,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
axios.post.mockImplementation(async () => {
|
|
153
|
+
return response;
|
|
154
|
+
});
|
|
155
|
+
|
|
142
156
|
await act(async () => {
|
|
143
157
|
tree = await create(wrapComponent(route));
|
|
144
158
|
});
|
|
@@ -151,7 +165,7 @@ describe('test AddNewOneTap', () => {
|
|
|
151
165
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
|
|
152
166
|
id: 1,
|
|
153
167
|
name: 'script test',
|
|
154
|
-
type:
|
|
168
|
+
type: 'one_tap',
|
|
155
169
|
havePermission: true,
|
|
156
170
|
unit: { id: 1 },
|
|
157
171
|
isMultiUnits: false,
|
|
@@ -25,7 +25,6 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
25
25
|
isMultiUnits,
|
|
26
26
|
automateId,
|
|
27
27
|
scriptName,
|
|
28
|
-
oldType,
|
|
29
28
|
} = route.params;
|
|
30
29
|
const t = useTranslations();
|
|
31
30
|
const { navigate, dispatch, goBack } = useNavigation();
|
|
@@ -92,7 +91,7 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
92
91
|
navigate(Routes.ScriptDetail, {
|
|
93
92
|
id: automateId,
|
|
94
93
|
name: scriptName,
|
|
95
|
-
type:
|
|
94
|
+
type: type,
|
|
96
95
|
havePermission: true,
|
|
97
96
|
unit,
|
|
98
97
|
isMultiUnits,
|
|
@@ -121,7 +120,7 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
121
120
|
}
|
|
122
121
|
>
|
|
123
122
|
<HeaderCustom isShowClose onClose={onClose} />
|
|
124
|
-
<ScrollView
|
|
123
|
+
<ScrollView>
|
|
125
124
|
<Text
|
|
126
125
|
testID={TESTID.ADD_NEW_DEVICE_ADD}
|
|
127
126
|
semibold
|
|
@@ -35,9 +35,9 @@ const AllCamera = () => {
|
|
|
35
35
|
const [dataFullScreen, setDataFullScreen] = useState();
|
|
36
36
|
|
|
37
37
|
const handleFullScreen = useCallback(
|
|
38
|
-
(
|
|
38
|
+
(data) => {
|
|
39
39
|
setIsFullScreen(!isFullScreen);
|
|
40
|
-
setDataFullScreen(
|
|
40
|
+
setDataFullScreen(data);
|
|
41
41
|
},
|
|
42
42
|
[isFullScreen]
|
|
43
43
|
);
|
|
@@ -74,8 +74,8 @@ const AllCamera = () => {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
const goToPlayBack = useCallback(
|
|
77
|
-
(item,
|
|
78
|
-
navigate(Routes.PlaybackCamera, { item, thumbnail
|
|
77
|
+
(item, thumbnail) => () => {
|
|
78
|
+
navigate(Routes.PlaybackCamera, { item, thumbnail });
|
|
79
79
|
},
|
|
80
80
|
[navigate]
|
|
81
81
|
);
|
|
@@ -39,17 +39,17 @@ const MultiUnits = () => {
|
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
const getData = useCallback(
|
|
42
|
-
async (
|
|
42
|
+
async (params) => {
|
|
43
43
|
if (isMultiUnits) {
|
|
44
|
-
const { success, data
|
|
44
|
+
const { success, data } = await axiosGet(
|
|
45
45
|
API.AUTOMATE.GET_MULTI_UNITS(),
|
|
46
|
-
|
|
46
|
+
params
|
|
47
47
|
);
|
|
48
|
-
success && setData(
|
|
48
|
+
success && setData(data);
|
|
49
49
|
} else {
|
|
50
50
|
await fetchWithCache(API.UNIT.AUTOMATE(unit?.id), {}, (response) => {
|
|
51
|
-
const { success, data
|
|
52
|
-
success && setData(
|
|
51
|
+
const { success, data } = response;
|
|
52
|
+
success && setData(data);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
},
|
|
@@ -60,14 +60,14 @@ const MultiUnits = () => {
|
|
|
60
60
|
setTabActive(tab);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const onPressItem = (item,
|
|
63
|
+
const onPressItem = (item, isOwner) => () => {
|
|
64
64
|
navigate(Routes.UnitStack, {
|
|
65
65
|
screen: Routes.ScriptDetail,
|
|
66
66
|
params: {
|
|
67
67
|
id: item?.id,
|
|
68
68
|
name: item?.script?.name,
|
|
69
69
|
type: item?.type,
|
|
70
|
-
havePermission:
|
|
70
|
+
havePermission: isOwner || idUser === item?.user,
|
|
71
71
|
unit,
|
|
72
72
|
isMultiUnits,
|
|
73
73
|
automate: item,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import
|
|
4
|
+
import axios from 'axios';
|
|
5
5
|
import { useRoute } from '@react-navigation/native';
|
|
6
6
|
|
|
7
7
|
import MultiUnits from '../MultiUnits';
|
|
@@ -13,10 +13,8 @@ import Routes from '../../../utils/Route';
|
|
|
13
13
|
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
14
14
|
import { getTranslate } from '../../../utils/I18n';
|
|
15
15
|
import { AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
16
|
-
import api from '../../../utils/Apis/axios';
|
|
17
|
-
import { API } from '../../../configs';
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
jest.mock('axios');
|
|
20
18
|
const mockedNavigate = jest.fn();
|
|
21
19
|
const mockSetState = jest.fn();
|
|
22
20
|
|
|
@@ -49,6 +47,7 @@ describe('Test MultiUnits', () => {
|
|
|
49
47
|
let tree;
|
|
50
48
|
|
|
51
49
|
beforeEach(() => {
|
|
50
|
+
axios.get.mockClear();
|
|
52
51
|
mockedNavigate.mockClear();
|
|
53
52
|
mockSetState.mockClear();
|
|
54
53
|
useRoute.mockClear();
|
|
@@ -94,7 +93,9 @@ describe('Test MultiUnits', () => {
|
|
|
94
93
|
},
|
|
95
94
|
],
|
|
96
95
|
};
|
|
97
|
-
|
|
96
|
+
await axios.get.mockImplementation(async () => {
|
|
97
|
+
return response;
|
|
98
|
+
});
|
|
98
99
|
useRoute.mockReturnValue({
|
|
99
100
|
params: {
|
|
100
101
|
isMultiUnits: true,
|
|
@@ -188,7 +189,9 @@ describe('Test MultiUnits', () => {
|
|
|
188
189
|
},
|
|
189
190
|
],
|
|
190
191
|
};
|
|
191
|
-
|
|
192
|
+
await axios.get.mockImplementation(async () => {
|
|
193
|
+
return response;
|
|
194
|
+
});
|
|
192
195
|
useRoute.mockReturnValue({
|
|
193
196
|
params: {
|
|
194
197
|
isMultiUnits: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { FlatList, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import
|
|
4
|
+
import axios from 'axios';
|
|
5
5
|
|
|
6
6
|
import Automate from '../';
|
|
7
7
|
import { SCProvider } from '../../../context';
|
|
@@ -10,10 +10,8 @@ import ItemOneTap from '../../../commons/SubUnit/OneTap/ItemOneTap';
|
|
|
10
10
|
import ItemAddNew from '../../../commons/Device/ItemAddNew';
|
|
11
11
|
import Routes from '../../../utils/Route';
|
|
12
12
|
import { TESTID } from '../../../configs/Constants';
|
|
13
|
-
import api from '../../../utils/Apis/axios';
|
|
14
|
-
import { API } from '../../../configs';
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
jest.mock('axios');
|
|
17
15
|
const mockedNavigate = jest.fn();
|
|
18
16
|
const mockSetState = jest.fn();
|
|
19
17
|
|
|
@@ -48,6 +46,7 @@ describe('Test Automate', () => {
|
|
|
48
46
|
let tree;
|
|
49
47
|
|
|
50
48
|
beforeEach(() => {
|
|
49
|
+
axios.get.mockClear();
|
|
51
50
|
mockedNavigate.mockClear();
|
|
52
51
|
mockSetState.mockClear();
|
|
53
52
|
});
|
|
@@ -87,7 +86,9 @@ describe('Test Automate', () => {
|
|
|
87
86
|
},
|
|
88
87
|
],
|
|
89
88
|
};
|
|
90
|
-
|
|
89
|
+
await axios.get.mockImplementation(async () => {
|
|
90
|
+
return response;
|
|
91
|
+
});
|
|
91
92
|
|
|
92
93
|
useState.mockImplementation(() => [false, mockSetState]);
|
|
93
94
|
useState.mockImplementation(() => [response.data, mockSetState]);
|
|
@@ -140,7 +141,9 @@ describe('Test Automate', () => {
|
|
|
140
141
|
{ automates: [], unit_id: 3, unit_name: 'La Vida' },
|
|
141
142
|
],
|
|
142
143
|
};
|
|
143
|
-
|
|
144
|
+
await axios.get.mockImplementation(async () => {
|
|
145
|
+
return response;
|
|
146
|
+
});
|
|
144
147
|
|
|
145
148
|
useState.mockImplementation(() => [false, mockSetState]);
|
|
146
149
|
useState.mockImplementation(() => [response.data, mockSetState]);
|
|
@@ -196,7 +199,9 @@ describe('Test Automate', () => {
|
|
|
196
199
|
{ automates: [], unit_id: 3, unit_name: 'La Vida' },
|
|
197
200
|
],
|
|
198
201
|
};
|
|
199
|
-
|
|
202
|
+
await axios.get.mockImplementation(async () => {
|
|
203
|
+
return response;
|
|
204
|
+
});
|
|
200
205
|
|
|
201
206
|
useState.mockImplementation(() => [false, mockSetState]);
|
|
202
207
|
useState.mockImplementation(() => [response.data, mockSetState]);
|