@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { create, act } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import MemberList from '../MemberList';
|
|
5
|
+
import { AlertAction } from '../../../commons';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
import { TouchableOpacity } from 'react-native';
|
|
9
|
+
import Routes from '../../../utils/Route';
|
|
10
|
+
|
|
11
|
+
jest.mock('../../../hooks/Common', () => {
|
|
12
|
+
return {
|
|
13
|
+
useIsOwnerOfUnit: () => ({ isOwner: false }),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const mockedNavigate = jest.fn();
|
|
18
|
+
const mockUseIsFocused = jest.fn();
|
|
19
|
+
|
|
20
|
+
jest.mock('@react-navigation/native', () => {
|
|
21
|
+
return {
|
|
22
|
+
...jest.requireActual('@react-navigation/native'),
|
|
23
|
+
useNavigation: () => ({
|
|
24
|
+
navigate: mockedNavigate,
|
|
25
|
+
}),
|
|
26
|
+
useIsFocused: () => ({
|
|
27
|
+
isFocused: mockUseIsFocused,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const wrapComponent = (route, state) => (
|
|
33
|
+
<SCProvider initState={mockSCStore({})}>
|
|
34
|
+
<MemberList route={route} />
|
|
35
|
+
</SCProvider>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
describe('test MemberList', () => {
|
|
39
|
+
let route;
|
|
40
|
+
let localState = {
|
|
41
|
+
auth: {
|
|
42
|
+
account: {
|
|
43
|
+
user: {
|
|
44
|
+
id: 2,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
route = {
|
|
52
|
+
params: {
|
|
53
|
+
unitId: 1,
|
|
54
|
+
unit: {
|
|
55
|
+
id: 1,
|
|
56
|
+
user_id: 2,
|
|
57
|
+
name: '',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('AlertAction rightButtonClick', async () => {
|
|
64
|
+
let tree;
|
|
65
|
+
await act(async () => {
|
|
66
|
+
tree = await create(wrapComponent(route, localState));
|
|
67
|
+
});
|
|
68
|
+
const instance = tree.root;
|
|
69
|
+
const alertAction = instance.findByType(AlertAction);
|
|
70
|
+
await act(async () => {
|
|
71
|
+
alertAction.props.rightButtonClick();
|
|
72
|
+
});
|
|
73
|
+
const MemberListButtons = instance.findAllByType(TouchableOpacity);
|
|
74
|
+
await MemberListButtons[1].props.onPress();
|
|
75
|
+
expect(mockedNavigate).not.toBeCalledWith(Routes.AddMemberStack, {
|
|
76
|
+
screen: Routes.SharingSelectPermission,
|
|
77
|
+
params: { unit: { id: 1 } },
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -2,16 +2,17 @@ import { act } from '@testing-library/react-hooks';
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { FlatList, Text, Platform } from 'react-native';
|
|
4
4
|
import { create } from 'react-test-renderer';
|
|
5
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
6
|
+
|
|
5
7
|
import SelectPermission from '../SelectPermission';
|
|
6
|
-
import axios from 'axios';
|
|
7
8
|
import { SensorItem, TitleCheckBox } from '../Components';
|
|
8
9
|
import { ViewButtonBottom } from '../../../commons';
|
|
9
|
-
import Routes from '../../../utils/Route';
|
|
10
10
|
import { SCProvider } from '../../../context';
|
|
11
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
12
12
|
import API from '../../../configs/API';
|
|
13
|
+
import api from '../../../utils/Apis/axios';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
15
16
|
|
|
16
17
|
const mockSetState = jest.fn();
|
|
17
18
|
jest.mock('react', () => {
|
|
@@ -63,7 +64,6 @@ describe('Test SelectPermission', () => {
|
|
|
63
64
|
const mockSetDataStations = jest.fn();
|
|
64
65
|
|
|
65
66
|
afterEach(() => {
|
|
66
|
-
axios.mockClear();
|
|
67
67
|
mockSetState.mockClear();
|
|
68
68
|
mockSetTickAllDevice.mockClear();
|
|
69
69
|
mockSetActiveItemId.mockClear();
|
|
@@ -92,15 +92,16 @@ describe('Test SelectPermission', () => {
|
|
|
92
92
|
act(() => {
|
|
93
93
|
tree = create(wrapComponent(route));
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
const instance = tree.root;
|
|
96
|
+
const ViewButtonBottoms = instance.findAllByType(ViewButtonBottom);
|
|
97
|
+
expect(ViewButtonBottoms).toHaveLength(1);
|
|
96
98
|
});
|
|
97
99
|
|
|
98
100
|
it('render empty list', () => {
|
|
99
101
|
mockLoading();
|
|
100
102
|
Platform.OS = 'ios';
|
|
101
|
-
|
|
102
103
|
route.params.unit = 1;
|
|
103
|
-
|
|
104
|
+
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(200);
|
|
104
105
|
act(() => {
|
|
105
106
|
tree = create(wrapComponent(route));
|
|
106
107
|
});
|
|
@@ -111,9 +112,8 @@ describe('Test SelectPermission', () => {
|
|
|
111
112
|
|
|
112
113
|
it('test get unit fail', () => {
|
|
113
114
|
mockLoading();
|
|
114
|
-
|
|
115
115
|
route.params.unit = 1;
|
|
116
|
-
|
|
116
|
+
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(400);
|
|
117
117
|
act(() => {
|
|
118
118
|
tree = create(wrapComponent(route));
|
|
119
119
|
});
|
|
@@ -183,27 +183,15 @@ describe('Test SelectPermission', () => {
|
|
|
183
183
|
act(() => {
|
|
184
184
|
ViewButtonBottomElement[0].props.onRightClick();
|
|
185
185
|
});
|
|
186
|
-
expect(mockNavigate).toBeCalledWith(Routes.SharingInviteMembers, {
|
|
187
|
-
permissions: {
|
|
188
|
-
control_permissions: [{ id: 123, values: [136] }],
|
|
189
|
-
read_permissions: [{ id: 123, values: [137] }],
|
|
190
|
-
},
|
|
191
|
-
unit: 1,
|
|
192
|
-
});
|
|
193
186
|
act(() => {
|
|
194
187
|
ViewButtonBottomElement[0].props.onLeftClick();
|
|
195
188
|
});
|
|
196
189
|
expect(mockGoBack).toBeCalled();
|
|
197
190
|
});
|
|
191
|
+
|
|
198
192
|
it('test selectPermission type share_device', () => {
|
|
199
193
|
mocSetdata();
|
|
200
|
-
|
|
201
|
-
params: {
|
|
202
|
-
unit: { id: 1 },
|
|
203
|
-
type: 'share_device',
|
|
204
|
-
member: { id: 1, name: 'a', phone_number: '89898888' },
|
|
205
|
-
},
|
|
206
|
-
};
|
|
194
|
+
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
207
195
|
const response = {
|
|
208
196
|
status: 200,
|
|
209
197
|
data: [
|
|
@@ -223,28 +211,30 @@ describe('Test SelectPermission', () => {
|
|
|
223
211
|
},
|
|
224
212
|
],
|
|
225
213
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
214
|
+
mock
|
|
215
|
+
.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1))
|
|
216
|
+
.reply(200, response.data);
|
|
217
|
+
const routes = {
|
|
218
|
+
params: {
|
|
219
|
+
unit: { id: 1 },
|
|
220
|
+
type: 'update_shared',
|
|
221
|
+
member: {
|
|
222
|
+
id: 1,
|
|
223
|
+
name: 'a',
|
|
224
|
+
phone_number: '89898888',
|
|
225
|
+
email: 'abcderfg@gmail.com',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
229
|
act(() => {
|
|
230
230
|
tree = create(wrapComponent(routes));
|
|
231
231
|
});
|
|
232
232
|
const instance = tree.root;
|
|
233
233
|
const ViewButtonBottomElement = instance.findAllByType(ViewButtonBottom);
|
|
234
|
-
expect(ViewButtonBottomElement).toHaveLength(1);
|
|
235
|
-
expect(axios.get).toHaveBeenCalledWith(
|
|
236
|
-
API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1),
|
|
237
|
-
{}
|
|
238
|
-
);
|
|
239
234
|
act(() => {
|
|
240
235
|
ViewButtonBottomElement[0].props.onRightClick();
|
|
241
236
|
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
control_permissions: [{ id: 123, values: [136] }],
|
|
245
|
-
read_permissions: [{ id: 123, values: [137] }],
|
|
246
|
-
},
|
|
247
|
-
unit: 1,
|
|
248
|
-
});
|
|
237
|
+
mock.onPost(API.SHARE.SHARE()).reply(200);
|
|
238
|
+
expect(mockGoBack).toBeCalled();
|
|
249
239
|
});
|
|
250
240
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { create, act } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
4
|
|
|
5
5
|
import SelectUser from '../SelectUser';
|
|
6
6
|
import { TESTID } from '../../../configs/Constants';
|
|
@@ -11,6 +11,7 @@ import { API } from '../../../configs';
|
|
|
11
11
|
import { getTranslate } from '../../../utils/I18n';
|
|
12
12
|
import { SCProvider } from '../../../context';
|
|
13
13
|
import { mockSCStore } from '../../../context/mockStore';
|
|
14
|
+
import api from '../../../utils/Apis/axios';
|
|
14
15
|
|
|
15
16
|
const wrapComponent = (route) => (
|
|
16
17
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -18,13 +19,13 @@ const wrapComponent = (route) => (
|
|
|
18
19
|
</SCProvider>
|
|
19
20
|
);
|
|
20
21
|
|
|
22
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
23
|
+
|
|
21
24
|
const mockedNavigate = jest.fn();
|
|
22
25
|
const mockedGoBack = jest.fn();
|
|
23
26
|
const mockedDangerouslyGetState = jest.fn();
|
|
24
27
|
const mockedDangerouslyGetParentGoBack = jest.fn();
|
|
25
28
|
|
|
26
|
-
jest.mock('axios');
|
|
27
|
-
|
|
28
29
|
jest.mock('react-redux', () => {
|
|
29
30
|
return {
|
|
30
31
|
...jest.requireActual('react-redux'),
|
|
@@ -52,7 +53,6 @@ describe('test SelectUser container', () => {
|
|
|
52
53
|
let route;
|
|
53
54
|
|
|
54
55
|
beforeEach(() => {
|
|
55
|
-
axios.post.mockClear();
|
|
56
56
|
route = {
|
|
57
57
|
params: {
|
|
58
58
|
unit: {
|
|
@@ -70,12 +70,6 @@ describe('test SelectUser container', () => {
|
|
|
70
70
|
return instance.find((el) => el.props.testID === id);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const mockAxiosPost = (response) => {
|
|
74
|
-
axios.post.mockImplementation(async () => {
|
|
75
|
-
return await response;
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
73
|
test('create', async () => {
|
|
80
74
|
await act(async () => {
|
|
81
75
|
tree = create(wrapComponent(route));
|
|
@@ -125,11 +119,7 @@ describe('test SelectUser container', () => {
|
|
|
125
119
|
});
|
|
126
120
|
|
|
127
121
|
test('_TextInput onChange phone, invalidate and not call api sharedPermission', async () => {
|
|
128
|
-
|
|
129
|
-
status: 200,
|
|
130
|
-
};
|
|
131
|
-
mockAxiosPost(response);
|
|
132
|
-
|
|
122
|
+
mock.onPost(API.SHARE.SHARE()).reply(200);
|
|
133
123
|
await act(async () => {
|
|
134
124
|
tree = create(wrapComponent(route));
|
|
135
125
|
});
|
|
@@ -151,48 +141,37 @@ describe('test SelectUser container', () => {
|
|
|
151
141
|
expect(textInput.props.errorText).toEqual(
|
|
152
142
|
getTranslate('en', 'invalid_phone_number_or_email')
|
|
153
143
|
);
|
|
154
|
-
expect(axios.post).not.toHaveBeenCalled();
|
|
155
144
|
});
|
|
156
145
|
|
|
157
146
|
test('_TextInput onChange phone, validated and call api sharedPermission', async () => {
|
|
158
|
-
const response = {
|
|
159
|
-
status: 200,
|
|
160
|
-
data: {
|
|
161
|
-
user: {
|
|
162
|
-
id: 2,
|
|
163
|
-
name: 'user add',
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
mockAxiosPost(response);
|
|
168
|
-
|
|
169
147
|
await act(async () => {
|
|
170
148
|
tree = create(wrapComponent(route));
|
|
171
149
|
});
|
|
172
150
|
const instance = tree.root;
|
|
173
|
-
|
|
174
151
|
const textInput = instance.findByType(_TextInput);
|
|
175
152
|
const button = instance.findByType(Button);
|
|
176
|
-
|
|
177
153
|
let accountList = instance.findAllByType(AccountList);
|
|
178
154
|
expect(accountList).toHaveLength(0);
|
|
179
|
-
|
|
180
155
|
await act(async () => {
|
|
181
156
|
await textInput.props.onChange('0909123456');
|
|
182
157
|
});
|
|
183
|
-
|
|
158
|
+
mock.onPost(API.SHARE.SHARE()).reply(200, {
|
|
159
|
+
user: {
|
|
160
|
+
id: 2,
|
|
161
|
+
name: 'user add',
|
|
162
|
+
phone_number: '0909123456',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
184
165
|
await act(async () => {
|
|
185
166
|
await button.props.onPress();
|
|
186
167
|
});
|
|
187
|
-
|
|
168
|
+
await act(async () => {
|
|
169
|
+
await textInput.props.onChange('test123@gmail.com');
|
|
170
|
+
});
|
|
188
171
|
expect(textInput.props.errorText).toEqual('');
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
email: '',
|
|
192
|
-
unit: 1,
|
|
193
|
-
permissions: { controlPermissions: {}, readPermissions: {} },
|
|
172
|
+
await act(async () => {
|
|
173
|
+
await button.props.onPress();
|
|
194
174
|
});
|
|
195
|
-
|
|
196
175
|
accountList = instance.findAllByType(AccountList);
|
|
197
176
|
expect(accountList).toHaveLength(1);
|
|
198
177
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
|
|
5
5
|
import { TESTID } from '../../../configs/Constants';
|
|
@@ -11,8 +11,9 @@ import { API } from '../../../configs';
|
|
|
11
11
|
import { TouchableOpacity } from 'react-native';
|
|
12
12
|
import { ModalCustom } from '../../../commons/Modal';
|
|
13
13
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
14
|
+
import api from '../../../utils/Apis/axios';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
16
17
|
|
|
17
18
|
const wrapComponent = (route) => (
|
|
18
19
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -26,8 +27,6 @@ describe('Test SideMenuDetail', () => {
|
|
|
26
27
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
27
28
|
|
|
28
29
|
afterEach(() => {
|
|
29
|
-
axios.get.mockClear();
|
|
30
|
-
axios.post.mockClear();
|
|
31
30
|
spyToastSuccess.mockReset();
|
|
32
31
|
spyToastSuccess.mockRestore();
|
|
33
32
|
});
|
|
@@ -60,7 +59,7 @@ describe('Test SideMenuDetail', () => {
|
|
|
60
59
|
expect(popup.props.isVisible).toBeFalsy();
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
const
|
|
62
|
+
const enterPasscode = async (instance) => {
|
|
64
63
|
const inputPasscode = instance.find(
|
|
65
64
|
(item) => item.props.testID === TESTID.PASSCODE_FIELD
|
|
66
65
|
);
|
|
@@ -124,24 +123,14 @@ describe('Test SideMenuDetail', () => {
|
|
|
124
123
|
data: [{ id: 1, name: 'Ken' }],
|
|
125
124
|
};
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
status: 200,
|
|
135
|
-
data: [],
|
|
136
|
-
};
|
|
137
|
-
});
|
|
126
|
+
mock
|
|
127
|
+
.onGet(API.DEVICE.SIDE_MENU_DETAIL(1, 1))
|
|
128
|
+
.reply(200, response_side_menu.data);
|
|
129
|
+
mock
|
|
130
|
+
.onGet(API.SHARE.UNITS_MEMBERS(1))
|
|
131
|
+
.reply(200, response_unit_members.data);
|
|
132
|
+
mock.onPost(API.DEVICE.TRIGGER_ACTION(1)).reply(200, []);
|
|
138
133
|
|
|
139
|
-
axios.post.mockImplementation(() => {
|
|
140
|
-
return {
|
|
141
|
-
status: 200,
|
|
142
|
-
data: [],
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
134
|
const route = {
|
|
146
135
|
params: {
|
|
147
136
|
unit: { id: 1 },
|
|
@@ -158,7 +147,7 @@ describe('Test SideMenuDetail', () => {
|
|
|
158
147
|
await onPressSubmitData(instance);
|
|
159
148
|
expect(spyToastError).toBeCalled();
|
|
160
149
|
|
|
161
|
-
await
|
|
150
|
+
await enterPasscode(instance);
|
|
162
151
|
await onPressSubmitData(instance);
|
|
163
152
|
expect(spyToastSuccess).toBeCalled();
|
|
164
153
|
});
|
|
@@ -61,7 +61,6 @@ const SideMenuDetail = memo(({ route }) => {
|
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
64
|
[unit, dataForm]
|
|
66
65
|
);
|
|
67
66
|
|
|
@@ -88,7 +87,7 @@ const SideMenuDetail = memo(({ route }) => {
|
|
|
88
87
|
|
|
89
88
|
data.action_zigbee = actionZigbee;
|
|
90
89
|
|
|
91
|
-
const { success } = await axiosPost(API.
|
|
90
|
+
const { success } = await axiosPost(API.DEVICE.TRIGGER_ACTION(sensor.id), {
|
|
92
91
|
key: sideMenu.action,
|
|
93
92
|
data,
|
|
94
93
|
source: 'smart_lock',
|
|
@@ -105,7 +104,7 @@ const SideMenuDetail = memo(({ route }) => {
|
|
|
105
104
|
|
|
106
105
|
const fetchSideMenuDetail = useCallback(async () => {
|
|
107
106
|
const { success, data } = await axiosGet(
|
|
108
|
-
API.
|
|
107
|
+
API.DEVICE.SIDE_MENU_DETAIL(sensor.id, side_menu.id)
|
|
109
108
|
);
|
|
110
109
|
if (success) {
|
|
111
110
|
setSideMenu(data);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback, useState, useMemo } from 'react';
|
|
2
|
-
import { View, TouchableOpacity
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import WrapHeaderScrollable from '../../../../commons/Sharing/WrapHeaderScrollable';
|
|
4
4
|
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
5
5
|
import SmartTiviActionTemplate from '../../../../commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate';
|
|
@@ -14,6 +14,7 @@ import { Remote, SmartIr, Union } from '../../../../Images/SmartIr';
|
|
|
14
14
|
|
|
15
15
|
import styles from './GroupButtonByTypeStyles';
|
|
16
16
|
import { TESTID } from '../../../../configs/Constants';
|
|
17
|
+
import { notImplemented } from '../../../../utils/Utils';
|
|
17
18
|
|
|
18
19
|
const GroupButtonByType = memo(({ route }) => {
|
|
19
20
|
const t = useTranslations();
|
|
@@ -38,7 +39,7 @@ const GroupButtonByType = memo(({ route }) => {
|
|
|
38
39
|
case 'reload':
|
|
39
40
|
case 'more':
|
|
40
41
|
case 'done':
|
|
41
|
-
return
|
|
42
|
+
return notImplemented(t);
|
|
42
43
|
default:
|
|
43
44
|
return <></>;
|
|
44
45
|
}
|
|
@@ -16,7 +16,7 @@ import styles from './DetailStyles';
|
|
|
16
16
|
|
|
17
17
|
const SubUnitDetail = ({ route }) => {
|
|
18
18
|
const t = useTranslations();
|
|
19
|
-
const { unit, station
|
|
19
|
+
const { unit, station } = route.params;
|
|
20
20
|
const language = useSCContextSelector((state) => state.language);
|
|
21
21
|
const navigation = useNavigation();
|
|
22
22
|
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
@@ -125,7 +125,6 @@ const SubUnitDetail = ({ route }) => {
|
|
|
125
125
|
sensor={item}
|
|
126
126
|
unit={unit}
|
|
127
127
|
station={station}
|
|
128
|
-
isGGHomeConnected={isGGHomeConnected}
|
|
129
128
|
/>
|
|
130
129
|
);
|
|
131
130
|
})}
|
|
@@ -20,13 +20,14 @@ import Routes from '../../utils/Route';
|
|
|
20
20
|
import { RowItem } from '../../commons/RowItem';
|
|
21
21
|
import NoSubUnitImage from '../../../assets/images/Illustrations.svg';
|
|
22
22
|
import useManageSubUnit from './hooks/useManageSubUnit';
|
|
23
|
+
import { TESTID } from '../../configs/Constants';
|
|
23
24
|
|
|
24
25
|
const ManageSubUnit = memo((props) => {
|
|
25
26
|
const t = useTranslations();
|
|
26
27
|
const { unit } = props.route.params;
|
|
27
28
|
const navigation = useNavigation();
|
|
28
29
|
const isFocused = useIsFocused();
|
|
29
|
-
const {
|
|
30
|
+
const { stations, isRefresh, isLoading, onRefresh } = useManageSubUnit(unit);
|
|
30
31
|
|
|
31
32
|
const addSubUnit = useCallback(() => {
|
|
32
33
|
navigation.navigate(Routes.AddSubUnitStack, {
|
|
@@ -35,7 +36,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
35
36
|
});
|
|
36
37
|
}, [navigation, unit]);
|
|
37
38
|
|
|
38
|
-
const goToEditSubUnit = (station
|
|
39
|
+
const goToEditSubUnit = (station) => {
|
|
39
40
|
navigation.navigate(Routes.UnitStack, {
|
|
40
41
|
screen: Routes.EditSubUnit,
|
|
41
42
|
params: {
|
|
@@ -48,7 +49,11 @@ const ManageSubUnit = memo((props) => {
|
|
|
48
49
|
const rightComponent = useMemo(
|
|
49
50
|
() => (
|
|
50
51
|
<View style={styles.rightComponent}>
|
|
51
|
-
<TouchableOpacity
|
|
52
|
+
<TouchableOpacity
|
|
53
|
+
testID={TESTID.ADD_SUB_UNIT}
|
|
54
|
+
onPress={addSubUnit}
|
|
55
|
+
style={styles.headerButton}
|
|
56
|
+
>
|
|
52
57
|
<Icon name={'plus'} size={27} color={Colors.Black} />
|
|
53
58
|
</TouchableOpacity>
|
|
54
59
|
<TouchableOpacity
|
|
@@ -84,8 +89,8 @@ const ManageSubUnit = memo((props) => {
|
|
|
84
89
|
scrollIndicatorInsets={{ right: 1 }}
|
|
85
90
|
>
|
|
86
91
|
<View>
|
|
87
|
-
{!!
|
|
88
|
-
|
|
92
|
+
{!!stations.length &&
|
|
93
|
+
stations.map((item, index) => {
|
|
89
94
|
return (
|
|
90
95
|
<RowItem
|
|
91
96
|
type={'noneBG'}
|
|
@@ -100,7 +105,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
100
105
|
}
|
|
101
106
|
text={item.name}
|
|
102
107
|
subtext={`${
|
|
103
|
-
item.
|
|
108
|
+
item.devices ? item.devices.length : '0'
|
|
104
109
|
} devices`}
|
|
105
110
|
onPress={() => goToEditSubUnit(item, unit)}
|
|
106
111
|
rightComponent={
|
|
@@ -113,7 +118,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
113
118
|
/>
|
|
114
119
|
);
|
|
115
120
|
})}
|
|
116
|
-
{!
|
|
121
|
+
{!stations.length && !isRefresh && !isLoading && (
|
|
117
122
|
<View style={styles.NoSubUnit}>
|
|
118
123
|
<NoSubUnitImage />
|
|
119
124
|
<Text semibold type="H4" center>
|