@eohjsc/react-native-smart-city 0.2.99 → 0.3.2
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 +1 -1
- package/package.json +6 -4
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +11 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -20
- 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/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +0 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
- 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 +137 -2
- 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/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +72 -25
- 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/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +3 -3
- package/src/commons/Device/ItemDevice.js +15 -11
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- 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/FieldTemplate/ScheduleField/index.js +2 -2
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +24 -55
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -1
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +2 -2
- package/src/configs/API.js +85 -144
- package/src/configs/Constants.js +24 -0
- package/src/configs/SCConfig.js +2 -0
- package/src/context/actionType.ts +8 -0
- package/src/context/mockStore.ts +10 -0
- package/src/context/reducer.ts +38 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- 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/hooks/index.js +1 -1
- 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/AddLocationMaps/index.js +5 -4
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- 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/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
- 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/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -23
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- 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 +3 -3
- 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/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +32 -85
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +53 -22
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- 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/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +13 -40
- package/src/screens/HanetCamera/Detail.js +1 -1
- 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/components/RequestFaceIDPopup.js +3 -2
- 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/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- 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/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +1 -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 +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +22 -6
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- 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 +16 -11
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SelectUnit/index.js +4 -2
- package/src/screens/SetSchedule/index.js +9 -9
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/SelectPermission.js +121 -76
- 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 +12 -23
- package/src/screens/SideMenuDetail/index.js +2 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/ManageSubUnit.js +12 -7
- 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/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +30 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +34 -21
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Summaries.js +17 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +99 -200
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +84 -51
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- 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/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +70 -41
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/utils/Apis/axios.js +46 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +4 -1
- package/src/utils/I18n/translations/vi.json +5 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Utils.js +11 -7
|
@@ -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.DEVICE.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.DEVICE.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
|
});
|
|
@@ -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 pickerOptions = {
|
|
35
35
|
mediaType: 'photo',
|
|
36
36
|
compressImageMaxHeight: 1280,
|
|
37
37
|
compressImageMaxWidth: 738,
|
|
@@ -39,8 +39,9 @@ const RequestFaceIDPopup = ({
|
|
|
39
39
|
forceJpg: true,
|
|
40
40
|
};
|
|
41
41
|
try {
|
|
42
|
-
const result = await ImagePicker.openPicker(
|
|
42
|
+
const result = await ImagePicker.openPicker(pickerOptions);
|
|
43
43
|
onChooseFile && onChooseFile(result);
|
|
44
|
+
// eslint-disable-next-line no-empty
|
|
44
45
|
} catch (e) {}
|
|
45
46
|
},
|
|
46
47
|
},
|