@eohjsc/react-native-smart-city 0.2.97 → 0.3.0
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 +35 -14
- package/package.json +4 -2
- package/src/commons/Action/ItemQuickAction.js +5 -2
- package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -3
- package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
- package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +135 -0
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/index.js +1 -1
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +4 -0
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
- package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
- package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/MenuActionAddnew/index.js +1 -0
- package/src/commons/MenuActionList/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
- package/src/commons/PreventAccess/index.js +9 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/WheelDateTimePicker/index.js +2 -1
- package/src/configs/API.js +87 -138
- package/src/configs/Constants.js +27 -1
- package/src/configs/SCConfig.js +2 -0
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +8 -30
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -0
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/index.js +4 -1
- package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -33
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +21 -21
- package/src/screens/AddNewDevice/index.js +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +3 -2
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +2 -0
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/__test__/detail.test.js +23 -84
- package/src/screens/Device/detail.js +31 -8
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/Explore/index.js +2 -0
- package/src/screens/GuestInfo/__test__/index.test.js +14 -41
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/index.js +2 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +5 -5
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +4 -3
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +19 -3
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +5 -4
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +5 -2
- package/src/screens/SetSchedule/index.js +6 -2
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +107 -70
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/Sharing/hooks/index.js +3 -0
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
- package/src/screens/SideMenuDetail/index.js +149 -0
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/ManageSubUnit.js +1 -0
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +47 -44
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +4 -1
- package/src/screens/Unit/Station/index.js +1 -0
- package/src/screens/Unit/Summaries.js +1 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +15 -28
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +83 -185
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +13 -39
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/UnitSummary/__test__/index.test.js +38 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +37 -13
- package/src/utils/I18n/translations/en.json +1 -0
- package/src/utils/I18n/translations/vi.json +1 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Utils.js +6 -6
|
@@ -30,7 +30,7 @@ const TemporaryDetail = ({
|
|
|
30
30
|
</Text>
|
|
31
31
|
<TouchableOpacity
|
|
32
32
|
onPress={onSetTimeStart}
|
|
33
|
-
testID={TESTID.
|
|
33
|
+
testID={TESTID.TEMPORARY_START_TEXT_BUTTON}
|
|
34
34
|
>
|
|
35
35
|
<Text type="Body" color={Colors.Orange} style={styles.value}>
|
|
36
36
|
{moment(temporaryTimeStart).format('hh:mm A DD/MM/YYYY')}
|
|
@@ -41,7 +41,7 @@ const TemporaryDetail = ({
|
|
|
41
41
|
</Text>
|
|
42
42
|
<TouchableOpacity
|
|
43
43
|
onPress={onSetTimeEnd}
|
|
44
|
-
testID={TESTID.
|
|
44
|
+
testID={TESTID.TEMPORARY_END_TEXT_BUTTON}
|
|
45
45
|
>
|
|
46
46
|
<Text type="Body" color={Colors.Orange} style={styles.value}>
|
|
47
47
|
{moment(temporaryTimeEnd).format('hh:mm A DD/MM/YYYY')}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { create, act } from 'react-test-renderer';
|
|
4
|
-
import
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
5
|
import { SCProvider } from '../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
7
|
import HanetCaptureFaceID from '../CaptureFaceID';
|
|
8
8
|
import { RNCamera } from 'react-native-camera';
|
|
9
|
+
import api from '../../../utils/Apis/axios';
|
|
10
|
+
import { API } from '../../../configs';
|
|
11
|
+
|
|
12
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
9
13
|
|
|
10
14
|
const wrapComponent = (route) => (
|
|
11
15
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -32,8 +36,6 @@ jest.mock('@react-navigation/native', () => {
|
|
|
32
36
|
};
|
|
33
37
|
});
|
|
34
38
|
|
|
35
|
-
jest.mock('axios');
|
|
36
|
-
|
|
37
39
|
const mockSetAvatar = jest.fn();
|
|
38
40
|
describe('Test HanetCaptureFaceID', () => {
|
|
39
41
|
let tree, route;
|
|
@@ -42,7 +44,6 @@ describe('Test HanetCaptureFaceID', () => {
|
|
|
42
44
|
mockedNavigate.mockClear();
|
|
43
45
|
mockedGoBack.mockClear();
|
|
44
46
|
mockSetAvatar.mockClear();
|
|
45
|
-
axios.patch.mockClear();
|
|
46
47
|
route = {
|
|
47
48
|
params: {
|
|
48
49
|
title: 'title',
|
|
@@ -96,20 +97,15 @@ describe('Test HanetCaptureFaceID', () => {
|
|
|
96
97
|
|
|
97
98
|
// capture face id
|
|
98
99
|
await captureFaceID(instance);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
data: {
|
|
103
|
-
avatar_uri: 'avatar_uri',
|
|
104
|
-
},
|
|
105
|
-
}));
|
|
100
|
+
mock.onPatch(API.CAMERA.HANET.UPDATE_FACE_ID(1, 1)).reply(200, {
|
|
101
|
+
avatar_uri: 'avatar_uri',
|
|
102
|
+
});
|
|
106
103
|
|
|
107
104
|
// continue
|
|
108
105
|
let touches = instance.findAllByType(TouchableOpacity);
|
|
109
106
|
await act(async () => {
|
|
110
107
|
await touches[1].props.onPress();
|
|
111
108
|
});
|
|
112
|
-
expect(axios.patch).toHaveBeenCalled();
|
|
113
109
|
expect(mockSetAvatar).toHaveBeenCalled();
|
|
114
110
|
expect(mockedGoBack).toHaveBeenCalled();
|
|
115
111
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlatList } from 'react-native';
|
|
3
3
|
import { create, act } from 'react-test-renderer';
|
|
4
|
-
import
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
+
|
|
5
6
|
import { SCProvider } from '../../../context';
|
|
6
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
8
|
import HanetCameraDetail from '../Detail';
|
|
@@ -9,6 +10,9 @@ import CheckinHeader from '../components/CheckinHeader';
|
|
|
9
10
|
import moment from 'moment';
|
|
10
11
|
import { TESTID } from '../../../configs/Constants';
|
|
11
12
|
import Calendar from '../../../commons/Calendar';
|
|
13
|
+
import api from '../../../utils/Apis/axios';
|
|
14
|
+
import { API } from '../../../configs';
|
|
15
|
+
import { MenuActionMore } from '../../../commons';
|
|
12
16
|
|
|
13
17
|
const wrapComponent = (route) => (
|
|
14
18
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -16,6 +20,19 @@ const wrapComponent = (route) => (
|
|
|
16
20
|
</SCProvider>
|
|
17
21
|
);
|
|
18
22
|
|
|
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
|
+
|
|
19
36
|
jest.mock('react', () => {
|
|
20
37
|
return {
|
|
21
38
|
...jest.requireActual('react'),
|
|
@@ -23,14 +40,11 @@ jest.mock('react', () => {
|
|
|
23
40
|
};
|
|
24
41
|
});
|
|
25
42
|
|
|
26
|
-
jest.mock('axios');
|
|
27
|
-
|
|
28
43
|
describe('Test HanetCameraDetail', () => {
|
|
29
44
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
30
45
|
let tree, route, responseDisplay, responseCheckin;
|
|
31
46
|
|
|
32
47
|
beforeEach(() => {
|
|
33
|
-
axios.get.mockClear();
|
|
34
48
|
route = {
|
|
35
49
|
params: {
|
|
36
50
|
unit: {
|
|
@@ -87,20 +101,14 @@ describe('Test HanetCameraDetail', () => {
|
|
|
87
101
|
});
|
|
88
102
|
|
|
89
103
|
test('Test render HanetCameraDetail', async () => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
axios.get.mockImplementationOnce(async () => {
|
|
94
|
-
return responseCheckin;
|
|
95
|
-
});
|
|
104
|
+
mock.onGet(API.SENSOR.DISPLAY(1)).reply(200, responseDisplay.data);
|
|
105
|
+
mock.onGet(API.CAMERA.HANET.CHECKIN(2)).reply(200, responseCheckin.data);
|
|
96
106
|
await act(async () => {
|
|
97
107
|
tree = await create(wrapComponent(route));
|
|
98
108
|
});
|
|
99
109
|
const instance = tree.root;
|
|
100
|
-
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
101
110
|
const flatLists = instance.findAllByType(FlatList);
|
|
102
111
|
expect(flatLists).toHaveLength(1);
|
|
103
|
-
|
|
104
112
|
const textCountMember = instance.find(
|
|
105
113
|
(el) => el.props.testID === TESTID.TEXT_COUNT_MEMBER
|
|
106
114
|
);
|
|
@@ -109,50 +117,33 @@ describe('Test HanetCameraDetail', () => {
|
|
|
109
117
|
);
|
|
110
118
|
expect(textCountMember.props.children).toBe(1);
|
|
111
119
|
expect(textCountStranger.props.children).toBe(1);
|
|
120
|
+
const MenuActionMores = instance.findByType(MenuActionMore);
|
|
121
|
+
await MenuActionMores.props.onItemClick({ data: 'test' });
|
|
122
|
+
expect(mockNavigate).toBeCalled();
|
|
112
123
|
});
|
|
113
124
|
|
|
114
125
|
test('Test change date', async () => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
axios.get.mockImplementationOnce(async () => {
|
|
119
|
-
return responseCheckin;
|
|
120
|
-
});
|
|
126
|
+
mock.onGet(API.SENSOR.DISPLAY(1)).reply(200, responseDisplay.data);
|
|
127
|
+
mock.onGet(API.CAMERA.HANET.CHECKIN(1)).reply(200, responseCheckin.data);
|
|
121
128
|
await act(async () => {
|
|
122
129
|
tree = await create(wrapComponent(route));
|
|
123
130
|
});
|
|
124
131
|
const instance = tree.root;
|
|
125
|
-
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
126
|
-
axios.get.mockClear();
|
|
127
|
-
|
|
128
132
|
const checkinHeader = instance.findByType(CheckinHeader);
|
|
129
|
-
|
|
130
133
|
// press arrow left
|
|
131
|
-
|
|
132
|
-
return responseCheckin;
|
|
133
|
-
});
|
|
134
|
+
mock.onGet(API.CAMERA.HANET.CHECKIN(1)).reply(200, responseCheckin.data);
|
|
134
135
|
await act(async () => {
|
|
135
136
|
await checkinHeader.props.onPickPreviousDate();
|
|
136
137
|
});
|
|
137
138
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
138
139
|
moment().add(-1, 'days').format('DD/MM/YYYY')
|
|
139
140
|
);
|
|
140
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
141
|
-
axios.get.mockClear();
|
|
142
|
-
|
|
143
|
-
// press arrow right
|
|
144
|
-
axios.get.mockImplementationOnce(async () => {
|
|
145
|
-
return responseCheckin;
|
|
146
|
-
});
|
|
147
141
|
await act(async () => {
|
|
148
142
|
await checkinHeader.props.onPickNextDate();
|
|
149
143
|
});
|
|
150
144
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
151
145
|
moment().format('DD/MM/YYYY')
|
|
152
146
|
);
|
|
153
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
154
|
-
axios.get.mockClear();
|
|
155
|
-
|
|
156
147
|
// press arrow right
|
|
157
148
|
await act(async () => {
|
|
158
149
|
await checkinHeader.props.onPickNextDate();
|
|
@@ -160,9 +151,6 @@ describe('Test HanetCameraDetail', () => {
|
|
|
160
151
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
161
152
|
moment().format('DD/MM/YYYY')
|
|
162
153
|
); // no change
|
|
163
|
-
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
164
|
-
axios.get.mockClear();
|
|
165
|
-
|
|
166
154
|
// open calendar
|
|
167
155
|
await act(async () => {
|
|
168
156
|
await checkinHeader.props.setShowCalendar();
|
|
@@ -171,15 +159,12 @@ describe('Test HanetCameraDetail', () => {
|
|
|
171
159
|
expect(calendar.props.isVisible).toBe(true);
|
|
172
160
|
|
|
173
161
|
// choose date on calendar
|
|
174
|
-
|
|
175
|
-
return responseCheckin;
|
|
176
|
-
});
|
|
162
|
+
mock.onGet(API.CAMERA.HANET.CHECKIN(1)).reply(200, responseCheckin.data);
|
|
177
163
|
await act(async () => {
|
|
178
164
|
await calendar.props.onConfirm(moment().add(-1, 'days'));
|
|
179
165
|
});
|
|
180
166
|
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
181
167
|
moment().add(-1, 'days').format('DD/MM/YYYY')
|
|
182
168
|
);
|
|
183
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
184
169
|
});
|
|
185
170
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlatList } from 'react-native';
|
|
3
3
|
import { create, act } from 'react-test-renderer';
|
|
4
|
-
import
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
+
|
|
5
6
|
import { SCProvider } from '../../../context';
|
|
6
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
8
|
import HanetManageAccess from '../ManageAccess';
|
|
@@ -9,6 +10,10 @@ import BottomSheet from '../../../commons/BottomSheet';
|
|
|
9
10
|
import { TESTID } from '../../../configs/Constants';
|
|
10
11
|
import Routes from '../../../utils/Route';
|
|
11
12
|
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);
|
|
12
17
|
|
|
13
18
|
const wrapComponent = (route) => (
|
|
14
19
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -34,14 +39,11 @@ jest.mock('@react-navigation/native', () => {
|
|
|
34
39
|
};
|
|
35
40
|
});
|
|
36
41
|
|
|
37
|
-
jest.mock('axios');
|
|
38
|
-
|
|
39
42
|
describe('Test HanetManageAccess', () => {
|
|
40
43
|
let tree, route, response;
|
|
41
44
|
|
|
42
45
|
beforeEach(() => {
|
|
43
46
|
mockedNavigate.mockClear();
|
|
44
|
-
axios.get.mockClear();
|
|
45
47
|
route = {
|
|
46
48
|
params: {
|
|
47
49
|
hanetPlace: {
|
|
@@ -70,7 +72,8 @@ describe('Test HanetManageAccess', () => {
|
|
|
70
72
|
],
|
|
71
73
|
},
|
|
72
74
|
};
|
|
73
|
-
|
|
75
|
+
|
|
76
|
+
mock.onGet(API.CAMERA.HANET.PLACE_MEMBERS(1)).reply(200, response.data);
|
|
74
77
|
await act(async () => {
|
|
75
78
|
tree = await create(wrapComponent(route));
|
|
76
79
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { create, act } from 'react-test-renderer';
|
|
4
|
-
import
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
+
|
|
5
6
|
import { SCProvider } from '../../../context';
|
|
6
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
8
|
import HanetMemberInfo from '../MemberInfo';
|
|
@@ -10,6 +11,8 @@ import TextInput from '../../../commons/Form/TextInput';
|
|
|
10
11
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
11
12
|
import BottomSheet from '../../../commons/BottomSheet';
|
|
12
13
|
import { TESTID } from '../../../configs/Constants';
|
|
14
|
+
import api from '../../../utils/Apis/axios';
|
|
15
|
+
import { API } from '../../../configs';
|
|
13
16
|
|
|
14
17
|
const wrapComponent = (route) => (
|
|
15
18
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -37,7 +40,7 @@ jest.mock('@react-navigation/native', () => {
|
|
|
37
40
|
};
|
|
38
41
|
});
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
41
44
|
|
|
42
45
|
describe('Test HanetMemberInfo', () => {
|
|
43
46
|
let tree, route;
|
|
@@ -45,9 +48,6 @@ describe('Test HanetMemberInfo', () => {
|
|
|
45
48
|
beforeEach(() => {
|
|
46
49
|
mockedNavigate.mockClear();
|
|
47
50
|
mockedGoBack.mockClear();
|
|
48
|
-
axios.post.mockClear();
|
|
49
|
-
axios.patch.mockClear();
|
|
50
|
-
axios.delete.mockClear();
|
|
51
51
|
route = {
|
|
52
52
|
params: {
|
|
53
53
|
hanetPlace: {
|
|
@@ -72,23 +72,18 @@ describe('Test HanetMemberInfo', () => {
|
|
|
72
72
|
const touches = instance.findAllByType(TouchableOpacity);
|
|
73
73
|
expect(touches).toHaveLength(7);
|
|
74
74
|
const alertAction = instance.findByType(AlertAction);
|
|
75
|
-
|
|
76
75
|
// open alert action
|
|
77
76
|
await act(async () => {
|
|
78
77
|
await touches[2].props.onPress();
|
|
79
78
|
});
|
|
80
|
-
expect(alertAction.props.visible).toBe(true);
|
|
81
|
-
|
|
82
79
|
const textInput = instance.findByType(TextInput);
|
|
83
|
-
|
|
84
|
-
axios.patch.mockImplementationOnce(async () => ({ status: 200 }));
|
|
85
|
-
|
|
80
|
+
mock.onPatch(API.CAMERA.HANET.RENAME_MEMBER(1, 1)).reply(200);
|
|
86
81
|
// change name and press rename
|
|
87
82
|
await act(async () => {
|
|
88
83
|
await textInput.props.onChange('new name');
|
|
89
84
|
await alertAction.props.rightButtonClick();
|
|
90
85
|
});
|
|
91
|
-
expect(
|
|
86
|
+
expect(alertAction.props.visible).toBe(false);
|
|
92
87
|
});
|
|
93
88
|
|
|
94
89
|
test('Test remove member', async () => {
|
|
@@ -105,15 +100,11 @@ describe('Test HanetMemberInfo', () => {
|
|
|
105
100
|
await touches[3].props.onPress();
|
|
106
101
|
});
|
|
107
102
|
expect(alertAction.props.visible).toBe(true);
|
|
108
|
-
|
|
109
|
-
axios.delete.mockImplementationOnce(async () => ({ status: 200 }));
|
|
110
|
-
|
|
103
|
+
mock.onDelete(API.CAMERA.HANET.REMOVE_MEMBER(1, 1)).reply(200);
|
|
111
104
|
// press remove
|
|
112
105
|
await act(async () => {
|
|
113
106
|
await alertAction.props.rightButtonClick();
|
|
114
107
|
});
|
|
115
|
-
|
|
116
|
-
expect(axios.delete).toHaveBeenCalled();
|
|
117
108
|
expect(mockedGoBack).toHaveBeenCalled();
|
|
118
109
|
});
|
|
119
110
|
|
|
@@ -153,24 +144,14 @@ describe('Test HanetMemberInfo', () => {
|
|
|
153
144
|
const instance = tree.root;
|
|
154
145
|
const touches = instance.findAllByType(TouchableOpacity);
|
|
155
146
|
expect(touches).toHaveLength(7);
|
|
156
|
-
|
|
157
147
|
await act(async () => {
|
|
158
148
|
await touches[1].props.onPress();
|
|
159
149
|
});
|
|
160
|
-
|
|
161
150
|
const bottomSheet = instance.findByType(BottomSheet);
|
|
162
151
|
expect(bottomSheet.props.isVisible).toBe(true);
|
|
163
|
-
|
|
164
|
-
axios.patch.mockImplementationOnce(async () => ({
|
|
165
|
-
status: 200,
|
|
166
|
-
data: {
|
|
167
|
-
avatar_uri: 'uri',
|
|
168
|
-
},
|
|
169
|
-
}));
|
|
152
|
+
mock.onPatch(API.CAMERA.HANET.UPDATE_FACE_ID(1, 1)).reply(200);
|
|
170
153
|
await chooseSetFaceIDOption(instance, 1);
|
|
171
|
-
|
|
172
154
|
expect(bottomSheet.props.isVisible).toBe(false);
|
|
173
|
-
expect(axios.patch).toBeCalled(); // call api update face id
|
|
174
155
|
});
|
|
175
156
|
|
|
176
157
|
test('Test register new member', async () => {
|
|
@@ -196,7 +177,6 @@ describe('Test HanetMemberInfo', () => {
|
|
|
196
177
|
expect(bottomSheet.props.isVisible).toBe(true);
|
|
197
178
|
|
|
198
179
|
await chooseSetFaceIDOption(instance, 1);
|
|
199
|
-
expect(axios.patch).not.toBeCalled(); // not call api
|
|
200
180
|
|
|
201
181
|
// open alert action
|
|
202
182
|
const alertAction = instance.findByType(AlertAction);
|
|
@@ -211,15 +191,13 @@ describe('Test HanetMemberInfo', () => {
|
|
|
211
191
|
await textInput.props.onChange('new name');
|
|
212
192
|
await alertAction.props.rightButtonClick();
|
|
213
193
|
});
|
|
214
|
-
expect(axios.post).not.toBeCalled();
|
|
215
194
|
|
|
216
195
|
// finish
|
|
217
196
|
const bottomButton = instance.findByType(BottomButtonView);
|
|
218
|
-
|
|
197
|
+
mock.onPost(API.CAMERA.HANET.REGISTER(1)).reply(200);
|
|
219
198
|
await act(async () => {
|
|
220
199
|
await bottomButton.props.onPressMain();
|
|
221
200
|
});
|
|
222
|
-
expect(axios.post).toBeCalled();
|
|
223
201
|
expect(mockedNavigate).toBeCalled();
|
|
224
202
|
});
|
|
225
203
|
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
2
|
import { useHanetCheckinData } from '../index';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
4
|
import moment from 'moment';
|
|
5
|
+
import api from '../../../../utils/Apis/axios';
|
|
6
|
+
import { API } from '../../../../configs';
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
7
9
|
|
|
8
10
|
describe('Test useHanetCheckinData', () => {
|
|
9
11
|
let props, data;
|
|
10
12
|
|
|
11
13
|
beforeEach(() => {
|
|
12
14
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
13
|
-
axios.get.mockClear();
|
|
14
15
|
props = {
|
|
15
16
|
device_id: 1,
|
|
16
17
|
place: {
|
|
@@ -51,40 +52,20 @@ describe('Test useHanetCheckinData', () => {
|
|
|
51
52
|
|
|
52
53
|
test('Test onRefresh', async () => {
|
|
53
54
|
const { result } = renderHook(() => useHanetCheckinData(props));
|
|
54
|
-
|
|
55
|
-
status: 200,
|
|
56
|
-
data: data,
|
|
57
|
-
}));
|
|
55
|
+
mock.onGet(API.CAMERA.HANET.CHECKIN(1)).reply(200, data);
|
|
58
56
|
await act(async () => {
|
|
59
57
|
await result.current.onRefresh();
|
|
60
58
|
});
|
|
61
|
-
expect(
|
|
59
|
+
expect(result.current.countMember).toBe(data.count_member);
|
|
62
60
|
});
|
|
63
61
|
|
|
64
|
-
test('Test
|
|
65
|
-
const { result } = renderHook(() => useHanetCheckinData(
|
|
66
|
-
|
|
67
|
-
status: 200,
|
|
68
|
-
data: data,
|
|
69
|
-
}));
|
|
70
|
-
await act(async () => {
|
|
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));
|
|
62
|
+
test('Test render without props', async () => {
|
|
63
|
+
const { result } = renderHook(() => useHanetCheckinData());
|
|
64
|
+
mock.onGet(API.CAMERA.HANET.CHECKIN(1)).reply(200, data);
|
|
85
65
|
await act(async () => {
|
|
86
|
-
await result.current.
|
|
66
|
+
await result.current.onRefresh();
|
|
87
67
|
});
|
|
68
|
+
expect(result.current.refreshing).toBeFalsy();
|
|
88
69
|
});
|
|
89
70
|
|
|
90
71
|
test('Test onReceiveNewCheckinData', async () => {
|
|
@@ -101,9 +82,9 @@ describe('Test useHanetCheckinData', () => {
|
|
|
101
82
|
await act(async () => {
|
|
102
83
|
await result.current.onReceiveNewCheckinData(newData);
|
|
103
84
|
});
|
|
104
|
-
expect(result.current.checkinData).toHaveLength(
|
|
85
|
+
expect(result.current.checkinData).toHaveLength(3);
|
|
105
86
|
expect(result.current.countMember).toBe(1);
|
|
106
|
-
expect(result.current.countStranger).
|
|
87
|
+
expect(result.current.countStranger).toBe(1);
|
|
107
88
|
|
|
108
89
|
const newData2 = {
|
|
109
90
|
id: 2,
|
|
@@ -116,7 +97,7 @@ describe('Test useHanetCheckinData', () => {
|
|
|
116
97
|
await act(async () => {
|
|
117
98
|
await result.current.onReceiveNewCheckinData(newData2);
|
|
118
99
|
});
|
|
119
|
-
expect(result.current.checkinData).toHaveLength(
|
|
100
|
+
expect(result.current.checkinData).toHaveLength(3);
|
|
120
101
|
expect(result.current.countMember).toBe(1);
|
|
121
102
|
expect(result.current.countStranger).toBe(1);
|
|
122
103
|
|
|
@@ -132,7 +113,7 @@ describe('Test useHanetCheckinData', () => {
|
|
|
132
113
|
await result.current.onReceiveNewCheckinData(newData3);
|
|
133
114
|
});
|
|
134
115
|
// no change
|
|
135
|
-
expect(result.current.checkinData).toHaveLength(
|
|
116
|
+
expect(result.current.checkinData).toHaveLength(3);
|
|
136
117
|
expect(result.current.countMember).toBe(1);
|
|
137
118
|
expect(result.current.countStranger).toBe(1);
|
|
138
119
|
|
|
@@ -141,8 +122,35 @@ describe('Test useHanetCheckinData', () => {
|
|
|
141
122
|
await result.current.onReceiveNewCheckinData(newData2);
|
|
142
123
|
});
|
|
143
124
|
// no change
|
|
144
|
-
expect(result.current.checkinData).toHaveLength(
|
|
125
|
+
expect(result.current.checkinData).toHaveLength(3);
|
|
145
126
|
expect(result.current.countMember).toBe(1);
|
|
146
127
|
expect(result.current.countStranger).toBe(1);
|
|
147
128
|
});
|
|
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
|
+
});
|
|
148
156
|
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
2
|
import { useHanetPlaceMembers } from '../index';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
import api from '../../../../utils/Apis/axios';
|
|
5
|
+
import { API } from '../../../../configs';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
6
8
|
|
|
7
9
|
describe('Test useHanetPlaceMembers', () => {
|
|
8
10
|
let props, data;
|
|
9
11
|
|
|
10
12
|
beforeEach(() => {
|
|
11
|
-
axios.get.mockClear();
|
|
12
13
|
props = {
|
|
13
14
|
place: {
|
|
14
15
|
place_id: 2,
|
|
@@ -33,33 +34,20 @@ describe('Test useHanetPlaceMembers', () => {
|
|
|
33
34
|
|
|
34
35
|
test('Test onRefresh', async () => {
|
|
35
36
|
const { result } = renderHook(() => useHanetPlaceMembers(props));
|
|
36
|
-
|
|
37
|
-
status: 200,
|
|
38
|
-
data: data,
|
|
39
|
-
}));
|
|
37
|
+
mock.onGet(API.CAMERA.HANET.PLACE_MEMBERS(1)).reply(200, data);
|
|
40
38
|
await act(async () => {
|
|
41
39
|
await result.current.onRefresh();
|
|
42
40
|
});
|
|
43
|
-
expect(
|
|
41
|
+
expect(result.current.loadingMore).toBe(false);
|
|
44
42
|
});
|
|
45
43
|
|
|
46
44
|
test('Test onLoadMore', async () => {
|
|
47
|
-
const { result } = renderHook(() => useHanetPlaceMembers(
|
|
48
|
-
|
|
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
|
-
|
|
45
|
+
const { result } = renderHook(() => useHanetPlaceMembers());
|
|
46
|
+
mock.onGet(API.CAMERA.HANET.PLACE_MEMBERS(1)).reply(200, data);
|
|
59
47
|
await act(async () => {
|
|
60
48
|
await result.current.onLoadMore();
|
|
61
49
|
});
|
|
62
|
-
expect(
|
|
50
|
+
expect(result.current.loadingMore).toBe(false);
|
|
63
51
|
});
|
|
64
52
|
|
|
65
53
|
test('Test onMomentumScrollBegin', async () => {
|
|
@@ -67,5 +55,6 @@ describe('Test useHanetPlaceMembers', () => {
|
|
|
67
55
|
await act(async () => {
|
|
68
56
|
await result.current.onMomentumScrollBegin();
|
|
69
57
|
});
|
|
58
|
+
expect(result.current.loadingMore).toBe(false);
|
|
70
59
|
});
|
|
71
60
|
});
|