@eohjsc/react-native-smart-city 0.2.99 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +6 -4
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +11 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -20
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +0 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +137 -2
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +72 -25
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +3 -3
- package/src/commons/Device/ItemDevice.js +15 -11
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +19 -14
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/index.js +2 -2
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +24 -55
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -1
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +2 -2
- package/src/configs/API.js +85 -144
- package/src/configs/Constants.js +24 -0
- package/src/configs/SCConfig.js +2 -0
- package/src/context/actionType.ts +8 -0
- package/src/context/mockStore.ts +10 -0
- package/src/context/reducer.ts +38 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/index.js +5 -4
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -33
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +21 -21
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -23
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +3 -3
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +32 -85
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +53 -22
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +1 -1
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +18 -14
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +30 -31
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +13 -40
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +5 -5
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +22 -6
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +16 -11
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SelectUnit/index.js +4 -2
- package/src/screens/SetSchedule/index.js +9 -9
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/SelectPermission.js +121 -76
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/SideMenuDetail/__test__/index.test.js +12 -23
- package/src/screens/SideMenuDetail/index.js +2 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/ManageSubUnit.js +12 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +30 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +34 -21
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Summaries.js +17 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +99 -200
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +84 -51
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +70 -41
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/utils/Apis/axios.js +46 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +4 -1
- package/src/utils/I18n/translations/vi.json +5 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Utils.js +11 -7
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
2
3
|
import useActivityLog from '../';
|
|
3
|
-
import axios from 'axios';
|
|
4
4
|
import { API } from '../../../../configs';
|
|
5
|
-
import moment from 'moment';
|
|
6
5
|
import { AUTOMATE_TYPE } from '../../../../configs/Constants';
|
|
6
|
+
import api from '../../../../utils/Apis/axios';
|
|
7
|
+
import { getDataForList, getEmergencyEventDataForList } from '../../utils';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
9
10
|
|
|
10
11
|
describe('Test useActivityLog', () => {
|
|
11
12
|
let props;
|
|
@@ -61,7 +62,6 @@ describe('Test useActivityLog', () => {
|
|
|
61
62
|
|
|
62
63
|
beforeEach(() => {
|
|
63
64
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
64
|
-
axios.get.mockClear();
|
|
65
65
|
props = {
|
|
66
66
|
id: 1,
|
|
67
67
|
type: 'action',
|
|
@@ -81,103 +81,75 @@ describe('Test useActivityLog', () => {
|
|
|
81
81
|
|
|
82
82
|
it('Test onRefresh activity log of sensor', async () => {
|
|
83
83
|
const { result } = renderHook(() => useActivityLog(props));
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
count: 21,
|
|
89
|
-
},
|
|
90
|
-
}));
|
|
84
|
+
mock.onGet(API.DEVICE.ACTIVITY_LOG(1)).reply(200, {
|
|
85
|
+
results: actionLogData,
|
|
86
|
+
count: 21,
|
|
87
|
+
});
|
|
91
88
|
await act(async () => {
|
|
92
89
|
await result.current.onRefresh();
|
|
93
90
|
});
|
|
94
|
-
|
|
95
|
-
params.append('id', 1);
|
|
96
|
-
params.append('page', 1);
|
|
97
|
-
expect(axios.get).toHaveBeenCalled();
|
|
91
|
+
expect(result.current.data).toEqual(getDataForList(actionLogData));
|
|
98
92
|
});
|
|
99
93
|
|
|
100
94
|
it('Test onRefresh activity log of automate', async () => {
|
|
101
95
|
props.type = 'automate';
|
|
102
96
|
const { result } = renderHook(() => useActivityLog(props));
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
count: 2,
|
|
108
|
-
},
|
|
109
|
-
}));
|
|
97
|
+
mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
|
|
98
|
+
results: automateLogData,
|
|
99
|
+
count: 2,
|
|
100
|
+
});
|
|
110
101
|
await act(async () => {
|
|
111
102
|
await result.current.onRefresh();
|
|
112
103
|
});
|
|
113
|
-
|
|
114
|
-
params.append('page', 1);
|
|
115
|
-
expect(axios.get).toHaveBeenCalled();
|
|
104
|
+
expect(result.current.data).toEqual(getDataForList(automateLogData));
|
|
116
105
|
});
|
|
117
106
|
|
|
118
107
|
it('Test onRefresh activity log of automate one tap', async () => {
|
|
119
108
|
props.type = `automate.${AUTOMATE_TYPE.ONE_TAP}`;
|
|
120
109
|
props.filterEnabled.date = true;
|
|
121
110
|
const { result } = renderHook(() => useActivityLog(props));
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
count: 2,
|
|
127
|
-
},
|
|
128
|
-
}));
|
|
111
|
+
mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
|
|
112
|
+
results: automateLogData,
|
|
113
|
+
count: 2,
|
|
114
|
+
});
|
|
129
115
|
await act(async () => {
|
|
130
116
|
await result.current.onRefresh();
|
|
131
117
|
});
|
|
132
|
-
|
|
133
|
-
params.append('page', 1);
|
|
134
|
-
params.append('date_from', moment().add(-7, 'days').format('YYYY-MM-DD'));
|
|
135
|
-
params.append('date_to', moment().format('YYYY-MM-DD'));
|
|
136
|
-
expect(axios.get).toHaveBeenCalled();
|
|
118
|
+
expect(result.current.data).toEqual(getDataForList(automateLogData));
|
|
137
119
|
});
|
|
138
120
|
|
|
139
121
|
it('Test onRefresh activity log of emergency button', async () => {
|
|
140
122
|
props.type = 'emergency_event';
|
|
141
123
|
const { result } = renderHook(() => useActivityLog(props));
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
count: 2,
|
|
147
|
-
},
|
|
148
|
-
}));
|
|
124
|
+
mock.onGet(API.EMERGENCY_BUTTON.ACTIVITY_LOG()).reply(200, {
|
|
125
|
+
results: emergencyEventLogData,
|
|
126
|
+
count: 2,
|
|
127
|
+
});
|
|
149
128
|
await act(async () => {
|
|
150
129
|
await result.current.onRefresh();
|
|
151
130
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
expect(axios.get).toHaveBeenCalled();
|
|
131
|
+
expect(result.current.data).toEqual(
|
|
132
|
+
getEmergencyEventDataForList(emergencyEventLogData)
|
|
133
|
+
);
|
|
156
134
|
});
|
|
157
135
|
|
|
158
136
|
it('Test onLoadMore', async () => {
|
|
159
137
|
const { result } = renderHook(() => useActivityLog(props));
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
count: 1,
|
|
165
|
-
},
|
|
166
|
-
}));
|
|
138
|
+
mock.onGet(API.DEVICE.ACTIVITY_LOG(1)).reply(200, {
|
|
139
|
+
results: actionLogData,
|
|
140
|
+
count: 21,
|
|
141
|
+
});
|
|
167
142
|
await act(async () => {
|
|
168
143
|
await result.current.onLoadMore();
|
|
169
144
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
axios.get.mockClear();
|
|
176
|
-
|
|
145
|
+
mock.onGet(API.DEVICE.ACTIVITY_LOG(2)).reply(200, {
|
|
146
|
+
results: actionLogData,
|
|
147
|
+
count: 21,
|
|
148
|
+
});
|
|
177
149
|
await act(async () => {
|
|
178
150
|
await result.current.onLoadMore();
|
|
179
151
|
});
|
|
180
|
-
expect(
|
|
152
|
+
expect(result.current.isLoading).toBeFalsy();
|
|
181
153
|
});
|
|
182
154
|
|
|
183
155
|
it('Test fetchMembers', async () => {
|
|
@@ -185,25 +157,20 @@ describe('Test useActivityLog', () => {
|
|
|
185
157
|
props.share = { id: 2 };
|
|
186
158
|
props.filterEnabled.user = true;
|
|
187
159
|
const { result } = renderHook(() => useActivityLog(props));
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
}));
|
|
160
|
+
mock.onGet(API.SHARE.UNITS_MEMBERS(2)).reply(200, [
|
|
161
|
+
{
|
|
162
|
+
id: 1,
|
|
163
|
+
name: 'user 1',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 2,
|
|
167
|
+
name: 'user 2',
|
|
168
|
+
},
|
|
169
|
+
]);
|
|
201
170
|
await act(async () => {
|
|
202
171
|
await result.current.fetchMembers();
|
|
203
172
|
});
|
|
204
|
-
|
|
205
|
-
params.append('page', 1);
|
|
206
|
-
expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(2), {});
|
|
173
|
+
expect(result.current.data).toEqual([]);
|
|
207
174
|
});
|
|
208
175
|
|
|
209
176
|
it('Test filter by users', async () => {
|
|
@@ -218,13 +185,10 @@ describe('Test useActivityLog', () => {
|
|
|
218
185
|
users: userIds,
|
|
219
186
|
});
|
|
220
187
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
count: 2,
|
|
226
|
-
},
|
|
227
|
-
}));
|
|
188
|
+
mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
|
|
189
|
+
results: automateLogData,
|
|
190
|
+
count: 2,
|
|
191
|
+
});
|
|
228
192
|
await act(async () => {
|
|
229
193
|
await result.current.onRefresh();
|
|
230
194
|
});
|
|
@@ -232,9 +196,6 @@ describe('Test useActivityLog', () => {
|
|
|
232
196
|
userIds.map((id) => {
|
|
233
197
|
params.append('users', id);
|
|
234
198
|
});
|
|
235
|
-
|
|
236
|
-
params.append('date_to', moment().format('YYYY-MM-DD'));
|
|
237
|
-
params.append('page', 1);
|
|
238
|
-
expect(axios.get).toHaveBeenCalled();
|
|
199
|
+
expect(result.current.data).toEqual(getDataForList(automateLogData));
|
|
239
200
|
});
|
|
240
201
|
});
|
|
@@ -9,7 +9,7 @@ import { getDataForList, getEmergencyEventDataForList } from '../utils';
|
|
|
9
9
|
|
|
10
10
|
const apiMaps = {
|
|
11
11
|
['action']: {
|
|
12
|
-
url: () => API.
|
|
12
|
+
url: () => API.DEVICE.ACTIVITY_LOG(),
|
|
13
13
|
params: (id) => ({ id: id }),
|
|
14
14
|
standardizeData: getDataForList,
|
|
15
15
|
memberUrl: (id) => API.SHARE.UNITS_MEMBERS(id),
|
|
@@ -23,7 +23,7 @@ const keyExtractor = (item) => item.id;
|
|
|
23
23
|
|
|
24
24
|
const ActivityLogScreen = ({ route }) => {
|
|
25
25
|
const t = useTranslations();
|
|
26
|
-
const { id, type, share, filterEnabled } = route.params;
|
|
26
|
+
const { id, type, share, filterEnabled } = route.params || {};
|
|
27
27
|
const {
|
|
28
28
|
data,
|
|
29
29
|
isLoading,
|
|
@@ -118,7 +118,7 @@ const ActivityLogScreen = ({ route }) => {
|
|
|
118
118
|
onMomentumScrollBegin={onMomentumScrollBegin}
|
|
119
119
|
/>
|
|
120
120
|
</View>
|
|
121
|
-
{(filterEnabled
|
|
121
|
+
{(filterEnabled?.user || filterEnabled?.date) && (
|
|
122
122
|
<FilterPopup
|
|
123
123
|
isVisible={showFilterPopup}
|
|
124
124
|
onHide={setHideFilterPopup}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
import { TouchableOpacity } from 'react-native';
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
+
|
|
4
6
|
import AddCommonSelectSubUnit from '../SelectSubUnit';
|
|
5
7
|
import { ViewButtonBottom } from '../../../commons';
|
|
6
8
|
import { SCProvider } from '../../../context';
|
|
7
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
10
|
import Text from '../../../commons/Text';
|
|
9
|
-
import axios from 'axios';
|
|
10
11
|
import { TESTID } from '../../../configs/Constants';
|
|
12
|
+
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { API } from '../../../configs';
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
13
16
|
|
|
14
17
|
const mockedGoBack = jest.fn();
|
|
15
18
|
const mockedNavigate = jest.fn();
|
|
@@ -95,18 +98,10 @@ describe('Test SelectSubUnit container', () => {
|
|
|
95
98
|
});
|
|
96
99
|
test(`press next to navigate ${type}`, async () => {
|
|
97
100
|
const route = { params: { addType: type } };
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
{ id: 1, name: 'Unit 1' },
|
|
103
|
-
{ id: 2, name: 'Unit 2' },
|
|
104
|
-
],
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
axios.get.mockImplementation(async () => {
|
|
108
|
-
return response;
|
|
109
|
-
});
|
|
101
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, [
|
|
102
|
+
{ id: 1, name: 'Unit 1' },
|
|
103
|
+
{ id: 2, name: 'Unit 2' },
|
|
104
|
+
]);
|
|
110
105
|
|
|
111
106
|
await act(async () => {
|
|
112
107
|
tree = renderer.create(wrapComponent(route));
|
|
@@ -159,19 +154,13 @@ describe('Test SelectSubUnit container', () => {
|
|
|
159
154
|
break;
|
|
160
155
|
case 'AddDeviceNewFlow':
|
|
161
156
|
expect(mockedNavigate).toBeCalledWith('ConnectingProcess', {
|
|
157
|
+
devicePrefixName: undefined,
|
|
162
158
|
gateway: undefined,
|
|
163
159
|
scan_sensor_data: undefined,
|
|
164
160
|
station: undefined,
|
|
165
|
-
unit: [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
name: 'Unit 1',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: 2,
|
|
172
|
-
name: 'Unit 2',
|
|
173
|
-
},
|
|
174
|
-
],
|
|
161
|
+
unit: [],
|
|
162
|
+
wifi_pass: undefined,
|
|
163
|
+
wifi_ssid: undefined,
|
|
175
164
|
});
|
|
176
165
|
break;
|
|
177
166
|
default:
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
import { TouchableOpacity, Platform } from 'react-native';
|
|
4
|
-
import
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
5
5
|
|
|
6
6
|
import AddCommonSelectUnit from '../SelectUnit';
|
|
7
7
|
import Text from '../../../commons/Text';
|
|
8
8
|
import { TESTID } from '../../../configs/Constants';
|
|
9
9
|
import { SCProvider } from '../../../context';
|
|
10
10
|
import { mockSCStore } from '../../../context/mockStore';
|
|
11
|
+
import api from '../../../utils/Apis/axios';
|
|
12
|
+
import { API } from '../../../configs';
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
13
15
|
|
|
14
16
|
const mockedGoBack = jest.fn();
|
|
15
17
|
const mockedNavigate = jest.fn();
|
|
@@ -86,11 +88,7 @@ describe('Test SelectUnit container', () => {
|
|
|
86
88
|
{ id: 2, name: 'Unit 2' },
|
|
87
89
|
],
|
|
88
90
|
};
|
|
89
|
-
|
|
90
|
-
axios.get.mockImplementation(async () => {
|
|
91
|
-
return response;
|
|
92
|
-
});
|
|
93
|
-
|
|
91
|
+
mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
|
|
94
92
|
await act(async () => {
|
|
95
93
|
tree = renderer.create(wrapComponent(route));
|
|
96
94
|
});
|
|
@@ -151,10 +149,6 @@ describe('Test SelectUnit container', () => {
|
|
|
151
149
|
describe('test single SelectUnit', () => {
|
|
152
150
|
let tree;
|
|
153
151
|
|
|
154
|
-
beforeEach(() => {
|
|
155
|
-
axios.get.mockClear();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
152
|
test('fetch Unit success', async () => {
|
|
159
153
|
Platform.OS = 'android';
|
|
160
154
|
const route = { params: { addType: 'AddSubUnit' } };
|
|
@@ -166,15 +160,10 @@ describe('test single SelectUnit', () => {
|
|
|
166
160
|
{ id: 2, name: 'Unit 2' },
|
|
167
161
|
],
|
|
168
162
|
};
|
|
169
|
-
|
|
170
|
-
axios.get.mockImplementation(async () => {
|
|
171
|
-
return response;
|
|
172
|
-
});
|
|
173
|
-
|
|
163
|
+
mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
|
|
174
164
|
await act(async () => {
|
|
175
165
|
tree = renderer.create(wrapComponent(route));
|
|
176
166
|
});
|
|
177
|
-
|
|
178
167
|
const instance = tree.root;
|
|
179
168
|
const unitName = instance.findAll(
|
|
180
169
|
(item) =>
|
|
@@ -183,35 +172,23 @@ describe('test single SelectUnit', () => {
|
|
|
183
172
|
const radioButton = instance.findAll(
|
|
184
173
|
(item) => item.props.testID === TESTID.SELECT_UNIT_RADIO_BUTTON
|
|
185
174
|
);
|
|
186
|
-
|
|
187
175
|
expect(unitName[0].props.children).toBe('Unit 1');
|
|
188
176
|
expect(unitName[1].props.children).toBe('Unit 2');
|
|
189
177
|
expect(radioButton[0].props.active).toBeFalsy();
|
|
190
178
|
expect(radioButton[1].props.active).toBeFalsy();
|
|
191
|
-
|
|
192
179
|
const selectUnit = instance.findAll(
|
|
193
180
|
(item) => item.props.testID === TESTID.SELECT_UNIT_SELECT
|
|
194
181
|
);
|
|
195
|
-
|
|
196
182
|
await act(async () => {
|
|
197
183
|
selectUnit[0].props.onPress();
|
|
198
184
|
});
|
|
199
|
-
|
|
200
185
|
expect(radioButton[0].props.active).toBeTruthy();
|
|
201
186
|
});
|
|
202
187
|
|
|
203
188
|
test('fetch Unit not success', async () => {
|
|
204
189
|
Platform.OS = 'ios';
|
|
205
190
|
const route = { params: { addType: 'AddSubUnit' } };
|
|
206
|
-
|
|
207
|
-
status: 500,
|
|
208
|
-
success: false,
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
axios.get.mockImplementation(async () => {
|
|
212
|
-
return response;
|
|
213
|
-
});
|
|
214
|
-
|
|
191
|
+
mock.onGet(500);
|
|
215
192
|
await act(async () => {
|
|
216
193
|
tree = renderer.create(wrapComponent(route));
|
|
217
194
|
});
|
|
@@ -224,9 +201,8 @@ describe('test single SelectUnit', () => {
|
|
|
224
201
|
const radioButton = instance.findAll(
|
|
225
202
|
(item) => item.props.testID === TESTID.SELECT_UNIT_RADIO_BUTTON
|
|
226
203
|
);
|
|
227
|
-
|
|
228
|
-
expect(
|
|
229
|
-
expect(radioButton).toHaveLength(0);
|
|
204
|
+
expect(unitName).toHaveLength(2);
|
|
205
|
+
expect(radioButton).toHaveLength(2);
|
|
230
206
|
});
|
|
231
207
|
|
|
232
208
|
test('click goBack', async () => {
|
|
@@ -45,9 +45,9 @@ const AddLocationMaps = memo(() => {
|
|
|
45
45
|
goBack();
|
|
46
46
|
}, [goBack]);
|
|
47
47
|
|
|
48
|
-
const onTextInput = useCallback(async (
|
|
49
|
-
setInput(
|
|
50
|
-
if (!
|
|
48
|
+
const onTextInput = useCallback(async (newValue) => {
|
|
49
|
+
setInput(newValue);
|
|
50
|
+
if (!newValue) {
|
|
51
51
|
setSearchData([]);
|
|
52
52
|
setSearchedLocation(null);
|
|
53
53
|
return;
|
|
@@ -55,7 +55,7 @@ const AddLocationMaps = memo(() => {
|
|
|
55
55
|
try {
|
|
56
56
|
const config = {
|
|
57
57
|
params: {
|
|
58
|
-
input:
|
|
58
|
+
input: newValue,
|
|
59
59
|
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
60
60
|
sessiontoken: 123456324,
|
|
61
61
|
strictBounds: false,
|
|
@@ -70,6 +70,7 @@ const AddLocationMaps = memo(() => {
|
|
|
70
70
|
if (success) {
|
|
71
71
|
setSearchData(data.predictions);
|
|
72
72
|
}
|
|
73
|
+
// eslint-disable-next-line no-empty
|
|
73
74
|
} catch (error) {}
|
|
74
75
|
}, []);
|
|
75
76
|
|
|
@@ -21,7 +21,7 @@ import { TitleCheckBox } from '../Sharing/Components';
|
|
|
21
21
|
import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
|
|
22
22
|
import { popAction } from '../../navigations/utils';
|
|
23
23
|
import { LoadingSelectAction } from './Components';
|
|
24
|
-
import { ToastBottomHelper } from '../../utils/Utils';
|
|
24
|
+
import { notImplemented, ToastBottomHelper } from '../../utils/Utils';
|
|
25
25
|
|
|
26
26
|
const SelectAction = memo(({ route }) => {
|
|
27
27
|
const t = useTranslations();
|
|
@@ -48,10 +48,10 @@ const SelectAction = memo(({ route }) => {
|
|
|
48
48
|
const fetchData = useCallback(async () => {
|
|
49
49
|
isSelectSensor && setIsLoading(true);
|
|
50
50
|
setIsfetched(true);
|
|
51
|
-
const { success, data } = await axiosGet(
|
|
51
|
+
const { success, data: automateData } = await axiosGet(
|
|
52
52
|
isSelectSensor
|
|
53
53
|
? API.AUTOMATE.GET_SENSOR_CONFIG(device.id)
|
|
54
|
-
: API.
|
|
54
|
+
: API.DEVICE.DISPLAY_ACTIONS(device.id),
|
|
55
55
|
isSelectSensor && {},
|
|
56
56
|
isSelectSensor && true
|
|
57
57
|
);
|
|
@@ -78,21 +78,21 @@ const SelectAction = memo(({ route }) => {
|
|
|
78
78
|
const condition = conditionType.find((item) => {
|
|
79
79
|
return item.conditionValue === automate.condition;
|
|
80
80
|
});
|
|
81
|
-
const updateSensorData =
|
|
81
|
+
const updateSensorData = automateData.map((obj) =>
|
|
82
82
|
obj.id === automate.config_id
|
|
83
83
|
? { ...obj, value: automate.value, ...condition }
|
|
84
84
|
: obj
|
|
85
85
|
);
|
|
86
|
-
let selectSensor =
|
|
86
|
+
let selectSensor = automateData.find((config) => {
|
|
87
87
|
return config.id === automate.config_id;
|
|
88
88
|
});
|
|
89
89
|
setSensorData(updateSensorData);
|
|
90
90
|
setCheckedItem(selectSensor);
|
|
91
91
|
} else {
|
|
92
|
-
setSensorData(
|
|
92
|
+
setSensorData(automateData);
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
|
-
setData(
|
|
95
|
+
setData(automateData);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
setIsfetched(false);
|
|
@@ -265,7 +265,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
265
265
|
dispatch(popAction(3));
|
|
266
266
|
isAutomateTab && goBack();
|
|
267
267
|
} else {
|
|
268
|
-
|
|
268
|
+
notImplemented(t);
|
|
269
269
|
}
|
|
270
270
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
271
271
|
}, [route.params]);
|
|
@@ -45,13 +45,13 @@ const SetUpSensor = () => {
|
|
|
45
45
|
const [isShowModal, setIsShowModal] = useState(false);
|
|
46
46
|
const [itemActiveModal, setItemActiveModal] = useState(modalData[0]);
|
|
47
47
|
const [value, setValue] = useState(parseFloat(item?.value || 0));
|
|
48
|
-
const [minimum] = useState(isHasLimit ? parseInt(item?.range_min) : 0);
|
|
48
|
+
const [minimum] = useState(isHasLimit ? parseInt(item?.range_min, 10) : 0);
|
|
49
49
|
const [maximum, setMaximum] = useState(
|
|
50
50
|
value === 0
|
|
51
51
|
? 100
|
|
52
52
|
: isHasLimit
|
|
53
|
-
? (parseInt(item?.range_max) - minimum) * 10 + minimum
|
|
54
|
-
: (parseInt(item?.value) + 20 - minimum) * 10 + minimum
|
|
53
|
+
? (parseInt(item?.range_max, 10) - minimum) * 10 + minimum
|
|
54
|
+
: (parseInt(item?.value, 10) + 20 - minimum) * 10 + minimum
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
const onOpenModal = useCallback(() => {
|
|
@@ -62,8 +62,8 @@ const SetUpSensor = () => {
|
|
|
62
62
|
setIsShowModal(false);
|
|
63
63
|
}, []);
|
|
64
64
|
|
|
65
|
-
const onChooseCondition = (
|
|
66
|
-
setItemActiveModal(
|
|
65
|
+
const onChooseCondition = (selectedItem) => () => {
|
|
66
|
+
setItemActiveModal(selectedItem);
|
|
67
67
|
onCloseModal();
|
|
68
68
|
};
|
|
69
69
|
|
|
@@ -74,9 +74,9 @@ const SetUpSensor = () => {
|
|
|
74
74
|
}, []);
|
|
75
75
|
|
|
76
76
|
const onChangeValue = useCallback(
|
|
77
|
-
(
|
|
77
|
+
(newValue) => {
|
|
78
78
|
setValue(
|
|
79
|
-
(parseFloat(
|
|
79
|
+
(parseFloat(newValue / 128) + parseFloat(minimum)).toFixed(
|
|
80
80
|
item?.decimal_behind || 1
|
|
81
81
|
)
|
|
82
82
|
);
|