@eohjsc/react-native-smart-city 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -36
- package/package.json +5 -9
- package/react-native-smart-city.podspec +0 -1
- package/src/commons/Action/ItemQuickAction.js +4 -16
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
- package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
- package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
- package/src/commons/ActionGroup/__test__/index.test.js +0 -135
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +3 -1
- package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
- package/src/commons/ConnectingProcess/index.js +26 -76
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/HistoryChart.js +3 -7
- package/src/commons/Device/ItemDevice.js +12 -19
- package/src/commons/Device/LinearChart.js +0 -15
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
- package/src/commons/Explore/__test__/CityItem.test.js +54 -33
- package/src/commons/Form/CurrencyInput.js +1 -15
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +1 -2
- package/src/commons/Header/HeaderCustom.js +1 -2
- package/src/commons/HeaderAni/index.js +1 -6
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
- package/src/commons/MediaPlayerDetail/index.js +47 -25
- package/src/commons/MenuActionAddnew/index.js +0 -1
- package/src/commons/MenuActionList/index.js +0 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/index.js +1 -9
- package/src/commons/Sharing/MemberList.js +2 -10
- package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
- package/src/commons/SubUnit/Favorites/index.js +3 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
- package/src/commons/SubUnit/OneTap/index.js +2 -1
- package/src/commons/SubUnit/ShortDetail.js +9 -25
- package/src/commons/SubUnit/__test__/Item.test.js +1 -0
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
- package/src/commons/Unit/SharedUnit.js +0 -1
- package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
- package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
- package/src/commons/WheelDateTimePicker/index.js +3 -4
- package/src/configs/API.js +143 -87
- package/src/configs/Constants.js +1 -57
- package/src/configs/SCConfig.js +0 -4
- package/src/context/actionType.ts +0 -8
- package/src/context/mockStore.ts +0 -10
- package/src/context/reducer.ts +2 -38
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useGetIdUser.js +5 -1
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/useReceiveNotifications.js +5 -9
- package/src/iot/Monitor.js +2 -3
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +49 -75
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +20 -11
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +0 -2
- package/src/screens/ActivityLog/__test__/index.test.js +23 -38
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +0 -1
- package/src/screens/AddCommon/SelectUnit.js +0 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
- package/src/screens/AddLocationMaps/index.js +5 -9
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
- package/src/screens/AddNewAutoSmart/index.js +2 -5
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewDevice/index.js +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +40 -46
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +10 -64
- package/src/screens/AddNewGateway/SelectGateway.js +0 -1
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
- package/src/screens/AddNewGateway/index.js +0 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
- package/src/screens/AddNewOneTap/index.js +2 -3
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
- package/src/screens/Automate/__test__/index.test.js +12 -7
- package/src/screens/Automate/index.js +3 -5
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
- package/src/screens/ConfirmUnitDeletion/index.js +1 -7
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
- package/src/screens/Device/EditDevice/index.js +15 -17
- package/src/screens/Device/__test__/detail.test.js +86 -33
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
- package/src/screens/Device/components/SensorDisplayItem.js +2 -5
- package/src/screens/Device/detail.js +24 -80
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
- package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +1 -4
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
- package/src/screens/Explore/index.js +0 -2
- package/src/screens/GuestInfo/__test__/index.test.js +41 -14
- package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +12 -8
- package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +22 -33
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
- package/src/screens/ManageAccess/hooks/index.js +4 -7
- package/src/screens/ManageAccess/index.js +1 -2
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +25 -14
- package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
- package/src/screens/Notification/components/NotificationItem.js +20 -17
- package/src/screens/Notification/index.js +2 -9
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
- package/src/screens/PlayBackCamera/index.js +6 -22
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
- package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
- package/src/screens/ScanChipQR/hooks/index.js +16 -15
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
- package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
- package/src/screens/ScriptDetail/index.js +14 -19
- package/src/screens/SelectUnit/__test__/index.test.js +55 -12
- package/src/screens/SelectUnit/index.js +4 -9
- package/src/screens/SetSchedule/index.js +11 -15
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
- package/src/screens/SharedUnit/index.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +12 -10
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +11 -12
- package/src/screens/Sharing/SelectPermission.js +76 -121
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
- package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
- package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
- package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
- package/src/screens/Sharing/hooks/index.js +0 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +17 -23
- package/src/screens/SubUnit/Detail.js +2 -1
- package/src/screens/SubUnit/EditSubUnit.js +13 -15
- package/src/screens/SubUnit/ManageSubUnit.js +7 -13
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
- package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
- package/src/screens/TDSGuide/index.js +1 -4
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +14 -7
- package/src/screens/Unit/Detail.js +75 -30
- package/src/screens/Unit/ManageUnit.js +0 -1
- package/src/screens/Unit/SelectAddress.js +23 -45
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +0 -4
- package/src/screens/Unit/Summaries.js +2 -18
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
- package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
- package/src/screens/Unit/__test__/Detail.test.js +200 -99
- package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
- package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +0 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
- package/src/screens/Unit/styles.js +0 -4
- package/src/screens/UnitSummary/__test__/index.test.js +30 -91
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
- package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
- package/src/screens/UnitSummary/index.js +1 -15
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +31 -54
- package/src/utils/Converter/time.js +18 -0
- package/src/utils/I18n/translations/en.json +1 -7
- package/src/utils/I18n/translations/vi.json +1 -8
- package/src/utils/Route/index.js +0 -1
- package/src/utils/Utils.js +7 -11
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
- package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
- package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
- package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
- package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
- package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
- package/src/hooks/IoT/index.js +0 -4
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/hooks/IoT/useRemoteControl.js +0 -79
- package/src/hooks/index.js +0 -4
- package/src/navigations/UnitStackStyles.js +0 -21
- package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
- package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
- package/src/screens/SideMenuDetail/index.js +0 -148
- package/src/screens/Unit/__test__/Summaries.test.js +0 -100
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
- package/src/utils/Permission/common.js +0 -67
- package/src/utils/Setting/Location.js +0 -30
- package/src/utils/__test__/Utils.test.js +0 -12
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlatList } 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 HanetCameraDetail from '../Detail';
|
|
@@ -10,9 +9,6 @@ import CheckinHeader from '../components/CheckinHeader';
|
|
|
10
9
|
import moment from 'moment';
|
|
11
10
|
import { TESTID } from '../../../configs/Constants';
|
|
12
11
|
import Calendar from '../../../commons/Calendar';
|
|
13
|
-
import api from '../../../utils/Apis/axios';
|
|
14
|
-
import { API } from '../../../configs';
|
|
15
|
-
import { MenuActionMore } from '../../../commons';
|
|
16
12
|
|
|
17
13
|
const wrapComponent = (route) => (
|
|
18
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -20,19 +16,6 @@ const wrapComponent = (route) => (
|
|
|
20
16
|
</SCProvider>
|
|
21
17
|
);
|
|
22
18
|
|
|
23
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
24
|
-
|
|
25
|
-
const mockNavigate = jest.fn();
|
|
26
|
-
jest.mock('@react-navigation/native', () => {
|
|
27
|
-
return {
|
|
28
|
-
...jest.requireActual('@react-navigation/native'),
|
|
29
|
-
useRoute: jest.fn(),
|
|
30
|
-
useNavigation: () => ({
|
|
31
|
-
navigate: mockNavigate,
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
|
|
36
19
|
jest.mock('react', () => {
|
|
37
20
|
return {
|
|
38
21
|
...jest.requireActual('react'),
|
|
@@ -40,11 +23,14 @@ jest.mock('react', () => {
|
|
|
40
23
|
};
|
|
41
24
|
});
|
|
42
25
|
|
|
26
|
+
jest.mock('axios');
|
|
27
|
+
|
|
43
28
|
describe('Test HanetCameraDetail', () => {
|
|
44
29
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
45
30
|
let tree, route, responseDisplay, responseCheckin;
|
|
46
31
|
|
|
47
32
|
beforeEach(() => {
|
|
33
|
+
axios.get.mockClear();
|
|
48
34
|
route = {
|
|
49
35
|
params: {
|
|
50
36
|
unit: {
|
|
@@ -101,14 +87,20 @@ describe('Test HanetCameraDetail', () => {
|
|
|
101
87
|
});
|
|
102
88
|
|
|
103
89
|
test('Test render HanetCameraDetail', async () => {
|
|
104
|
-
|
|
105
|
-
|
|
90
|
+
axios.get.mockImplementationOnce(async () => {
|
|
91
|
+
return responseDisplay;
|
|
92
|
+
});
|
|
93
|
+
axios.get.mockImplementationOnce(async () => {
|
|
94
|
+
return responseCheckin;
|
|
95
|
+
});
|
|
106
96
|
await act(async () => {
|
|
107
97
|
tree = await create(wrapComponent(route));
|
|
108
98
|
});
|
|
109
99
|
const instance = tree.root;
|
|
100
|
+
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
110
101
|
const flatLists = instance.findAllByType(FlatList);
|
|
111
102
|
expect(flatLists).toHaveLength(1);
|
|
103
|
+
|
|
112
104
|
const textCountMember = instance.find(
|
|
113
105
|
(el) => el.props.testID === TESTID.TEXT_COUNT_MEMBER
|
|
114
106
|
);
|
|
@@ -117,33 +109,50 @@ describe('Test HanetCameraDetail', () => {
|
|
|
117
109
|
);
|
|
118
110
|
expect(textCountMember.props.children).toBe(1);
|
|
119
111
|
expect(textCountStranger.props.children).toBe(1);
|
|
120
|
-
const MenuActionMores = instance.findByType(MenuActionMore);
|
|
121
|
-
await MenuActionMores.props.onItemClick({ data: 'test' });
|
|
122
|
-
expect(mockNavigate).toBeCalled();
|
|
123
112
|
});
|
|
124
113
|
|
|
125
114
|
test('Test change date', async () => {
|
|
126
|
-
|
|
127
|
-
|
|
115
|
+
axios.get.mockImplementationOnce(async () => {
|
|
116
|
+
return responseDisplay;
|
|
117
|
+
});
|
|
118
|
+
axios.get.mockImplementationOnce(async () => {
|
|
119
|
+
return responseCheckin;
|
|
120
|
+
});
|
|
128
121
|
await act(async () => {
|
|
129
122
|
tree = await create(wrapComponent(route));
|
|
130
123
|
});
|
|
131
124
|
const instance = tree.root;
|
|
125
|
+
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
126
|
+
axios.get.mockClear();
|
|
127
|
+
|
|
132
128
|
const checkinHeader = instance.findByType(CheckinHeader);
|
|
129
|
+
|
|
133
130
|
// press arrow left
|
|
134
|
-
|
|
131
|
+
axios.get.mockImplementationOnce(async () => {
|
|
132
|
+
return responseCheckin;
|
|
133
|
+
});
|
|
135
134
|
await act(async () => {
|
|
136
135
|
await checkinHeader.props.onPickPreviousDate();
|
|
137
136
|
});
|
|
138
137
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
139
138
|
moment().add(-1, 'days').format('DD/MM/YYYY')
|
|
140
139
|
);
|
|
140
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
141
|
+
axios.get.mockClear();
|
|
142
|
+
|
|
143
|
+
// press arrow right
|
|
144
|
+
axios.get.mockImplementationOnce(async () => {
|
|
145
|
+
return responseCheckin;
|
|
146
|
+
});
|
|
141
147
|
await act(async () => {
|
|
142
148
|
await checkinHeader.props.onPickNextDate();
|
|
143
149
|
});
|
|
144
150
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
145
151
|
moment().format('DD/MM/YYYY')
|
|
146
152
|
);
|
|
153
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
154
|
+
axios.get.mockClear();
|
|
155
|
+
|
|
147
156
|
// press arrow right
|
|
148
157
|
await act(async () => {
|
|
149
158
|
await checkinHeader.props.onPickNextDate();
|
|
@@ -151,6 +160,9 @@ describe('Test HanetCameraDetail', () => {
|
|
|
151
160
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
152
161
|
moment().format('DD/MM/YYYY')
|
|
153
162
|
); // no change
|
|
163
|
+
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
164
|
+
axios.get.mockClear();
|
|
165
|
+
|
|
154
166
|
// open calendar
|
|
155
167
|
await act(async () => {
|
|
156
168
|
await checkinHeader.props.setShowCalendar();
|
|
@@ -159,12 +171,15 @@ describe('Test HanetCameraDetail', () => {
|
|
|
159
171
|
expect(calendar.props.isVisible).toBe(true);
|
|
160
172
|
|
|
161
173
|
// choose date on calendar
|
|
162
|
-
|
|
174
|
+
axios.get.mockImplementationOnce(async () => {
|
|
175
|
+
return responseCheckin;
|
|
176
|
+
});
|
|
163
177
|
await act(async () => {
|
|
164
178
|
await calendar.props.onConfirm(moment().add(-1, 'days'));
|
|
165
179
|
});
|
|
166
180
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
167
181
|
moment().add(-1, 'days').format('DD/MM/YYYY')
|
|
168
182
|
);
|
|
183
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
169
184
|
});
|
|
170
185
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlatList } 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 HanetManageAccess from '../ManageAccess';
|
|
@@ -10,10 +9,6 @@ import BottomSheet from '../../../commons/BottomSheet';
|
|
|
10
9
|
import { TESTID } from '../../../configs/Constants';
|
|
11
10
|
import Routes from '../../../utils/Route';
|
|
12
11
|
import ImagePicker from 'react-native-image-crop-picker';
|
|
13
|
-
import api from '../../../utils/Apis/axios';
|
|
14
|
-
import { API } from '../../../configs';
|
|
15
|
-
|
|
16
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
17
12
|
|
|
18
13
|
const wrapComponent = (route) => (
|
|
19
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -39,11 +34,14 @@ jest.mock('@react-navigation/native', () => {
|
|
|
39
34
|
};
|
|
40
35
|
});
|
|
41
36
|
|
|
37
|
+
jest.mock('axios');
|
|
38
|
+
|
|
42
39
|
describe('Test HanetManageAccess', () => {
|
|
43
40
|
let tree, route, response;
|
|
44
41
|
|
|
45
42
|
beforeEach(() => {
|
|
46
43
|
mockedNavigate.mockClear();
|
|
44
|
+
axios.get.mockClear();
|
|
47
45
|
route = {
|
|
48
46
|
params: {
|
|
49
47
|
hanetPlace: {
|
|
@@ -72,8 +70,7 @@ describe('Test HanetManageAccess', () => {
|
|
|
72
70
|
],
|
|
73
71
|
},
|
|
74
72
|
};
|
|
75
|
-
|
|
76
|
-
mock.onGet(API.CAMERA.HANET.PLACE_MEMBERS(1)).reply(200, response.data);
|
|
73
|
+
axios.get.mockImplementationOnce(async () => response);
|
|
77
74
|
await act(async () => {
|
|
78
75
|
tree = await create(wrapComponent(route));
|
|
79
76
|
});
|
|
@@ -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 HanetMemberInfo from '../MemberInfo';
|
|
@@ -11,8 +10,6 @@ import TextInput from '../../../commons/Form/TextInput';
|
|
|
11
10
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
12
11
|
import BottomSheet from '../../../commons/BottomSheet';
|
|
13
12
|
import { TESTID } from '../../../configs/Constants';
|
|
14
|
-
import api from '../../../utils/Apis/axios';
|
|
15
|
-
import { API } from '../../../configs';
|
|
16
13
|
|
|
17
14
|
const wrapComponent = (route) => (
|
|
18
15
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -40,7 +37,7 @@ jest.mock('@react-navigation/native', () => {
|
|
|
40
37
|
};
|
|
41
38
|
});
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
jest.mock('axios');
|
|
44
41
|
|
|
45
42
|
describe('Test HanetMemberInfo', () => {
|
|
46
43
|
let tree, route;
|
|
@@ -48,6 +45,9 @@ describe('Test HanetMemberInfo', () => {
|
|
|
48
45
|
beforeEach(() => {
|
|
49
46
|
mockedNavigate.mockClear();
|
|
50
47
|
mockedGoBack.mockClear();
|
|
48
|
+
axios.post.mockClear();
|
|
49
|
+
axios.patch.mockClear();
|
|
50
|
+
axios.delete.mockClear();
|
|
51
51
|
route = {
|
|
52
52
|
params: {
|
|
53
53
|
hanetPlace: {
|
|
@@ -72,18 +72,23 @@ describe('Test HanetMemberInfo', () => {
|
|
|
72
72
|
const touches = instance.findAllByType(TouchableOpacity);
|
|
73
73
|
expect(touches).toHaveLength(7);
|
|
74
74
|
const alertAction = instance.findByType(AlertAction);
|
|
75
|
+
|
|
75
76
|
// open alert action
|
|
76
77
|
await act(async () => {
|
|
77
78
|
await touches[2].props.onPress();
|
|
78
79
|
});
|
|
80
|
+
expect(alertAction.props.visible).toBe(true);
|
|
81
|
+
|
|
79
82
|
const textInput = instance.findByType(TextInput);
|
|
80
|
-
|
|
83
|
+
|
|
84
|
+
axios.patch.mockImplementationOnce(async () => ({ status: 200 }));
|
|
85
|
+
|
|
81
86
|
// change name and press rename
|
|
82
87
|
await act(async () => {
|
|
83
88
|
await textInput.props.onChange('new name');
|
|
84
89
|
await alertAction.props.rightButtonClick();
|
|
85
90
|
});
|
|
86
|
-
expect(
|
|
91
|
+
expect(axios.patch).toHaveBeenCalled();
|
|
87
92
|
});
|
|
88
93
|
|
|
89
94
|
test('Test remove member', async () => {
|
|
@@ -100,11 +105,15 @@ describe('Test HanetMemberInfo', () => {
|
|
|
100
105
|
await touches[3].props.onPress();
|
|
101
106
|
});
|
|
102
107
|
expect(alertAction.props.visible).toBe(true);
|
|
103
|
-
|
|
108
|
+
|
|
109
|
+
axios.delete.mockImplementationOnce(async () => ({ status: 200 }));
|
|
110
|
+
|
|
104
111
|
// press remove
|
|
105
112
|
await act(async () => {
|
|
106
113
|
await alertAction.props.rightButtonClick();
|
|
107
114
|
});
|
|
115
|
+
|
|
116
|
+
expect(axios.delete).toHaveBeenCalled();
|
|
108
117
|
expect(mockedGoBack).toHaveBeenCalled();
|
|
109
118
|
});
|
|
110
119
|
|
|
@@ -144,14 +153,24 @@ describe('Test HanetMemberInfo', () => {
|
|
|
144
153
|
const instance = tree.root;
|
|
145
154
|
const touches = instance.findAllByType(TouchableOpacity);
|
|
146
155
|
expect(touches).toHaveLength(7);
|
|
156
|
+
|
|
147
157
|
await act(async () => {
|
|
148
158
|
await touches[1].props.onPress();
|
|
149
159
|
});
|
|
160
|
+
|
|
150
161
|
const bottomSheet = instance.findByType(BottomSheet);
|
|
151
162
|
expect(bottomSheet.props.isVisible).toBe(true);
|
|
152
|
-
|
|
163
|
+
|
|
164
|
+
axios.patch.mockImplementationOnce(async () => ({
|
|
165
|
+
status: 200,
|
|
166
|
+
data: {
|
|
167
|
+
avatar_uri: 'uri',
|
|
168
|
+
},
|
|
169
|
+
}));
|
|
153
170
|
await chooseSetFaceIDOption(instance, 1);
|
|
171
|
+
|
|
154
172
|
expect(bottomSheet.props.isVisible).toBe(false);
|
|
173
|
+
expect(axios.patch).toBeCalled(); // call api update face id
|
|
155
174
|
});
|
|
156
175
|
|
|
157
176
|
test('Test register new member', async () => {
|
|
@@ -177,6 +196,7 @@ describe('Test HanetMemberInfo', () => {
|
|
|
177
196
|
expect(bottomSheet.props.isVisible).toBe(true);
|
|
178
197
|
|
|
179
198
|
await chooseSetFaceIDOption(instance, 1);
|
|
199
|
+
expect(axios.patch).not.toBeCalled(); // not call api
|
|
180
200
|
|
|
181
201
|
// open alert action
|
|
182
202
|
const alertAction = instance.findByType(AlertAction);
|
|
@@ -191,13 +211,15 @@ describe('Test HanetMemberInfo', () => {
|
|
|
191
211
|
await textInput.props.onChange('new name');
|
|
192
212
|
await alertAction.props.rightButtonClick();
|
|
193
213
|
});
|
|
214
|
+
expect(axios.post).not.toBeCalled();
|
|
194
215
|
|
|
195
216
|
// finish
|
|
196
217
|
const bottomButton = instance.findByType(BottomButtonView);
|
|
197
|
-
|
|
218
|
+
axios.post.mockImplementationOnce(async () => ({ status: 200 }));
|
|
198
219
|
await act(async () => {
|
|
199
220
|
await bottomButton.props.onPressMain();
|
|
200
221
|
});
|
|
222
|
+
expect(axios.post).toBeCalled();
|
|
201
223
|
expect(mockedNavigate).toBeCalled();
|
|
202
224
|
});
|
|
203
225
|
});
|
|
@@ -31,7 +31,7 @@ const RequestFaceIDPopup = ({
|
|
|
31
31
|
text: t('pick_available_image_from_your_phone'),
|
|
32
32
|
onChoose: async () => {
|
|
33
33
|
setHide();
|
|
34
|
-
const
|
|
34
|
+
const options = {
|
|
35
35
|
mediaType: 'photo',
|
|
36
36
|
compressImageMaxHeight: 1280,
|
|
37
37
|
compressImageMaxWidth: 738,
|
|
@@ -39,9 +39,8 @@ const RequestFaceIDPopup = ({
|
|
|
39
39
|
forceJpg: true,
|
|
40
40
|
};
|
|
41
41
|
try {
|
|
42
|
-
const result = await ImagePicker.openPicker(
|
|
42
|
+
const result = await ImagePicker.openPicker(options);
|
|
43
43
|
onChooseFile && onChooseFile(result);
|
|
44
|
-
// eslint-disable-next-line no-empty
|
|
45
44
|
} catch (e) {}
|
|
46
45
|
},
|
|
47
46
|
},
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
2
|
import { useHanetCheckinData } from '../index';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
import moment from 'moment';
|
|
5
|
-
import api from '../../../../utils/Apis/axios';
|
|
6
|
-
import { API } from '../../../../configs';
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
jest.mock('axios');
|
|
9
7
|
|
|
10
8
|
describe('Test useHanetCheckinData', () => {
|
|
11
9
|
let props, data;
|
|
12
10
|
|
|
13
11
|
beforeEach(() => {
|
|
14
12
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
13
|
+
axios.get.mockClear();
|
|
15
14
|
props = {
|
|
16
15
|
device_id: 1,
|
|
17
16
|
place: {
|
|
@@ -52,20 +51,40 @@ describe('Test useHanetCheckinData', () => {
|
|
|
52
51
|
|
|
53
52
|
test('Test onRefresh', async () => {
|
|
54
53
|
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
55
|
-
|
|
54
|
+
axios.get.mockImplementationOnce(() => ({
|
|
55
|
+
status: 200,
|
|
56
|
+
data: data,
|
|
57
|
+
}));
|
|
56
58
|
await act(async () => {
|
|
57
59
|
await result.current.onRefresh();
|
|
58
60
|
});
|
|
59
|
-
expect(
|
|
61
|
+
expect(axios.get).toHaveBeenCalled();
|
|
60
62
|
});
|
|
61
63
|
|
|
62
|
-
test('Test
|
|
63
|
-
const { result } = renderHook(() => useHanetCheckinData());
|
|
64
|
-
|
|
64
|
+
test('Test onLoadMore', async () => {
|
|
65
|
+
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
66
|
+
axios.get.mockImplementationOnce(() => ({
|
|
67
|
+
status: 200,
|
|
68
|
+
data: data,
|
|
69
|
+
}));
|
|
65
70
|
await act(async () => {
|
|
66
|
-
await result.current.
|
|
71
|
+
await result.current.onLoadMore();
|
|
72
|
+
});
|
|
73
|
+
expect(axios.get).toHaveBeenCalled();
|
|
74
|
+
|
|
75
|
+
axios.get.mockClear();
|
|
76
|
+
|
|
77
|
+
await act(async () => {
|
|
78
|
+
await result.current.onLoadMore();
|
|
79
|
+
});
|
|
80
|
+
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('Test onMomentumScrollBegin', async () => {
|
|
84
|
+
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
85
|
+
await act(async () => {
|
|
86
|
+
await result.current.onMomentumScrollBegin();
|
|
67
87
|
});
|
|
68
|
-
expect(result.current.refreshing).toBeFalsy();
|
|
69
88
|
});
|
|
70
89
|
|
|
71
90
|
test('Test onReceiveNewCheckinData', async () => {
|
|
@@ -82,9 +101,9 @@ describe('Test useHanetCheckinData', () => {
|
|
|
82
101
|
await act(async () => {
|
|
83
102
|
await result.current.onReceiveNewCheckinData(newData);
|
|
84
103
|
});
|
|
85
|
-
expect(result.current.checkinData).toHaveLength(
|
|
104
|
+
expect(result.current.checkinData).toHaveLength(1);
|
|
86
105
|
expect(result.current.countMember).toBe(1);
|
|
87
|
-
expect(result.current.countStranger).toBe(1);
|
|
106
|
+
expect(result.current.countStranger).not.toBe(1);
|
|
88
107
|
|
|
89
108
|
const newData2 = {
|
|
90
109
|
id: 2,
|
|
@@ -97,7 +116,7 @@ describe('Test useHanetCheckinData', () => {
|
|
|
97
116
|
await act(async () => {
|
|
98
117
|
await result.current.onReceiveNewCheckinData(newData2);
|
|
99
118
|
});
|
|
100
|
-
expect(result.current.checkinData).toHaveLength(
|
|
119
|
+
expect(result.current.checkinData).toHaveLength(2);
|
|
101
120
|
expect(result.current.countMember).toBe(1);
|
|
102
121
|
expect(result.current.countStranger).toBe(1);
|
|
103
122
|
|
|
@@ -113,7 +132,7 @@ describe('Test useHanetCheckinData', () => {
|
|
|
113
132
|
await result.current.onReceiveNewCheckinData(newData3);
|
|
114
133
|
});
|
|
115
134
|
// no change
|
|
116
|
-
expect(result.current.checkinData).toHaveLength(
|
|
135
|
+
expect(result.current.checkinData).toHaveLength(2);
|
|
117
136
|
expect(result.current.countMember).toBe(1);
|
|
118
137
|
expect(result.current.countStranger).toBe(1);
|
|
119
138
|
|
|
@@ -122,35 +141,8 @@ describe('Test useHanetCheckinData', () => {
|
|
|
122
141
|
await result.current.onReceiveNewCheckinData(newData2);
|
|
123
142
|
});
|
|
124
143
|
// no change
|
|
125
|
-
expect(result.current.checkinData).toHaveLength(
|
|
144
|
+
expect(result.current.checkinData).toHaveLength(2);
|
|
126
145
|
expect(result.current.countMember).toBe(1);
|
|
127
146
|
expect(result.current.countStranger).toBe(1);
|
|
128
147
|
});
|
|
129
|
-
|
|
130
|
-
test('Test onLoadMore', async () => {
|
|
131
|
-
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
132
|
-
mock
|
|
133
|
-
.onGet(API.CAMERA.HANET.CHECKIN(1))
|
|
134
|
-
.reply(200, { ...data, count_member: 20 });
|
|
135
|
-
await act(async () => {
|
|
136
|
-
await result.current.onLoadMore();
|
|
137
|
-
});
|
|
138
|
-
expect(result.current.countMember).toBe(20);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test('Test onMomentumScrollBegin', async () => {
|
|
142
|
-
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
143
|
-
await act(async () => {
|
|
144
|
-
await result.current.onMomentumScrollBegin();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test('Test onChangeDate', async () => {
|
|
149
|
-
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
150
|
-
mock.onGet(API.CAMERA.HANET.CHECKIN(1, moment())).reply(200, data);
|
|
151
|
-
await act(async () => {
|
|
152
|
-
await result.current.onChangeDate(moment());
|
|
153
|
-
});
|
|
154
|
-
expect(result.current.countMember).toBe(data.count_member);
|
|
155
|
-
});
|
|
156
148
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
2
|
import { useHanetPlaceMembers } from '../index';
|
|
3
|
-
import
|
|
4
|
-
import api from '../../../../utils/Apis/axios';
|
|
5
|
-
import { API } from '../../../../configs';
|
|
3
|
+
import axios from 'axios';
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
jest.mock('axios');
|
|
8
6
|
|
|
9
7
|
describe('Test useHanetPlaceMembers', () => {
|
|
10
8
|
let props, data;
|
|
11
9
|
|
|
12
10
|
beforeEach(() => {
|
|
11
|
+
axios.get.mockClear();
|
|
13
12
|
props = {
|
|
14
13
|
place: {
|
|
15
14
|
place_id: 2,
|
|
@@ -34,20 +33,33 @@ describe('Test useHanetPlaceMembers', () => {
|
|
|
34
33
|
|
|
35
34
|
test('Test onRefresh', async () => {
|
|
36
35
|
const { result } = renderHook(() => useHanetPlaceMembers(props));
|
|
37
|
-
|
|
36
|
+
axios.get.mockImplementationOnce(() => ({
|
|
37
|
+
status: 200,
|
|
38
|
+
data: data,
|
|
39
|
+
}));
|
|
38
40
|
await act(async () => {
|
|
39
41
|
await result.current.onRefresh();
|
|
40
42
|
});
|
|
41
|
-
expect(
|
|
43
|
+
expect(axios.get).toHaveBeenCalled();
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
test('Test onLoadMore', async () => {
|
|
45
|
-
const { result } = renderHook(() => useHanetPlaceMembers());
|
|
46
|
-
|
|
47
|
+
const { result } = renderHook(() => useHanetPlaceMembers(props));
|
|
48
|
+
axios.get.mockImplementationOnce(() => ({
|
|
49
|
+
status: 200,
|
|
50
|
+
data: data,
|
|
51
|
+
}));
|
|
52
|
+
await act(async () => {
|
|
53
|
+
await result.current.onLoadMore();
|
|
54
|
+
});
|
|
55
|
+
expect(axios.get).toHaveBeenCalled();
|
|
56
|
+
|
|
57
|
+
axios.get.mockClear();
|
|
58
|
+
|
|
47
59
|
await act(async () => {
|
|
48
60
|
await result.current.onLoadMore();
|
|
49
61
|
});
|
|
50
|
-
expect(
|
|
62
|
+
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
51
63
|
});
|
|
52
64
|
|
|
53
65
|
test('Test onMomentumScrollBegin', async () => {
|
|
@@ -55,6 +67,5 @@ describe('Test useHanetPlaceMembers', () => {
|
|
|
55
67
|
await act(async () => {
|
|
56
68
|
await result.current.onMomentumScrollBegin();
|
|
57
69
|
});
|
|
58
|
-
expect(result.current.loadingMore).toBe(false);
|
|
59
70
|
});
|
|
60
71
|
});
|
|
@@ -16,13 +16,13 @@ const useHanetCheckinData = (hanetCamera) => {
|
|
|
16
16
|
const [loadingMore, setLoadingMore] = useState(false);
|
|
17
17
|
const [canLoadMore, setCanLoadMore] = useState(true);
|
|
18
18
|
|
|
19
|
-
const fetchData = async (
|
|
19
|
+
const fetchData = async (page, date) => {
|
|
20
20
|
if (!hanetCamera) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
setPage(
|
|
24
|
-
setDate(
|
|
25
|
-
if (
|
|
23
|
+
setPage(page);
|
|
24
|
+
setDate(date);
|
|
25
|
+
if (page === 1) {
|
|
26
26
|
setRefreshing(true);
|
|
27
27
|
} else {
|
|
28
28
|
if (!canLoadMore) {
|
|
@@ -32,8 +32,8 @@ const useHanetCheckinData = (hanetCamera) => {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const params = new URLSearchParams();
|
|
35
|
-
params.append('page',
|
|
36
|
-
params.append('date',
|
|
35
|
+
params.append('page', page);
|
|
36
|
+
params.append('date', date.format('YYYY-MM-DD'));
|
|
37
37
|
const { success, data } = await axiosGet(
|
|
38
38
|
API.CAMERA.HANET.CHECKIN(hanetCamera.device_id),
|
|
39
39
|
{
|
|
@@ -43,17 +43,17 @@ const useHanetCheckinData = (hanetCamera) => {
|
|
|
43
43
|
if (success && data) {
|
|
44
44
|
setCountMember(data.count_member);
|
|
45
45
|
setCountStranger(data.count_stranger);
|
|
46
|
-
if (
|
|
46
|
+
if (page === 1) {
|
|
47
47
|
setCheckinData(data.results || []);
|
|
48
48
|
} else {
|
|
49
|
-
setCanLoadMore(
|
|
49
|
+
setCanLoadMore(page < Math.ceil(data.count / 20));
|
|
50
50
|
setCheckinData((prevData) =>
|
|
51
51
|
_.uniqBy(prevData.concat(data.results || []), 'id')
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (
|
|
56
|
+
if (page === 1) {
|
|
57
57
|
setRefreshing(false);
|
|
58
58
|
} else {
|
|
59
59
|
setLoadingMore(false);
|
|
@@ -75,8 +75,8 @@ const useHanetCheckinData = (hanetCamera) => {
|
|
|
75
75
|
const onMomentumScrollBegin = () =>
|
|
76
76
|
(onEndReachedCalledDuringMomentum = false);
|
|
77
77
|
|
|
78
|
-
const onChangeDate = (
|
|
79
|
-
fetchData(page,
|
|
78
|
+
const onChangeDate = (date) => {
|
|
79
|
+
fetchData(page, date);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const onReceiveNewCheckinData = (data) => {
|
|
@@ -13,12 +13,12 @@ const useHanetPlaceMembers = (place) => {
|
|
|
13
13
|
const [loadingMore, setLoadingMore] = useState(false);
|
|
14
14
|
const [canLoadMore, setCanLoadMore] = useState(true);
|
|
15
15
|
|
|
16
|
-
const fetchData = async (
|
|
16
|
+
const fetchData = async (page) => {
|
|
17
17
|
if (!place) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
setPage(
|
|
21
|
-
if (
|
|
20
|
+
setPage(page);
|
|
21
|
+
if (page === 1) {
|
|
22
22
|
setRefreshing(true);
|
|
23
23
|
} else {
|
|
24
24
|
if (!canLoadMore) {
|
|
@@ -28,23 +28,23 @@ const useHanetPlaceMembers = (place) => {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const params = new URLSearchParams();
|
|
31
|
-
params.append('page',
|
|
32
|
-
const { success, data
|
|
31
|
+
params.append('page', page);
|
|
32
|
+
const { success, data } = await axiosGet(
|
|
33
33
|
API.CAMERA.HANET.PLACE_MEMBERS(place.place_id),
|
|
34
34
|
{
|
|
35
35
|
params,
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
|
-
if (success &&
|
|
39
|
-
if (
|
|
40
|
-
setData(
|
|
38
|
+
if (success && data) {
|
|
39
|
+
if (page === 1) {
|
|
40
|
+
setData(data.results || []);
|
|
41
41
|
} else {
|
|
42
|
-
setCanLoadMore(
|
|
43
|
-
setData((prevData) => prevData.concat(
|
|
42
|
+
setCanLoadMore(page < Math.ceil(data.count / 20));
|
|
43
|
+
setData((prevData) => prevData.concat(data.results || []));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (
|
|
47
|
+
if (page === 1) {
|
|
48
48
|
setRefreshing(false);
|
|
49
49
|
} else {
|
|
50
50
|
setLoadingMore(false);
|