@eohjsc/react-native-smart-city 0.7.21 → 0.7.23
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 +1 -1
- package/src/Images/Common/default_end_device.png +0 -0
- package/src/commons/ActionGroup/TerminalBoxTemplate.js +3 -0
- package/src/commons/ActionTemplate/OnOffButtonAction.js +38 -4
- package/src/commons/ActionTemplate/OnOffSimpleAction.js +55 -15
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +46 -8
- package/src/commons/ActionTemplate/SwitchButtonAction.js +35 -4
- package/src/commons/ActionTemplate/ThreeButtonAction.js +13 -3
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +46 -7
- package/src/commons/ActionTemplate/__test__/OnOffSimpleAction.test.js +66 -6
- package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +53 -13
- package/src/commons/ActionTemplate/__test__/SwitchButtonAction.test.js +46 -7
- package/src/commons/ActionTemplate/__test__/index.test.js +6 -2
- package/src/commons/ActionTemplate/index.js +65 -10
- package/src/commons/Dashboard/MyUnit/index.js +19 -20
- package/src/commons/DevMode/Search.js +1 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +5 -5
- package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +26 -32
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +8 -6
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +6 -0
- package/src/commons/SubUnit/OneTap/index.js +5 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +9 -11
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +2 -2
- package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +1 -1
- package/src/configs/API.js +10 -0
- package/src/configs/AccessibilityLabel.js +5 -1
- package/src/configs/Images.js +1 -0
- package/src/navigations/AddMemberStack.js +3 -3
- package/src/screens/ActivityLog/__test__/index.test.js +10 -0
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/AddCommon/SelectUnit.js +3 -2
- package/src/screens/AddLocationMaps/__test__/index.test.js +13 -13
- package/src/screens/Automate/AddNewAction/ChooseAction.js +15 -51
- package/src/screens/Automate/AddNewAction/SelectControlDevices.js +13 -3
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +74 -54
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +114 -4
- package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +9 -11
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +37 -8
- package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +5 -0
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddAutomationTypeSmart.test.js +31 -0
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +18 -2
- package/src/screens/Automate/Components/InputName.js +7 -6
- package/src/screens/Automate/Constants.js +12 -0
- package/src/screens/Automate/EditActionsList/UpdateActionScript.js +24 -55
- package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +298 -41
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +2 -2
- package/src/screens/Automate/EditActionsList/index.js +26 -14
- package/src/screens/Automate/MultiUnits.js +9 -1
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +3 -3
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +4 -10
- package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +2 -4
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +78 -0
- package/src/screens/Automate/ScriptDetail/index.js +16 -10
- package/src/screens/Automate/ScriptDetail/utils.js +39 -35
- package/src/screens/Automate/SetSchedule/AddEditConditionSchedule.js +27 -160
- package/src/screens/Automate/SetSchedule/EditSchedule.js +269 -0
- package/src/screens/Automate/SetSchedule/__test__/AddEditConditionSchedule.test.js +327 -22
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +35 -22
- package/src/screens/Automate/SetSchedule/components/RepeatOptionsPopup.js +2 -8
- package/src/screens/Automate/SetSchedule/index.js +15 -129
- package/src/screens/Automate/SetSchedule/styles/indexStyles.js +9 -0
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -1
- package/src/screens/Automate/hooks/useAction.js +222 -0
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +69 -13
- package/src/screens/ConfirmUnitDeletion/index.js +14 -14
- package/src/screens/Device/__test__/detail.test.js +48 -1
- package/src/screens/Device/detail.js +46 -3
- package/src/screens/PlayBackCamera/__test__/index.test.js +48 -13
- package/src/screens/PlayBackCamera/index.js +1 -1
- package/src/screens/Sharing/Components/ConfigItem.js +34 -0
- package/src/screens/Sharing/Components/DeviceItem.js +77 -0
- package/src/screens/Sharing/Components/ItemChangeRole.js +3 -4
- package/src/screens/Sharing/Components/ShareDeviceSelector.js +255 -0
- package/src/screens/Sharing/Components/Styles/CheckBoxCustomStyles.js +1 -1
- package/src/screens/Sharing/Components/Styles/DeviceItemStyles.js +11 -27
- package/src/screens/Sharing/{Styles/SelectPermissionStyles.js → Components/Styles/ShareDeviceSelectorStyles.js} +3 -11
- package/src/screens/Sharing/Components/SubUnitItem.js +28 -0
- package/src/screens/Sharing/Components/SubUnitTreeView.js +68 -0
- package/src/screens/Sharing/Components/TitleCheckBox.js +23 -41
- package/src/screens/Sharing/Components/__test__/ItemChangeRole.test.js +7 -7
- package/src/screens/Sharing/Components/__test__/ShareDeviceSelector.test.js +298 -0
- package/src/screens/Sharing/Components/index.js +14 -1
- package/src/screens/Sharing/InfoMemberUnit.js +20 -20
- package/src/screens/Sharing/SelectShareDevice.js +11 -255
- package/src/screens/Sharing/SelectUser.js +12 -12
- package/src/screens/Sharing/UpdateShareDevice.js +45 -301
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +58 -11
- package/src/screens/Sharing/__test__/SelectShareDevice.test.js +51 -160
- package/src/screens/Sharing/__test__/SelectUser.test.js +72 -10
- package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +49 -209
- package/src/utils/Apis/axios.js +6 -0
- package/src/utils/I18n/translations/en.js +9 -1
- package/src/utils/I18n/translations/vi.js +10 -2
- package/src/commons/Sharing/StationDevicePermissions.js +0 -204
- package/src/screens/Automate/constants.js +0 -0
- package/src/screens/Sharing/Components/CheckBoxConfig.js +0 -44
- package/src/screens/Sharing/Components/CheckBoxSubUnit.js +0 -35
- package/src/screens/Sharing/Components/EndDevice.js +0 -93
- package/src/screens/Sharing/Components/Styles/CheckBoxConfigStyles.js +0 -18
- package/src/screens/Sharing/Components/Styles/TitleCheckBoxStyles.js +0 -21
- package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +0 -31
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { create, act } from 'react-test-renderer';
|
|
3
|
-
import { TouchableOpacity } from 'react-native';
|
|
4
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
-
|
|
6
|
-
import InfoMemberUnit from '../InfoMemberUnit';
|
|
7
|
-
import { HeaderCustom } from '../../../commons/Header';
|
|
8
|
-
import { SCProvider } from '../../../context';
|
|
9
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
10
1
|
import { AlertAction, ViewButtonBottom } from '../../../commons';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
|
|
11
4
|
import API from '../../../configs/API';
|
|
12
5
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
13
|
-
import
|
|
6
|
+
import { HeaderCustom } from '../../../commons/Header';
|
|
7
|
+
import InfoMemberUnit from '../InfoMemberUnit';
|
|
14
8
|
import ItemChangeRole from '../Components/ItemChangeRole';
|
|
9
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
15
10
|
import ModalPopupCT from '../../../commons/ModalPopupCT';
|
|
11
|
+
import React from 'react';
|
|
16
12
|
import Routes from '../../../utils/Route';
|
|
17
|
-
import { useNavigation } from '@react-navigation/native';
|
|
18
13
|
import RowGuestInfo from '../../GuestInfo/components/RowGuestInfo';
|
|
14
|
+
import { SCProvider } from '../../../context';
|
|
15
|
+
import { TouchableOpacity } from 'react-native';
|
|
16
|
+
import api from '../../../utils/Apis/axios';
|
|
17
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
18
|
+
import { useNavigation } from '@react-navigation/native';
|
|
19
19
|
|
|
20
20
|
const mock = new MockAdapter(api.axiosInstance);
|
|
21
21
|
|
|
@@ -212,4 +212,51 @@ describe('Test InfoMemberUnit', () => {
|
|
|
212
212
|
});
|
|
213
213
|
expect(global.mockedNavigate).toHaveBeenCalledTimes(1);
|
|
214
214
|
});
|
|
215
|
+
|
|
216
|
+
it('test click left button', async () => {
|
|
217
|
+
jest.useFakeTimers();
|
|
218
|
+
mock.onGet(API.SHARE.UNIT_MEMBER_INFO(1, 1)).reply(200, {
|
|
219
|
+
id: 2,
|
|
220
|
+
identity: 'member',
|
|
221
|
+
name: 'user',
|
|
222
|
+
email: 'abc@gmail.com',
|
|
223
|
+
avatar: 'abc.png',
|
|
224
|
+
});
|
|
225
|
+
await act(async () => {
|
|
226
|
+
tree = await create(wrapComponent(route));
|
|
227
|
+
});
|
|
228
|
+
const instance = tree.root;
|
|
229
|
+
const touchChangeRole = instance.findByProps({
|
|
230
|
+
accessibilityLabel: AccessibilityLabel.CHANGE_ROLE,
|
|
231
|
+
});
|
|
232
|
+
await act(async () => {
|
|
233
|
+
await touchChangeRole.props.onPress();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const alertAction = instance.findByType(AlertAction);
|
|
237
|
+
expect(alertAction.props.visible).toEqual(true);
|
|
238
|
+
|
|
239
|
+
const itemChangeRole = instance.findAllByType(ItemChangeRole);
|
|
240
|
+
expect(itemChangeRole).toHaveLength(2);
|
|
241
|
+
|
|
242
|
+
await act(async () => {
|
|
243
|
+
await itemChangeRole[0].props.onPress();
|
|
244
|
+
});
|
|
245
|
+
await act(async () => {
|
|
246
|
+
await alertAction.props.rightButtonClick();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
await act(async () => {
|
|
250
|
+
jest.runAllTimers();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const viewButtonBottom = instance.findAllByType(ViewButtonBottom);
|
|
254
|
+
expect(viewButtonBottom).toHaveLength(2);
|
|
255
|
+
|
|
256
|
+
await act(async () => {
|
|
257
|
+
await viewButtonBottom[1].props.onLeftClick();
|
|
258
|
+
});
|
|
259
|
+
const modalPopupCT = instance.findByType(ModalPopupCT);
|
|
260
|
+
expect(modalPopupCT.props.isVisible).toEqual(false);
|
|
261
|
+
});
|
|
215
262
|
});
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { act } from '@testing-library/react-hooks';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Alert } from 'react-native';
|
|
4
|
-
import { create } from 'react-test-renderer';
|
|
5
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
6
|
-
import { ViewButtonBottom } from '../../../commons';
|
|
7
|
-
import { SCProvider } from '../../../context';
|
|
8
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
9
1
|
import API from '../../../configs/API';
|
|
10
|
-
import api from '../../../utils/Apis/axios';
|
|
11
2
|
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
12
|
-
import
|
|
3
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
+
import React from 'react';
|
|
13
6
|
import Routes from '../../../utils/Route';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import SelectShareDevice from '../SelectShareDevice';
|
|
9
|
+
import { ShareDeviceSelector } from '../Components';
|
|
10
|
+
import { ViewButtonBottom } from '../../../commons';
|
|
11
|
+
import { act } from '@testing-library/react-hooks';
|
|
12
|
+
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { create } from 'react-test-renderer';
|
|
14
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
15
|
+
import { useNavigation } from '@react-navigation/native';
|
|
14
16
|
|
|
15
17
|
const mock = new MockAdapter(api.axiosInstance);
|
|
16
|
-
jest.spyOn(Alert, 'alert').mockImplementation(() => {});
|
|
17
18
|
|
|
18
19
|
const wrapComponent = (route) => (
|
|
19
20
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -28,175 +29,65 @@ describe('Test SelectShareDevice', () => {
|
|
|
28
29
|
unit: { id: 1, name: 'unit 1' },
|
|
29
30
|
},
|
|
30
31
|
};
|
|
31
|
-
let listDevices
|
|
32
|
-
|
|
33
|
-
id: 1,
|
|
34
|
-
name: 'Sub unit',
|
|
35
|
-
devices: [
|
|
36
|
-
{
|
|
37
|
-
id: 2,
|
|
38
|
-
actions: [{ id: 3, name: 'action 1' }],
|
|
39
|
-
read_configs: [{ id: 4, name: 'config 1' }],
|
|
40
|
-
name: 'child1',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: 5,
|
|
44
|
-
actions: [{ id: 6, name: 'action 2' }],
|
|
45
|
-
read_configs: [{ id: 7, name: 'config 2' }],
|
|
46
|
-
name: 'child2',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: 8,
|
|
50
|
-
actions: [],
|
|
51
|
-
read_configs: [],
|
|
52
|
-
name: 'child3',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
afterEach(() => {
|
|
59
|
-
Alert.alert.mockReset();
|
|
32
|
+
let listDevices;
|
|
33
|
+
beforeEach(() => {
|
|
60
34
|
mock.resetHistory();
|
|
35
|
+
listDevices = [
|
|
36
|
+
{
|
|
37
|
+
id: 1,
|
|
38
|
+
name: 'Sub unit 1',
|
|
39
|
+
devices: [
|
|
40
|
+
{
|
|
41
|
+
id: 1,
|
|
42
|
+
icon_kit: 'https://xxx.png',
|
|
43
|
+
actions: [{ id: 1, name: 'action 1' }],
|
|
44
|
+
read_configs: [{ id: 1, name: 'config 1' }],
|
|
45
|
+
name: 'child1',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
61
50
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const checkBoxAllDevice = instance.find(
|
|
65
|
-
(el) =>
|
|
66
|
-
el.props.accessibilityLabel ===
|
|
67
|
-
`${AccessibilityLabel.CHECK_BOX_CUSTOM}-undefined`
|
|
68
|
-
);
|
|
69
|
-
expect(checkBoxAllDevice.props.isChecked).toEqual(statusCheckbox);
|
|
70
|
-
await act(async () => {
|
|
71
|
-
await checkBoxAllDevice.props.onPress();
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const clickCheckBoxSubUnit = async (instance, statusCheckbox) => {
|
|
76
|
-
const checkBoxSubunit = instance.find(
|
|
51
|
+
const clickChooseDevice = async (instance, deviceId, status) => {
|
|
52
|
+
const chooseDevice = instance.find(
|
|
77
53
|
(el) =>
|
|
78
54
|
el.props.accessibilityLabel ===
|
|
79
|
-
`${AccessibilityLabel.
|
|
55
|
+
`${AccessibilityLabel.SHARE_DEVICE.NAME_END_DEVICE}-device-${deviceId}`
|
|
80
56
|
);
|
|
81
|
-
expect(checkBoxSubunit.props.isChecked).toEqual(statusCheckbox);
|
|
82
57
|
await act(async () => {
|
|
83
|
-
|
|
58
|
+
chooseDevice.props.onPress();
|
|
84
59
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const clickCheckBoxConfig = async (instance, configId, statusCheckbox) => {
|
|
88
|
-
let checkBoxConfig = instance.find(
|
|
60
|
+
const iconCheck = instance.findAll(
|
|
89
61
|
(el) =>
|
|
90
62
|
el.props.accessibilityLabel ===
|
|
91
|
-
|
|
63
|
+
`${AccessibilityLabel.SHARE_DEVICE.ICON_CHECK}-device-${deviceId}` &&
|
|
64
|
+
el.type === IconOutline
|
|
92
65
|
);
|
|
93
|
-
expect(
|
|
94
|
-
await act(async () => {
|
|
95
|
-
await checkBoxConfig.props.onPress();
|
|
96
|
-
});
|
|
66
|
+
expect(iconCheck).toHaveLength(status ? 1 : 0);
|
|
97
67
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(el) =>
|
|
102
|
-
el.props.accessibilityLabel ===
|
|
103
|
-
`${AccessibilityLabel.SHARE_DEVICE.EXPAND_END_DEVICE}-${indexEndDevice}`
|
|
104
|
-
);
|
|
105
|
-
expect(expandEndDevice.props.name).toEqual(statusIcon);
|
|
106
|
-
await act(async () => {
|
|
107
|
-
await expandEndDevice.props.onPress();
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const clickNameEndDevice = async (instance, indexEndDevice) => {
|
|
112
|
-
const nameEndDevice = instance.find(
|
|
113
|
-
(el) =>
|
|
114
|
-
el.props.accessibilityLabel ===
|
|
115
|
-
`${AccessibilityLabel.SHARE_DEVICE.CLICK_NAME_END_DEVICE}-${indexEndDevice}`
|
|
116
|
-
);
|
|
117
|
-
await act(async () => {
|
|
118
|
-
await nameEndDevice.props.onPress();
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
it('test user select share device', async () => {
|
|
123
|
-
mock.onGet(API.SHARE.UNIT_PERMISSIONS(1)).reply(200, listDevices);
|
|
124
|
-
|
|
68
|
+
test('test render SelectShareDevice', async () => {
|
|
69
|
+
const mockedNavigate = useNavigation().navigate;
|
|
70
|
+
mock.onGet(API.SHARE.UNIT_PERMISSIONS_v2(1)).reply(200, listDevices);
|
|
125
71
|
await act(async () => {
|
|
126
72
|
tree = await create(wrapComponent(route));
|
|
127
73
|
});
|
|
128
|
-
let instance = tree.root;
|
|
129
|
-
await clickNameEndDevice(instance, 0); // click to select all configs in end device index 0
|
|
130
|
-
await clickNameEndDevice(instance, 0); // click again to remove all configs, and coverage expand end device
|
|
131
|
-
await clickCheckBoxConfig(instance, 3, false); // click to select action
|
|
132
|
-
await clickCheckBoxConfig(instance, 3, true); // click again to coverage case status reversal
|
|
133
|
-
await clickCheckBoxConfig(instance, 4, false); // click to select config
|
|
134
|
-
await clickCheckBoxConfig(instance, 4, true); // click again to coverage case status reversal
|
|
135
|
-
await clickExpandEndDevice(instance, 0, 'up');
|
|
136
|
-
await clickExpandEndDevice(instance, 0, 'down'); // click again to coverage case status reversal
|
|
137
74
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await
|
|
75
|
+
const instance = tree.root;
|
|
76
|
+
expect(instance.findAllByType(ShareDeviceSelector)).toHaveLength(1);
|
|
77
|
+
expect(instance.findAllByType(ViewButtonBottom)).toHaveLength(1);
|
|
78
|
+
await clickChooseDevice(instance, 1, true);
|
|
142
79
|
|
|
143
|
-
const
|
|
80
|
+
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
144
81
|
await act(async () => {
|
|
145
|
-
|
|
82
|
+
viewButtonBottom.props.onRightClick();
|
|
146
83
|
});
|
|
147
|
-
expect(
|
|
148
|
-
|
|
84
|
+
expect(viewButtonBottom.props.rightTitle).toEqual('Next');
|
|
85
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.SharingInviteMembers, {
|
|
86
|
+
unit: route.params.unit,
|
|
149
87
|
permissions: {
|
|
150
|
-
read_permissions: [
|
|
151
|
-
|
|
152
|
-
{ id: 8, values: [] },
|
|
153
|
-
],
|
|
154
|
-
control_permissions: [{ id: 5, values: [6] }],
|
|
88
|
+
read_permissions: [{ id: 1, values: [1] }],
|
|
89
|
+
control_permissions: [{ id: 1, values: [1] }],
|
|
155
90
|
},
|
|
156
91
|
});
|
|
157
92
|
});
|
|
158
|
-
|
|
159
|
-
it('test no data, api get UNIT_PERMISSIONS false', async () => {
|
|
160
|
-
mock.onGet(API.SHARE.UNIT_PERMISSIONS(1)).reply(400);
|
|
161
|
-
|
|
162
|
-
await act(async () => {
|
|
163
|
-
tree = await create(wrapComponent(route));
|
|
164
|
-
});
|
|
165
|
-
const instance = tree.root;
|
|
166
|
-
|
|
167
|
-
let text = instance.find(
|
|
168
|
-
(el) =>
|
|
169
|
-
el.props.accessibilityLabel === AccessibilityLabel.TEXT_NO_DATA_STATIONS
|
|
170
|
-
);
|
|
171
|
-
expect(text.props.children).toEqual('No data');
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('user not choose device click button back', async () => {
|
|
175
|
-
await act(async () => {
|
|
176
|
-
tree = await create(wrapComponent(route));
|
|
177
|
-
});
|
|
178
|
-
const instance = tree.root;
|
|
179
|
-
const ViewButtonBottomElement = instance.findAllByType(ViewButtonBottom);
|
|
180
|
-
expect(ViewButtonBottomElement).toHaveLength(1);
|
|
181
|
-
|
|
182
|
-
await act(async () => {
|
|
183
|
-
ViewButtonBottomElement[0].props.onLeftClick();
|
|
184
|
-
});
|
|
185
|
-
expect(global.mockedGoBack).toBeCalled();
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('user not choose device click button next', async () => {
|
|
189
|
-
await act(async () => {
|
|
190
|
-
tree = await create(wrapComponent(route));
|
|
191
|
-
});
|
|
192
|
-
const instance = tree.root;
|
|
193
|
-
const ViewButtonBottomElement = instance.findAllByType(ViewButtonBottom);
|
|
194
|
-
expect(ViewButtonBottomElement).toHaveLength(1);
|
|
195
|
-
await act(async () => {
|
|
196
|
-
ViewButtonBottomElement[0].props.onRightClick();
|
|
197
|
-
});
|
|
198
|
-
expect(Alert.alert.mock.calls[0][1]).toEqual(
|
|
199
|
-
'Please choose at least one sensor.'
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
93
|
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
1
|
+
import { Button, ViewButtonBottom } from '../../../commons';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
4
3
|
|
|
5
|
-
import { ViewButtonBottom, Button } from '../../../commons';
|
|
6
|
-
import _TextInput from '../../../commons/Form/TextInput';
|
|
7
|
-
import AccountList from '../../../commons/Auth/AccountList';
|
|
8
4
|
import { API } from '../../../configs';
|
|
9
|
-
import
|
|
5
|
+
import AccountList from '../../../commons/Auth/AccountList';
|
|
6
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
7
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
8
|
+
import React from 'react';
|
|
10
9
|
import { SCProvider } from '../../../context';
|
|
11
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
12
|
-
import api from '../../../utils/Apis/axios';
|
|
13
10
|
import SharingInviteMembers from '../SelectUser';
|
|
14
11
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
15
|
-
import
|
|
12
|
+
import _TextInput from '../../../commons/Form/TextInput';
|
|
13
|
+
import api from '../../../utils/Apis/axios';
|
|
14
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
15
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
16
16
|
|
|
17
17
|
const wrapComponent = (route) => (
|
|
18
18
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -27,6 +27,7 @@ describe('test SharingInviteMembers container', () => {
|
|
|
27
27
|
let route;
|
|
28
28
|
|
|
29
29
|
beforeEach(() => {
|
|
30
|
+
mock.resetHistory();
|
|
30
31
|
route = {
|
|
31
32
|
params: {
|
|
32
33
|
unit: {
|
|
@@ -67,6 +68,30 @@ describe('test SharingInviteMembers container', () => {
|
|
|
67
68
|
expect(viewButtonBottom.props.rightDisabled).toBeTruthy();
|
|
68
69
|
});
|
|
69
70
|
|
|
71
|
+
it('search user by phone api response error', async () => {
|
|
72
|
+
const spyToast = jest.spyOn(ToastBottomHelper, 'error');
|
|
73
|
+
const phone = '0909123456';
|
|
74
|
+
mock.onGet(API.SHARE.SEARCH_USER_BY_PHONE(phone)).reply(400);
|
|
75
|
+
await act(async () => {
|
|
76
|
+
tree = await create(wrapComponent(route));
|
|
77
|
+
});
|
|
78
|
+
const instance = tree.root;
|
|
79
|
+
|
|
80
|
+
const textInput = instance.findByType(_TextInput);
|
|
81
|
+
const button = instance.findByType(Button);
|
|
82
|
+
|
|
83
|
+
expect(textInput.props.errorText).toEqual('');
|
|
84
|
+
await act(async () => {
|
|
85
|
+
textInput.props.onChange(phone);
|
|
86
|
+
});
|
|
87
|
+
await act(async () => {
|
|
88
|
+
button.props.onPress();
|
|
89
|
+
});
|
|
90
|
+
let accountList = instance.findAllByType(AccountList);
|
|
91
|
+
expect(accountList).toHaveLength(0);
|
|
92
|
+
expect(spyToast).toBeCalledWith('Not found');
|
|
93
|
+
});
|
|
94
|
+
|
|
70
95
|
it('input phone valid and call api share permission', async () => {
|
|
71
96
|
const phone = '0909123456';
|
|
72
97
|
const spyToast = jest.spyOn(ToastBottomHelper, 'success');
|
|
@@ -104,6 +129,43 @@ describe('test SharingInviteMembers container', () => {
|
|
|
104
129
|
expect(spyToast).toBeCalledWith('Invited user');
|
|
105
130
|
});
|
|
106
131
|
|
|
132
|
+
it('input phone valid and call api share permission error', async () => {
|
|
133
|
+
const phone = '0909123456';
|
|
134
|
+
const spyToast = jest.spyOn(ToastBottomHelper, 'success');
|
|
135
|
+
spyToast.mockClear();
|
|
136
|
+
mock.onGet(API.SHARE.SEARCH_USER_BY_PHONE(phone)).reply(200, {
|
|
137
|
+
id: 3,
|
|
138
|
+
name: 'user add',
|
|
139
|
+
phone_number: phone,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
mock.onPost(API.SHARE.SHARE_V2()).reply(400);
|
|
143
|
+
await act(async () => {
|
|
144
|
+
tree = await create(wrapComponent(route));
|
|
145
|
+
});
|
|
146
|
+
const instance = tree.root;
|
|
147
|
+
const textInput = instance.findByType(_TextInput);
|
|
148
|
+
const buttonCheckUser = instance.findByType(Button);
|
|
149
|
+
let accountList = instance.findAllByType(AccountList);
|
|
150
|
+
expect(accountList).toHaveLength(0);
|
|
151
|
+
await act(async () => {
|
|
152
|
+
await textInput.props.onChange(phone);
|
|
153
|
+
});
|
|
154
|
+
await act(async () => {
|
|
155
|
+
await buttonCheckUser.props.onPress();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
accountList = instance.findAllByType(AccountList);
|
|
159
|
+
expect(accountList).toHaveLength(1);
|
|
160
|
+
expect(accountList[0].props.accounts).toHaveLength(1);
|
|
161
|
+
|
|
162
|
+
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
163
|
+
await act(async () => {
|
|
164
|
+
viewButtonBottom.props.onRightClick();
|
|
165
|
+
});
|
|
166
|
+
expect(spyToast).not.toHaveBeenCalled();
|
|
167
|
+
});
|
|
168
|
+
|
|
107
169
|
it('input 2 email valid and remove 1 email then call api share permission', async () => {
|
|
108
170
|
const email_1 = 'test1@gmail.com';
|
|
109
171
|
const email_2 = 'test2@gmail.com';
|