@eohjsc/react-native-smart-city 0.2.86 → 0.2.89
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/assets/images/Common/Calendar.svg +3 -0
- package/assets/images/Common/SmartPhone.svg +3 -0
- package/assets/images/Hanet/CaptureFaceID.svg +25 -0
- package/assets/images/Hanet/FaceFrame.svg +6 -0
- package/assets/images/brightnessBlack.svg +12 -0
- package/index.js +4 -0
- package/package.json +3 -3
- package/src/Images/SmartIr/AC.svg +14 -0
- package/src/Images/SmartIr/DIY.svg +3 -0
- package/src/Images/SmartIr/Fan.svg +10 -0
- package/src/Images/SmartIr/Fridge.svg +5 -0
- package/src/Images/SmartIr/Remote.svg +15 -0
- package/src/Images/SmartIr/SmartIr.svg +4 -0
- package/src/Images/SmartIr/TV.svg +10 -0
- package/src/Images/SmartIr/Union.svg +9 -0
- package/src/Images/SmartIr/WM.svg +11 -0
- package/src/Images/SmartIr/index.js +10 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +51 -0
- package/src/commons/ActionGroup/ColorPickerTemplateStyles.js +17 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +40 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +65 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapperStyles.js +43 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +48 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +57 -0
- package/src/commons/ActionGroup/{OnOffSmartLock.js → OnOffSmartLock/OnOffSmartLock.js} +5 -5
- package/src/commons/ActionGroup/{OnOffSmartLockStyle.js → OnOffSmartLock/OnOffSmartLockStyle.js} +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +48 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscodeStyles.js +42 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/PasscodeListStyles.js +49 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +66 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +96 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +98 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +62 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +249 -0
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -1
- package/src/commons/ActionGroup/SliderRangeTemplate.js +64 -0
- package/src/commons/ActionGroup/{LightActionTemplateStyles.js → SliderRangeTemplateStyles.js} +0 -8
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +167 -186
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -1
- package/src/commons/ActionGroup/index.js +7 -4
- package/src/commons/BottomSheet/index.js +2 -1
- package/src/commons/Device/DisconnectedView.js +7 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.js +109 -0
- package/src/commons/Device/HistoryChart.js +2 -2
- package/src/commons/Device/HorizontalBarChart.js +7 -0
- package/src/commons/Device/ItemDevice.js +18 -15
- package/src/commons/Device/LinearChart.js +14 -41
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -2
- package/src/commons/RowItem/index.js +12 -7
- package/src/commons/SubUnit/Favorites/index.js +2 -2
- package/src/commons/SubUnit/ShortDetail.js +39 -20
- package/src/commons/WheelDateTimePicker/index.js +18 -4
- package/src/configs/API.js +23 -1
- package/src/configs/Colors.js +1 -0
- package/src/configs/Constants.js +48 -0
- package/src/configs/SCConfig.js +1 -1
- package/src/context/actionType.ts +4 -0
- package/src/context/mockStore.ts +3 -0
- package/src/context/reducer.ts +20 -0
- package/src/iot/RemoteControl/Bluetooth.js +3 -22
- package/src/iot/RemoteControl/index.js +0 -1
- package/src/navigations/HanetCameraStack.js +41 -0
- package/src/navigations/SmartIrStack.js +31 -0
- package/src/navigations/SmartLockStack.js +51 -0
- package/src/navigations/UnitStack.js +46 -4
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +79 -72
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +155 -27
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +65 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +26 -2
- package/src/screens/Device/__test__/detail.test.js +0 -10
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +13 -2
- package/src/screens/Device/detail.js +118 -38
- package/src/screens/Device/hooks/useDisconnectedDevice.js +28 -16
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +9 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +3 -2
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -2
- package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +3 -0
- package/src/screens/HanetCamera/CaptureFaceID.js +210 -0
- package/src/screens/HanetCamera/Detail.js +252 -0
- package/src/screens/HanetCamera/ManageAccess.js +173 -0
- package/src/screens/HanetCamera/MemberInfo.js +208 -0
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +133 -0
- package/src/screens/HanetCamera/__test__/Detail.test.js +185 -0
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +152 -0
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +178 -0
- package/src/screens/HanetCamera/components/CheckinHeader.js +37 -0
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +151 -0
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +71 -0
- package/src/screens/HanetCamera/hooks/index.js +5 -0
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +116 -0
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +86 -0
- package/src/screens/HanetCamera/hooks/useStateAlertAction.js +62 -0
- package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +50 -0
- package/src/screens/HanetCamera/styles/checkinHeaderStyles.js +24 -0
- package/src/screens/HanetCamera/styles/detailStyles.js +107 -0
- package/src/screens/HanetCamera/styles/manageAccessStyles.js +49 -0
- package/src/screens/HanetCamera/styles/memberInfoStyles.js +73 -0
- package/src/screens/HanetCamera/utils/Monitor.js +52 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +1 -0
- package/src/screens/Notification/components/NotificationItem.js +16 -0
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +31 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +80 -0
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +65 -0
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +57 -0
- package/src/screens/SmartIr/__test__/SmartIr.test.js +1 -0
- package/src/screens/SmartIr/components/GroupButtonByType/ButtonsBottom.js +45 -0
- package/src/screens/SmartIr/components/GroupButtonByType/ButtonsBottomStyles.js +31 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +208 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByTypeStyles.js +113 -0
- package/src/screens/SmartIr/components/SelectBrand.js +61 -0
- package/src/screens/SmartIr/components/SelectBrandStyles.js +14 -0
- package/src/screens/SmartIr/components/SelectDeviceType.js +96 -0
- package/src/screens/SmartIr/components/SelectDeviceTypeStyles.js +30 -0
- package/src/screens/SmartIr/index.js +8 -3
- package/src/screens/Unit/Detail.js +7 -11
- package/src/screens/Unit/__test__/Detail.test.js +0 -10
- package/src/screens/Unit/components/MyUnitDevice/index.js +2 -4
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +38 -9
- package/src/utils/I18n/translations/en.json +51 -1
- package/src/utils/I18n/translations/vi.json +51 -1
- package/src/utils/Route/index.js +14 -1
- package/src/commons/ActionGroup/LightActionTemplate.js +0 -103
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +0 -59
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { create, act } from 'react-test-renderer';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import HanetCaptureFaceID from '../CaptureFaceID';
|
|
8
|
+
import { RNCamera } from 'react-native-camera';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (route) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<HanetCaptureFaceID route={route} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock('react', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('react'),
|
|
19
|
+
memo: (x) => x,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const mockedNavigate = jest.fn();
|
|
24
|
+
const mockedGoBack = jest.fn();
|
|
25
|
+
jest.mock('@react-navigation/native', () => {
|
|
26
|
+
return {
|
|
27
|
+
...jest.requireActual('@react-navigation/native'),
|
|
28
|
+
useNavigation: () => ({
|
|
29
|
+
navigate: mockedNavigate,
|
|
30
|
+
goBack: mockedGoBack,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
jest.mock('axios');
|
|
36
|
+
|
|
37
|
+
const mockSetAvatar = jest.fn();
|
|
38
|
+
describe('Test HanetCaptureFaceID', () => {
|
|
39
|
+
let tree, route;
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockedNavigate.mockClear();
|
|
43
|
+
mockedGoBack.mockClear();
|
|
44
|
+
mockSetAvatar.mockClear();
|
|
45
|
+
axios.patch.mockClear();
|
|
46
|
+
route = {
|
|
47
|
+
params: {
|
|
48
|
+
title: 'title',
|
|
49
|
+
hanetPlace: {
|
|
50
|
+
place_id: 1,
|
|
51
|
+
},
|
|
52
|
+
hanetMember: {
|
|
53
|
+
id: 1,
|
|
54
|
+
alias_id: 1,
|
|
55
|
+
name: 'name',
|
|
56
|
+
avatar_uri: 'uri',
|
|
57
|
+
},
|
|
58
|
+
setMemberAvatar: mockSetAvatar,
|
|
59
|
+
isAddNewMember: false,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const captureFaceID = async (instance) => {
|
|
65
|
+
let touches = instance.findAllByType(TouchableOpacity);
|
|
66
|
+
await act(async () => {
|
|
67
|
+
await touches[1].props.onPress();
|
|
68
|
+
});
|
|
69
|
+
const camera = instance.findByType(RNCamera);
|
|
70
|
+
expect(camera).toBeDefined();
|
|
71
|
+
|
|
72
|
+
// capture
|
|
73
|
+
touches = instance.findAllByType(TouchableOpacity);
|
|
74
|
+
await act(async () => {
|
|
75
|
+
await touches[1].props.onPress();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// resume capture
|
|
79
|
+
touches = instance.findAllByType(TouchableOpacity);
|
|
80
|
+
await act(async () => {
|
|
81
|
+
await touches[2].props.onPress();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// capture
|
|
85
|
+
touches = instance.findAllByType(TouchableOpacity);
|
|
86
|
+
await act(async () => {
|
|
87
|
+
await touches[1].props.onPress();
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
test('Test update face id', async () => {
|
|
92
|
+
await act(async () => {
|
|
93
|
+
tree = await create(wrapComponent(route));
|
|
94
|
+
});
|
|
95
|
+
const instance = tree.root;
|
|
96
|
+
|
|
97
|
+
// capture face id
|
|
98
|
+
await captureFaceID(instance);
|
|
99
|
+
|
|
100
|
+
axios.patch.mockImplementationOnce(async () => ({
|
|
101
|
+
status: 200,
|
|
102
|
+
data: {
|
|
103
|
+
avatar_uri: 'avatar_uri',
|
|
104
|
+
},
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
// continue
|
|
108
|
+
let touches = instance.findAllByType(TouchableOpacity);
|
|
109
|
+
await act(async () => {
|
|
110
|
+
await touches[1].props.onPress();
|
|
111
|
+
});
|
|
112
|
+
expect(axios.patch).toHaveBeenCalled();
|
|
113
|
+
expect(mockSetAvatar).toHaveBeenCalled();
|
|
114
|
+
expect(mockedGoBack).toHaveBeenCalled();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('Test set face id for new member', async () => {
|
|
118
|
+
route.params.isAddNewMember = true;
|
|
119
|
+
await act(async () => {
|
|
120
|
+
tree = await create(wrapComponent(route));
|
|
121
|
+
});
|
|
122
|
+
const instance = tree.root;
|
|
123
|
+
|
|
124
|
+
await captureFaceID(instance);
|
|
125
|
+
|
|
126
|
+
// continue
|
|
127
|
+
let touches = instance.findAllByType(TouchableOpacity);
|
|
128
|
+
await act(async () => {
|
|
129
|
+
await touches[1].props.onPress();
|
|
130
|
+
});
|
|
131
|
+
expect(mockedNavigate).toHaveBeenCalled();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatList } from 'react-native';
|
|
3
|
+
import { create, act } from 'react-test-renderer';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import HanetCameraDetail from '../Detail';
|
|
8
|
+
import CheckinHeader from '../components/CheckinHeader';
|
|
9
|
+
import moment from 'moment';
|
|
10
|
+
import { TESTID } from '../../../configs/Constants';
|
|
11
|
+
import Calendar from '../../../commons/Calendar';
|
|
12
|
+
|
|
13
|
+
const wrapComponent = (route) => (
|
|
14
|
+
<SCProvider initState={mockSCStore({})}>
|
|
15
|
+
<HanetCameraDetail route={route} />
|
|
16
|
+
</SCProvider>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
jest.mock('react', () => {
|
|
20
|
+
return {
|
|
21
|
+
...jest.requireActual('react'),
|
|
22
|
+
memo: (x) => x,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
jest.mock('axios');
|
|
27
|
+
|
|
28
|
+
describe('Test HanetCameraDetail', () => {
|
|
29
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
30
|
+
let tree, route, responseDisplay, responseCheckin;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
axios.get.mockClear();
|
|
34
|
+
route = {
|
|
35
|
+
params: {
|
|
36
|
+
unit: {
|
|
37
|
+
user_id: 1,
|
|
38
|
+
},
|
|
39
|
+
sensor: {
|
|
40
|
+
id: 1,
|
|
41
|
+
},
|
|
42
|
+
title: 'title',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
responseDisplay = {
|
|
46
|
+
status: 200,
|
|
47
|
+
data: {
|
|
48
|
+
items: [
|
|
49
|
+
{
|
|
50
|
+
type: 'hanet_camera',
|
|
51
|
+
configuration: {
|
|
52
|
+
device_id: 2,
|
|
53
|
+
place: {
|
|
54
|
+
place_id: 3,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
responseCheckin = {
|
|
62
|
+
status: 200,
|
|
63
|
+
data: {
|
|
64
|
+
count: 2,
|
|
65
|
+
count_member: 1,
|
|
66
|
+
count_stranger: 1,
|
|
67
|
+
results: [
|
|
68
|
+
{
|
|
69
|
+
id: 1,
|
|
70
|
+
person_name: 'name 1',
|
|
71
|
+
person_type: 'EMPLOYEE',
|
|
72
|
+
detected_image_uri: 'uri',
|
|
73
|
+
detected_mask: 'MASK_OFF',
|
|
74
|
+
created_at: moment(),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 2,
|
|
78
|
+
person_name: 'name 2',
|
|
79
|
+
person_type: 'STRANGER',
|
|
80
|
+
detected_image_uri: 'uri',
|
|
81
|
+
detected_mask: 'MASK_ON',
|
|
82
|
+
created_at: moment(),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('Test render HanetCameraDetail', async () => {
|
|
90
|
+
axios.get.mockImplementationOnce(async () => {
|
|
91
|
+
return responseDisplay;
|
|
92
|
+
});
|
|
93
|
+
axios.get.mockImplementationOnce(async () => {
|
|
94
|
+
return responseCheckin;
|
|
95
|
+
});
|
|
96
|
+
await act(async () => {
|
|
97
|
+
tree = await create(wrapComponent(route));
|
|
98
|
+
});
|
|
99
|
+
const instance = tree.root;
|
|
100
|
+
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
101
|
+
const flatLists = instance.findAllByType(FlatList);
|
|
102
|
+
expect(flatLists).toHaveLength(1);
|
|
103
|
+
|
|
104
|
+
const textCountMember = instance.find(
|
|
105
|
+
(el) => el.props.testID === TESTID.TEXT_COUNT_MEMBER
|
|
106
|
+
);
|
|
107
|
+
const textCountStranger = instance.find(
|
|
108
|
+
(el) => el.props.testID === TESTID.TEXT_COUNT_STRANGER
|
|
109
|
+
);
|
|
110
|
+
expect(textCountMember.props.children).toBe(1);
|
|
111
|
+
expect(textCountStranger.props.children).toBe(1);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('Test change date', async () => {
|
|
115
|
+
axios.get.mockImplementationOnce(async () => {
|
|
116
|
+
return responseDisplay;
|
|
117
|
+
});
|
|
118
|
+
axios.get.mockImplementationOnce(async () => {
|
|
119
|
+
return responseCheckin;
|
|
120
|
+
});
|
|
121
|
+
await act(async () => {
|
|
122
|
+
tree = await create(wrapComponent(route));
|
|
123
|
+
});
|
|
124
|
+
const instance = tree.root;
|
|
125
|
+
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
126
|
+
axios.get.mockClear();
|
|
127
|
+
|
|
128
|
+
const checkinHeader = instance.findByType(CheckinHeader);
|
|
129
|
+
|
|
130
|
+
// press arrow left
|
|
131
|
+
axios.get.mockImplementationOnce(async () => {
|
|
132
|
+
return responseCheckin;
|
|
133
|
+
});
|
|
134
|
+
await act(async () => {
|
|
135
|
+
await checkinHeader.props.onPickPreviousDate();
|
|
136
|
+
});
|
|
137
|
+
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
138
|
+
moment().add(-1, 'days').format('DD/MM/YYYY')
|
|
139
|
+
);
|
|
140
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
141
|
+
axios.get.mockClear();
|
|
142
|
+
|
|
143
|
+
// press arrow right
|
|
144
|
+
axios.get.mockImplementationOnce(async () => {
|
|
145
|
+
return responseCheckin;
|
|
146
|
+
});
|
|
147
|
+
await act(async () => {
|
|
148
|
+
await checkinHeader.props.onPickNextDate();
|
|
149
|
+
});
|
|
150
|
+
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
151
|
+
moment().format('DD/MM/YYYY')
|
|
152
|
+
);
|
|
153
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
154
|
+
axios.get.mockClear();
|
|
155
|
+
|
|
156
|
+
// press arrow right
|
|
157
|
+
await act(async () => {
|
|
158
|
+
await checkinHeader.props.onPickNextDate();
|
|
159
|
+
});
|
|
160
|
+
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
161
|
+
moment().format('DD/MM/YYYY')
|
|
162
|
+
); // no change
|
|
163
|
+
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
164
|
+
axios.get.mockClear();
|
|
165
|
+
|
|
166
|
+
// open calendar
|
|
167
|
+
await act(async () => {
|
|
168
|
+
await checkinHeader.props.setShowCalendar();
|
|
169
|
+
});
|
|
170
|
+
const calendar = instance.findByType(Calendar);
|
|
171
|
+
expect(calendar.props.isVisible).toBe(true);
|
|
172
|
+
|
|
173
|
+
// choose date on calendar
|
|
174
|
+
axios.get.mockImplementationOnce(async () => {
|
|
175
|
+
return responseCheckin;
|
|
176
|
+
});
|
|
177
|
+
await act(async () => {
|
|
178
|
+
await calendar.props.onConfirm(moment().add(-1, 'days'));
|
|
179
|
+
});
|
|
180
|
+
expect(checkinHeader.props.date.format('DD/MM/YYYY')).toBe(
|
|
181
|
+
moment().add(-1, 'days').format('DD/MM/YYYY')
|
|
182
|
+
);
|
|
183
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatList } from 'react-native';
|
|
3
|
+
import { create, act } from 'react-test-renderer';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import HanetManageAccess from '../ManageAccess';
|
|
8
|
+
import BottomSheet from '../../../commons/BottomSheet';
|
|
9
|
+
import { TESTID } from '../../../configs/Constants';
|
|
10
|
+
import Routes from '../../../utils/Route';
|
|
11
|
+
|
|
12
|
+
const wrapComponent = (route) => (
|
|
13
|
+
<SCProvider initState={mockSCStore({})}>
|
|
14
|
+
<HanetManageAccess route={route} />
|
|
15
|
+
</SCProvider>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
jest.mock('react', () => {
|
|
19
|
+
return {
|
|
20
|
+
...jest.requireActual('react'),
|
|
21
|
+
memo: (x) => x,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const mockedNavigate = jest.fn();
|
|
26
|
+
jest.mock('@react-navigation/native', () => {
|
|
27
|
+
return {
|
|
28
|
+
...jest.requireActual('@react-navigation/native'),
|
|
29
|
+
useNavigation: () => ({
|
|
30
|
+
navigate: mockedNavigate,
|
|
31
|
+
}),
|
|
32
|
+
useIsFocused: () => true,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
jest.mock('axios');
|
|
37
|
+
|
|
38
|
+
describe('Test HanetManageAccess', () => {
|
|
39
|
+
let tree, route, response;
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockedNavigate.mockClear();
|
|
43
|
+
axios.get.mockClear();
|
|
44
|
+
route = {
|
|
45
|
+
params: {
|
|
46
|
+
hanetPlace: {
|
|
47
|
+
place_id: 1,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('Test render', async () => {
|
|
54
|
+
response = {
|
|
55
|
+
status: 200,
|
|
56
|
+
data: {
|
|
57
|
+
count: 2,
|
|
58
|
+
results: [
|
|
59
|
+
{
|
|
60
|
+
id: 1,
|
|
61
|
+
name: 'name 1',
|
|
62
|
+
avatar_uri: 'uri 1',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 2,
|
|
66
|
+
name: 'name 2',
|
|
67
|
+
avatar_uri: 'uri 2',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
axios.get.mockImplementationOnce(async () => response);
|
|
73
|
+
await act(async () => {
|
|
74
|
+
tree = await create(wrapComponent(route));
|
|
75
|
+
});
|
|
76
|
+
const instance = tree.root;
|
|
77
|
+
const flatlists = instance.findAllByType(FlatList);
|
|
78
|
+
expect(flatlists).toHaveLength(1);
|
|
79
|
+
|
|
80
|
+
const touches = instance.findAll(
|
|
81
|
+
(el) => el.props.testID === TESTID.ROW_HANET_MANAGE_ACCESS
|
|
82
|
+
);
|
|
83
|
+
act(() => {
|
|
84
|
+
touches[0].props.onPress();
|
|
85
|
+
});
|
|
86
|
+
expect(mockedNavigate).toBeCalled();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const chooseAddMemberOption = async (instance, index) => {
|
|
90
|
+
const buttonAddNew = instance.find(
|
|
91
|
+
(el) => el.props.testID === TESTID.HANET_MANAGE_ACCESS_ADD_BUTTON
|
|
92
|
+
);
|
|
93
|
+
await act(async () => {
|
|
94
|
+
await buttonAddNew.props.onPress();
|
|
95
|
+
});
|
|
96
|
+
const option = instance.find(
|
|
97
|
+
(el) => el.props.testID === `${TESTID.HANET_ADD_MEMBER_OPTION}_${index}`
|
|
98
|
+
);
|
|
99
|
+
await act(async () => {
|
|
100
|
+
await option.props.onPress();
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
test('Test add new member capture face id', async () => {
|
|
105
|
+
await act(async () => {
|
|
106
|
+
tree = await create(wrapComponent(route));
|
|
107
|
+
});
|
|
108
|
+
const instance = tree.root;
|
|
109
|
+
|
|
110
|
+
const bottomSheet = instance.findByType(BottomSheet);
|
|
111
|
+
|
|
112
|
+
await chooseAddMemberOption(instance, 0);
|
|
113
|
+
|
|
114
|
+
expect(bottomSheet.props.isVisible).toBe(false);
|
|
115
|
+
expect(mockedNavigate).toBeCalledWith(Routes.HanetCaptureFaceID, {
|
|
116
|
+
title: 'Add new member',
|
|
117
|
+
hanetPlace: {
|
|
118
|
+
place_id: 1,
|
|
119
|
+
},
|
|
120
|
+
hanetMember: {
|
|
121
|
+
alias_id: null,
|
|
122
|
+
name: null,
|
|
123
|
+
},
|
|
124
|
+
isAddNewMember: true,
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('Test add new member choose file', async () => {
|
|
129
|
+
await act(async () => {
|
|
130
|
+
tree = await create(wrapComponent(route));
|
|
131
|
+
});
|
|
132
|
+
const instance = tree.root;
|
|
133
|
+
|
|
134
|
+
const bottomSheet = instance.findByType(BottomSheet);
|
|
135
|
+
|
|
136
|
+
await chooseAddMemberOption(instance, 1);
|
|
137
|
+
|
|
138
|
+
expect(bottomSheet.props.isVisible).toBe(false);
|
|
139
|
+
expect(mockedNavigate).toBeCalledWith(Routes.HanetMemberInfo, {
|
|
140
|
+
hanetPlace: {
|
|
141
|
+
place_id: 1,
|
|
142
|
+
},
|
|
143
|
+
hanetMember: {
|
|
144
|
+
alias_id: null,
|
|
145
|
+
name: null,
|
|
146
|
+
avatar_uri:
|
|
147
|
+
'file:///data/user/0/com.eohjsc.eohmobile/cache/Camera/80fbbd4b-926d-425f-a081-e21b13f2f7d0.jpg',
|
|
148
|
+
},
|
|
149
|
+
isAddNewMember: true,
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { create, act } from 'react-test-renderer';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import HanetMemberInfo from '../MemberInfo';
|
|
8
|
+
import { AlertAction } from '../../../commons';
|
|
9
|
+
import TextInput from '../../../commons/Form/TextInput';
|
|
10
|
+
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
11
|
+
|
|
12
|
+
const wrapComponent = (route) => (
|
|
13
|
+
<SCProvider initState={mockSCStore({})}>
|
|
14
|
+
<HanetMemberInfo route={route} />
|
|
15
|
+
</SCProvider>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
jest.mock('react', () => {
|
|
19
|
+
return {
|
|
20
|
+
...jest.requireActual('react'),
|
|
21
|
+
memo: (x) => x,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const mockedNavigate = jest.fn();
|
|
26
|
+
const mockedGoBack = jest.fn();
|
|
27
|
+
jest.mock('@react-navigation/native', () => {
|
|
28
|
+
return {
|
|
29
|
+
...jest.requireActual('@react-navigation/native'),
|
|
30
|
+
useNavigation: () => ({
|
|
31
|
+
navigate: mockedNavigate,
|
|
32
|
+
goBack: mockedGoBack,
|
|
33
|
+
}),
|
|
34
|
+
useIsFocused: () => true,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
jest.mock('axios');
|
|
39
|
+
|
|
40
|
+
describe('Test HanetMemberInfo', () => {
|
|
41
|
+
let tree, route;
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
mockedNavigate.mockClear();
|
|
45
|
+
mockedGoBack.mockClear();
|
|
46
|
+
axios.post.mockClear();
|
|
47
|
+
axios.patch.mockClear();
|
|
48
|
+
axios.delete.mockClear();
|
|
49
|
+
route = {
|
|
50
|
+
params: {
|
|
51
|
+
hanetPlace: {
|
|
52
|
+
place_id: 1,
|
|
53
|
+
},
|
|
54
|
+
hanetMember: {
|
|
55
|
+
id: 1,
|
|
56
|
+
alias_id: 1,
|
|
57
|
+
name: 'name',
|
|
58
|
+
avatar_uri: 'uri',
|
|
59
|
+
},
|
|
60
|
+
isAddNewMember: false,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('Test rename member', async () => {
|
|
66
|
+
await act(async () => {
|
|
67
|
+
tree = await create(wrapComponent(route));
|
|
68
|
+
});
|
|
69
|
+
const instance = tree.root;
|
|
70
|
+
const touches = instance.findAllByType(TouchableOpacity);
|
|
71
|
+
expect(touches).toHaveLength(5);
|
|
72
|
+
const alertAction = instance.findByType(AlertAction);
|
|
73
|
+
|
|
74
|
+
// open alert action
|
|
75
|
+
await act(async () => {
|
|
76
|
+
await touches[2].props.onPress();
|
|
77
|
+
});
|
|
78
|
+
expect(alertAction.props.visible).toBe(true);
|
|
79
|
+
|
|
80
|
+
const textInput = instance.findByType(TextInput);
|
|
81
|
+
|
|
82
|
+
axios.patch.mockImplementationOnce(async () => ({ status: 200 }));
|
|
83
|
+
|
|
84
|
+
// change name and press rename
|
|
85
|
+
await act(async () => {
|
|
86
|
+
await textInput.props.onChange('new name');
|
|
87
|
+
await alertAction.props.rightButtonClick();
|
|
88
|
+
});
|
|
89
|
+
expect(axios.patch).toHaveBeenCalled();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('Test remove member', async () => {
|
|
93
|
+
await act(async () => {
|
|
94
|
+
tree = await create(wrapComponent(route));
|
|
95
|
+
});
|
|
96
|
+
const instance = tree.root;
|
|
97
|
+
const touches = instance.findAllByType(TouchableOpacity);
|
|
98
|
+
expect(touches).toHaveLength(5);
|
|
99
|
+
const alertAction = instance.findByType(AlertAction);
|
|
100
|
+
|
|
101
|
+
// open alert action
|
|
102
|
+
await act(async () => {
|
|
103
|
+
await touches[3].props.onPress();
|
|
104
|
+
});
|
|
105
|
+
expect(alertAction.props.visible).toBe(true);
|
|
106
|
+
|
|
107
|
+
axios.delete.mockImplementationOnce(async () => ({ status: 200 }));
|
|
108
|
+
|
|
109
|
+
// press remove
|
|
110
|
+
await act(async () => {
|
|
111
|
+
await alertAction.props.rightButtonClick();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(axios.delete).toHaveBeenCalled();
|
|
115
|
+
expect(mockedGoBack).toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('Test navigate CaptureFaceID', async () => {
|
|
119
|
+
await act(async () => {
|
|
120
|
+
tree = await create(wrapComponent(route));
|
|
121
|
+
});
|
|
122
|
+
const instance = tree.root;
|
|
123
|
+
|
|
124
|
+
const touches = instance.findAllByType(TouchableOpacity);
|
|
125
|
+
expect(touches).toHaveLength(5);
|
|
126
|
+
|
|
127
|
+
await act(async () => {
|
|
128
|
+
await touches[1].props.onPress();
|
|
129
|
+
});
|
|
130
|
+
expect(mockedNavigate).toBeCalled();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('Test register new member', async () => {
|
|
134
|
+
route.params.hanetMember = {
|
|
135
|
+
alias_id: null,
|
|
136
|
+
name: null,
|
|
137
|
+
avatar_uri: 'avatar_uri',
|
|
138
|
+
};
|
|
139
|
+
route.params.isAddNewMember = true;
|
|
140
|
+
await act(async () => {
|
|
141
|
+
tree = await create(wrapComponent(route));
|
|
142
|
+
});
|
|
143
|
+
const instance = tree.root;
|
|
144
|
+
|
|
145
|
+
const touches = instance.findAllByType(TouchableOpacity);
|
|
146
|
+
expect(touches).toHaveLength(5);
|
|
147
|
+
|
|
148
|
+
// press set face id
|
|
149
|
+
await act(async () => {
|
|
150
|
+
await touches[1].props.onPress();
|
|
151
|
+
});
|
|
152
|
+
expect(mockedNavigate).toBeCalled();
|
|
153
|
+
|
|
154
|
+
// open alert action
|
|
155
|
+
const alertAction = instance.findByType(AlertAction);
|
|
156
|
+
await act(async () => {
|
|
157
|
+
await touches[2].props.onPress();
|
|
158
|
+
});
|
|
159
|
+
expect(alertAction.props.visible).toBe(true);
|
|
160
|
+
|
|
161
|
+
// change name and press rename
|
|
162
|
+
const textInput = instance.findByType(TextInput);
|
|
163
|
+
await act(async () => {
|
|
164
|
+
await textInput.props.onChange('new name');
|
|
165
|
+
await alertAction.props.rightButtonClick();
|
|
166
|
+
});
|
|
167
|
+
expect(axios.post).not.toBeCalled();
|
|
168
|
+
|
|
169
|
+
// finish
|
|
170
|
+
const bottomButton = instance.findByType(BottomButtonView);
|
|
171
|
+
axios.post.mockImplementationOnce(async () => ({ status: 200 }));
|
|
172
|
+
await act(async () => {
|
|
173
|
+
await bottomButton.props.onPressMain();
|
|
174
|
+
});
|
|
175
|
+
expect(axios.post).toBeCalled();
|
|
176
|
+
expect(mockedNavigate).toBeCalled();
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
3
|
+
import Text from '../../../commons/Text';
|
|
4
|
+
import { Images, Colors } from '../../../configs';
|
|
5
|
+
import styles from '../styles/checkinHeaderStyles';
|
|
6
|
+
import CalendarSvg from '../../../../assets/images/Common/Calendar.svg';
|
|
7
|
+
|
|
8
|
+
const CheckinHeader = ({
|
|
9
|
+
date,
|
|
10
|
+
onPickPreviousDate,
|
|
11
|
+
onPickNextDate,
|
|
12
|
+
setShowCalendar,
|
|
13
|
+
}) => {
|
|
14
|
+
return (
|
|
15
|
+
<View style={styles.wrap}>
|
|
16
|
+
<Text type="H3" color={Colors.Gray9} bold>
|
|
17
|
+
{'Check in'}
|
|
18
|
+
</Text>
|
|
19
|
+
<View style={styles.row}>
|
|
20
|
+
<TouchableOpacity onPress={onPickPreviousDate}>
|
|
21
|
+
<Image source={Images.arrowLeft} />
|
|
22
|
+
</TouchableOpacity>
|
|
23
|
+
<TouchableOpacity onPress={setShowCalendar} style={styles.wrapDate}>
|
|
24
|
+
<Text color={Colors.Gray9} style={styles.marginRight10}>
|
|
25
|
+
{date.format('DD/MM/YYYY')}
|
|
26
|
+
</Text>
|
|
27
|
+
<CalendarSvg color={Colors.Primary} />
|
|
28
|
+
</TouchableOpacity>
|
|
29
|
+
<TouchableOpacity onPress={onPickNextDate}>
|
|
30
|
+
<Image source={Images.arrowLeft} style={styles.arrowRight} />
|
|
31
|
+
</TouchableOpacity>
|
|
32
|
+
</View>
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default CheckinHeader;
|