@eohjsc/react-native-smart-city 0.2.99 → 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/package.json +3 -1
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- 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/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- 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/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/LinearChart.js +15 -0
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +19 -14
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -3
- 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/configs/API.js +85 -139
- package/src/configs/Constants.js +11 -0
- 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/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/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- 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/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/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -23
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- 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 +22 -83
- package/src/screens/Device/detail.js +4 -6
- 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 +1 -1
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +18 -14
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +30 -31
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +13 -40
- 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 +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +4 -4
- 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/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +2 -1
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- 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/SideMenuDetail/__test__/index.test.js +10 -21
- 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/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/ManageUnit.js +1 -0
- 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 +18 -43
- 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/utils/Apis/axios.js +37 -13
- package/src/utils/Utils.js +6 -6
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
import Toast from 'react-native-toast-message';
|
|
5
|
+
|
|
4
6
|
import { EmergencyContactsSelectContacts } from '../EmergencyContactsSelectContacts';
|
|
5
7
|
import { TESTID } from '../../../configs/Constants';
|
|
6
8
|
import { SCProvider } from '../../../context';
|
|
7
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
10
|
import { API } from '../../../configs';
|
|
9
11
|
import { ViewButtonBottom } from '../../../commons';
|
|
12
|
+
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
12
16
|
|
|
13
17
|
const mockedNavigate = jest.fn();
|
|
14
18
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -45,7 +49,6 @@ describe('test EmergencyContactsSelectContacts', () => {
|
|
|
45
49
|
tree = create(wrapComponent(route));
|
|
46
50
|
});
|
|
47
51
|
const instance = tree.root;
|
|
48
|
-
|
|
49
52
|
const rowUser = instance.findAllByProps(
|
|
50
53
|
(item) => item.props.testID === TESTID.EMERGENCY_SELECT_CONTACT
|
|
51
54
|
);
|
|
@@ -54,50 +57,41 @@ describe('test EmergencyContactsSelectContacts', () => {
|
|
|
54
57
|
|
|
55
58
|
test('render emergencyContactsSelectContacts success', async () => {
|
|
56
59
|
jest.useFakeTimers();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
axios.get.mockImplementation(() => Promise.resolve(response));
|
|
64
|
-
|
|
65
|
-
act(() => {
|
|
66
|
-
tree = create(wrapComponent(route));
|
|
60
|
+
mock.onGet(API.SHARE.UNITS_MEMBERS(1, 1)).reply(200, {
|
|
61
|
+
id: 1,
|
|
62
|
+
name: 'test',
|
|
63
|
+
phone_number: 1,
|
|
67
64
|
});
|
|
68
65
|
act(() => {
|
|
69
|
-
|
|
66
|
+
tree = create(wrapComponent(route));
|
|
70
67
|
});
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
const instance = tree.root;
|
|
69
|
+
const rowUser = instance.findAllByProps(
|
|
70
|
+
(item) => item.props.testID === TESTID.EMERGENCY_SELECT_CONTACT + 0
|
|
71
|
+
);
|
|
72
|
+
expect(rowUser[0]).toBeDefined();
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
test('test onSave emergencyContactsSelectContacts', async () => {
|
|
76
|
-
|
|
77
|
-
status: 200,
|
|
78
|
-
};
|
|
79
|
-
axios.post.mockImplementation(async () => {
|
|
80
|
-
return response;
|
|
81
|
-
});
|
|
76
|
+
mock.onPost(API.EMERGENCY_BUTTON.CREATE_BATCH()).reply(200);
|
|
82
77
|
act(() => {
|
|
83
78
|
tree = create(wrapComponent(route));
|
|
84
79
|
});
|
|
85
80
|
const instance = tree.root;
|
|
86
|
-
|
|
87
81
|
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
88
82
|
await act(async () => {
|
|
89
83
|
viewButtonBottom.props.onRightClick();
|
|
90
84
|
});
|
|
91
|
-
expect(
|
|
85
|
+
expect(Toast.show).toBeCalledWith({
|
|
86
|
+
type: 'success',
|
|
87
|
+
position: 'bottom',
|
|
88
|
+
text1: getTranslate('en', 'saving_contact_successful'),
|
|
89
|
+
visibilityTime: 1000,
|
|
90
|
+
});
|
|
92
91
|
});
|
|
93
92
|
|
|
94
93
|
test('test onSave emergencyContactsSelectContacts fail', async () => {
|
|
95
|
-
|
|
96
|
-
status: 500,
|
|
97
|
-
};
|
|
98
|
-
axios.post.mockImplementation(async () => {
|
|
99
|
-
return response;
|
|
100
|
-
});
|
|
94
|
+
mock.onPost(API.EMERGENCY_BUTTON.CREATE_BATCH()).reply(500);
|
|
101
95
|
act(() => {
|
|
102
96
|
tree = create(wrapComponent(route));
|
|
103
97
|
});
|
|
@@ -107,6 +101,11 @@ describe('test EmergencyContactsSelectContacts', () => {
|
|
|
107
101
|
await act(async () => {
|
|
108
102
|
viewButtonBottom.props.onRightClick();
|
|
109
103
|
});
|
|
110
|
-
expect(
|
|
104
|
+
expect(Toast.show).toBeCalledWith({
|
|
105
|
+
type: 'error',
|
|
106
|
+
position: 'bottom',
|
|
107
|
+
text1: getTranslate('en', 'create_contact_failed'),
|
|
108
|
+
visibilityTime: 1000,
|
|
109
|
+
});
|
|
111
110
|
});
|
|
112
111
|
});
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { create, act } from 'react-test-renderer';
|
|
3
3
|
import { TouchableOpacity } from 'react-native';
|
|
4
|
-
import
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
5
|
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
import EnterPassword from '../index';
|
|
9
9
|
import { TESTID } from '../../../configs/Constants';
|
|
10
10
|
import { API } from '../../../configs';
|
|
11
|
+
import api from '../../../utils/Apis/axios';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
13
14
|
|
|
14
15
|
const wrapComponent = (route) => (
|
|
15
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -37,20 +38,11 @@ describe('Test EnterPassword', () => {
|
|
|
37
38
|
el.type === TouchableOpacity
|
|
38
39
|
);
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
case 'put':
|
|
47
|
-
return axios.put.mockImplementation(async () => {
|
|
48
|
-
return response;
|
|
49
|
-
});
|
|
50
|
-
default:
|
|
51
|
-
return '';
|
|
52
|
-
}
|
|
53
|
-
};
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
mockNavigate.mockClear();
|
|
44
|
+
});
|
|
45
|
+
|
|
54
46
|
test('test render EnterPassword button done', () => {
|
|
55
47
|
const route = {
|
|
56
48
|
params: { dataParams: {}, type: '' },
|
|
@@ -63,6 +55,16 @@ describe('Test EnterPassword', () => {
|
|
|
63
55
|
expect(button).toHaveLength(1);
|
|
64
56
|
});
|
|
65
57
|
|
|
58
|
+
test('test render EnterPassword has not params', () => {
|
|
59
|
+
const route = {};
|
|
60
|
+
act(() => {
|
|
61
|
+
tree = create(wrapComponent(route));
|
|
62
|
+
});
|
|
63
|
+
const instance = tree.root;
|
|
64
|
+
const button = buttonDone(instance);
|
|
65
|
+
expect(button).toHaveLength(1);
|
|
66
|
+
});
|
|
67
|
+
|
|
66
68
|
test('test render EnterPassword text input password', () => {
|
|
67
69
|
const route = {
|
|
68
70
|
params: { dataParams: {}, type: '' },
|
|
@@ -102,11 +104,7 @@ describe('Test EnterPassword', () => {
|
|
|
102
104
|
type: 'infoMemberUnit',
|
|
103
105
|
},
|
|
104
106
|
};
|
|
105
|
-
|
|
106
|
-
status: 200,
|
|
107
|
-
data: { id: 1, user_id: 1 },
|
|
108
|
-
};
|
|
109
|
-
await mockAxios(responsePut, 'put');
|
|
107
|
+
mock.onPut(API.UNIT.CHANGE_OWNER(1)).reply(200, { id: 1, user_id: 1 });
|
|
110
108
|
await act(async () => {
|
|
111
109
|
tree = await create(wrapComponent(route));
|
|
112
110
|
});
|
|
@@ -115,10 +113,28 @@ describe('Test EnterPassword', () => {
|
|
|
115
113
|
await act(async () => {
|
|
116
114
|
await button[0].props.onPress();
|
|
117
115
|
});
|
|
118
|
-
expect(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
expect(mockNavigate).toBeCalled();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('test EnterPassword button failure', async () => {
|
|
120
|
+
const route = {
|
|
121
|
+
params: {
|
|
122
|
+
dataParams: {
|
|
123
|
+
unit_id: 1,
|
|
124
|
+
member: { id: 1 },
|
|
125
|
+
},
|
|
126
|
+
type: 'infoMemberUnit',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
await act(async () => {
|
|
130
|
+
tree = await create(wrapComponent(route));
|
|
131
|
+
});
|
|
132
|
+
const instance = tree.root;
|
|
133
|
+
const button = buttonDone(instance);
|
|
134
|
+
mock.onPut(API.UNIT.CHANGE_OWNER(1)).reply(400);
|
|
135
|
+
await act(async () => {
|
|
136
|
+
await button[0].props.onPress();
|
|
122
137
|
});
|
|
138
|
+
expect(mockNavigate).not.toBeCalled();
|
|
123
139
|
});
|
|
124
140
|
});
|
|
@@ -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 GuestInfo from '..';
|
|
@@ -11,6 +12,7 @@ import WheelDateTimePicker from '../../../commons/WheelDateTimePicker';
|
|
|
11
12
|
import Text from '../../../commons/Text';
|
|
12
13
|
import { TESTID } from '../../../configs/Constants';
|
|
13
14
|
import { API } from '../../../configs';
|
|
15
|
+
import api from '../../../utils/Apis/axios';
|
|
14
16
|
|
|
15
17
|
const wrapComponent = (route) => (
|
|
16
18
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -35,7 +37,7 @@ jest.mock('@react-navigation/native', () => {
|
|
|
35
37
|
};
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
39
41
|
|
|
40
42
|
const getButton = (instance, testID, many = false) => {
|
|
41
43
|
if (many) {
|
|
@@ -54,8 +56,6 @@ describe('Test GuestInfo', () => {
|
|
|
54
56
|
let data;
|
|
55
57
|
|
|
56
58
|
beforeEach(() => {
|
|
57
|
-
axios.get.mockClear();
|
|
58
|
-
axios.put.mockClear();
|
|
59
59
|
mockGoBack.mockClear();
|
|
60
60
|
route = {
|
|
61
61
|
params: { id: 1 },
|
|
@@ -76,23 +76,14 @@ describe('Test GuestInfo', () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
test('test render GuestInfo', async () => {
|
|
79
|
-
|
|
80
|
-
status: 200,
|
|
81
|
-
data: data,
|
|
82
|
-
};
|
|
83
|
-
axios.get.mockImplementation(async () => {
|
|
84
|
-
return response;
|
|
85
|
-
});
|
|
79
|
+
mock.onGet(API.SHARED_SENSOR.ACCESS(1)).reply(200, data);
|
|
86
80
|
await act(async () => {
|
|
87
81
|
tree = await create(wrapComponent(route));
|
|
88
82
|
});
|
|
89
83
|
const instance = tree.root;
|
|
90
|
-
|
|
91
|
-
expect(axios.get).toHaveBeenCalledWith(API.SHARED_SENSOR.ACCESS(1), {});
|
|
92
84
|
const texts = instance.findAllByType(Text);
|
|
93
85
|
expect(texts[4].props.children).toBe(data.user.id);
|
|
94
86
|
expect(texts[6].props.children).toBe('Always');
|
|
95
|
-
|
|
96
87
|
const accessScheduleItems = instance.findAllByType(AccessScheduleItem);
|
|
97
88
|
const radioButtons = getButton(
|
|
98
89
|
instance,
|
|
@@ -101,21 +92,18 @@ describe('Test GuestInfo', () => {
|
|
|
101
92
|
);
|
|
102
93
|
expect(accessScheduleItems).toHaveLength(3);
|
|
103
94
|
expect(radioButtons).toHaveLength(3);
|
|
104
|
-
|
|
105
95
|
const always = accessScheduleItems[0];
|
|
106
96
|
const recurring = accessScheduleItems[1];
|
|
107
97
|
const temporary = accessScheduleItems[2];
|
|
108
98
|
expect(always.props.isSelected).toBeTruthy();
|
|
109
99
|
expect(recurring.props.isSelected).toBeFalsy();
|
|
110
100
|
expect(temporary.props.isSelected).toBeFalsy();
|
|
111
|
-
|
|
112
101
|
await act(async () => {
|
|
113
102
|
await radioButtons[1].props.onPress();
|
|
114
103
|
});
|
|
115
104
|
expect(always.props.isSelected).toBeFalsy();
|
|
116
105
|
expect(recurring.props.isSelected).toBeTruthy();
|
|
117
106
|
expect(temporary.props.isSelected).toBeFalsy();
|
|
118
|
-
|
|
119
107
|
await act(async () => {
|
|
120
108
|
await radioButtons[2].props.onPress();
|
|
121
109
|
});
|
|
@@ -125,13 +113,7 @@ describe('Test GuestInfo', () => {
|
|
|
125
113
|
});
|
|
126
114
|
|
|
127
115
|
test('test open and close 2 modal', async () => {
|
|
128
|
-
|
|
129
|
-
status: 200,
|
|
130
|
-
data: data,
|
|
131
|
-
};
|
|
132
|
-
axios.get.mockImplementation(async () => {
|
|
133
|
-
return response;
|
|
134
|
-
});
|
|
116
|
+
mock.onGet(API.SHARED_SENSOR.ACCESS(1)).reply(200, data);
|
|
135
117
|
await act(async () => {
|
|
136
118
|
tree = await create(wrapComponent(route));
|
|
137
119
|
});
|
|
@@ -197,13 +179,7 @@ describe('Test GuestInfo', () => {
|
|
|
197
179
|
|
|
198
180
|
test('test save', async () => {
|
|
199
181
|
data.access_schedule = 'recurring';
|
|
200
|
-
|
|
201
|
-
status: 200,
|
|
202
|
-
data: data,
|
|
203
|
-
};
|
|
204
|
-
axios.get.mockImplementation(async () => {
|
|
205
|
-
return response;
|
|
206
|
-
});
|
|
182
|
+
mock.onGet(API.SHARED_SENSOR.ACCESS(1)).reply(200, data);
|
|
207
183
|
await act(async () => {
|
|
208
184
|
tree = await create(wrapComponent(route));
|
|
209
185
|
});
|
|
@@ -213,17 +189,14 @@ describe('Test GuestInfo', () => {
|
|
|
213
189
|
el.props.testID === TESTID.SAVE_ACCESS_SCHEDULE &&
|
|
214
190
|
el.type === TouchableOpacity
|
|
215
191
|
);
|
|
216
|
-
|
|
217
|
-
return { status: 200 };
|
|
218
|
-
});
|
|
192
|
+
mock.onPut(API.SHARED_SENSOR.ACCESS(1)).reply(200);
|
|
219
193
|
await act(async () => {
|
|
220
194
|
await saveButton.props.onPress();
|
|
221
195
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
196
|
+
const accessScheduleSheetDone = getButton(
|
|
197
|
+
instance,
|
|
198
|
+
`${TESTID.ACCESS_SCHEDULE_SHEET}${TESTID.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
|
|
199
|
+
);
|
|
200
|
+
expect(accessScheduleSheetDone.props.isVisible).toBeFalsy();
|
|
228
201
|
});
|
|
229
202
|
});
|
|
@@ -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
|
});
|