@eohjsc/react-native-smart-city 0.2.97 → 0.3.0
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 +35 -14
- package/package.json +4 -2
- package/src/commons/Action/ItemQuickAction.js +5 -2
- package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
- 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/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -3
- package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
- package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
- 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 +135 -0
- package/src/commons/Auth/AccountList.js +1 -1
- 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/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/index.js +1 -1
- 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/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +4 -0
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
- package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
- package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/MenuActionAddnew/index.js +1 -0
- package/src/commons/MenuActionList/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
- package/src/commons/PreventAccess/index.js +9 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/WheelDateTimePicker/index.js +2 -1
- package/src/configs/API.js +87 -138
- package/src/configs/Constants.js +27 -1
- package/src/configs/SCConfig.js +2 -0
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +8 -30
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -0
- 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/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- 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 +4 -1
- package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- 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/index.js +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- 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/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +3 -2
- 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 +2 -0
- 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/__test__/detail.test.js +23 -84
- package/src/screens/Device/detail.js +31 -8
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/Explore/index.js +2 -0
- package/src/screens/GuestInfo/__test__/index.test.js +14 -41
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- 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/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- 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/index.js +2 -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 +4 -3
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +19 -3
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- 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 +5 -4
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +5 -2
- package/src/screens/SetSchedule/index.js +6 -2
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +107 -70
- 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/Sharing/hooks/index.js +3 -0
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
- package/src/screens/SideMenuDetail/index.js +149 -0
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/ManageSubUnit.js +1 -0
- 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/hooks/__test__/useManageSubUnit.test.js +47 -44
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +4 -1
- package/src/screens/Unit/Station/index.js +1 -0
- package/src/screens/Unit/Summaries.js +1 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +15 -28
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +83 -185
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +13 -39
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- 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/UnitSummary/__test__/index.test.js +38 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +37 -13
- package/src/utils/I18n/translations/en.json +1 -0
- package/src/utils/I18n/translations/vi.json +1 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Utils.js +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
4
|
import AddLGDevice from '../AddLGDevice';
|
|
5
5
|
import API from '../../../configs/API';
|
|
6
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
@@ -11,8 +11,9 @@ import { ToastBottomHelper } from '../../../utils/Utils';
|
|
|
11
11
|
import Routes from '../../../utils/Route';
|
|
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 mock = new MockAdapter(api.axiosInstance);
|
|
16
17
|
|
|
17
18
|
const mockedNavigate = jest.fn();
|
|
18
19
|
const mockedGoBack = jest.fn();
|
|
@@ -54,11 +55,6 @@ describe('Test Add LG Device', () => {
|
|
|
54
55
|
};
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
afterEach(() => {
|
|
58
|
-
axios.get.mockClear();
|
|
59
|
-
axios.post.mockClear();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
58
|
const getText = (instance, id) => {
|
|
63
59
|
return instance.find((el) => el.props.testID === id);
|
|
64
60
|
};
|
|
@@ -91,16 +87,11 @@ describe('Test Add LG Device', () => {
|
|
|
91
87
|
stations: [{ id: 2, name: 'Station name' }],
|
|
92
88
|
},
|
|
93
89
|
};
|
|
94
|
-
|
|
95
|
-
return response;
|
|
96
|
-
});
|
|
97
|
-
|
|
90
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
98
91
|
await act(async () => {
|
|
99
92
|
tree = await create(wrapComponent(route));
|
|
100
93
|
});
|
|
101
94
|
const instance = tree.root;
|
|
102
|
-
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
103
|
-
|
|
104
95
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
105
96
|
expect(groupCheckBox.props.data).toEqual([
|
|
106
97
|
{ id: 2, name: 'Station name', title: 'Station name' },
|
|
@@ -108,19 +99,11 @@ describe('Test Add LG Device', () => {
|
|
|
108
99
|
});
|
|
109
100
|
|
|
110
101
|
test('fetchDetails fail', async () => {
|
|
111
|
-
|
|
112
|
-
data: {},
|
|
113
|
-
};
|
|
114
|
-
axios.get.mockImplementation(async () => {
|
|
115
|
-
return response;
|
|
116
|
-
});
|
|
117
|
-
|
|
102
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(400);
|
|
118
103
|
await act(async () => {
|
|
119
104
|
tree = await create(wrapComponent(route));
|
|
120
105
|
});
|
|
121
106
|
const instance = tree.root;
|
|
122
|
-
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
123
|
-
|
|
124
107
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
125
108
|
expect(groupCheckBox.props.data).toEqual([]);
|
|
126
109
|
});
|
|
@@ -161,7 +144,7 @@ describe('Test Add LG Device', () => {
|
|
|
161
144
|
await act(async () => {
|
|
162
145
|
viewButtonBottom.props.onRightClick();
|
|
163
146
|
});
|
|
164
|
-
expect(mockedNavigate).
|
|
147
|
+
expect(mockedNavigate).toHaveBeenCalled();
|
|
165
148
|
});
|
|
166
149
|
|
|
167
150
|
test('ViewButtonBottom onRightClick with stationId', async () => {
|
|
@@ -173,9 +156,7 @@ describe('Test Add LG Device', () => {
|
|
|
173
156
|
stations: [{ id: 2, name: 'Station name' }],
|
|
174
157
|
},
|
|
175
158
|
};
|
|
176
|
-
|
|
177
|
-
return response;
|
|
178
|
-
});
|
|
159
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
179
160
|
|
|
180
161
|
const responseToken = {
|
|
181
162
|
status: 200,
|
|
@@ -183,20 +164,9 @@ describe('Test Add LG Device', () => {
|
|
|
183
164
|
access_token: 'ACCESS_TOKEN',
|
|
184
165
|
},
|
|
185
166
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const responseSync = {
|
|
191
|
-
status: 200,
|
|
192
|
-
data: {},
|
|
193
|
-
};
|
|
194
|
-
axios.post.mockImplementationOnce(async () => {
|
|
195
|
-
return responseSync;
|
|
196
|
-
});
|
|
197
|
-
|
|
167
|
+
mock.onPost(API.IOT.LG.GET_TOKEN()).reply(200, responseToken.data);
|
|
168
|
+
mock.onPost(API.IOT.LG.SYNC_DEVICE()).reply(200, {});
|
|
198
169
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
199
|
-
|
|
200
170
|
await act(async () => {
|
|
201
171
|
tree = await create(wrapComponent(route));
|
|
202
172
|
});
|
|
@@ -210,10 +180,6 @@ describe('Test Add LG Device', () => {
|
|
|
210
180
|
await act(async () => {
|
|
211
181
|
viewButtonBottom.props.onRightClick();
|
|
212
182
|
});
|
|
213
|
-
|
|
214
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
215
|
-
expect(axios.post).toHaveBeenCalledTimes(2);
|
|
216
|
-
expect(spyToastSuccess).toBeCalled();
|
|
217
183
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
218
184
|
|
|
219
185
|
spyToastSuccess.mockReset();
|
|
@@ -229,27 +195,8 @@ describe('Test Add LG Device', () => {
|
|
|
229
195
|
stations: [{ id: 2, name: 'Station name' }],
|
|
230
196
|
},
|
|
231
197
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const responseToken = {
|
|
237
|
-
status: 200,
|
|
238
|
-
data: {
|
|
239
|
-
access_token: 'ACCESS_TOKEN',
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
axios.post.mockImplementationOnce(async () => {
|
|
243
|
-
return responseToken;
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
const responseSync = {
|
|
247
|
-
data: {},
|
|
248
|
-
};
|
|
249
|
-
axios.post.mockImplementationOnce(async () => {
|
|
250
|
-
return responseSync;
|
|
251
|
-
});
|
|
252
|
-
|
|
198
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
199
|
+
mock.onPost(API.IOT.LG.GET_TOKEN()).reply(200, response.data);
|
|
253
200
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
254
201
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
255
202
|
|
|
@@ -266,13 +213,9 @@ describe('Test Add LG Device', () => {
|
|
|
266
213
|
await act(async () => {
|
|
267
214
|
viewButtonBottom.props.onRightClick();
|
|
268
215
|
});
|
|
269
|
-
|
|
270
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
271
|
-
expect(axios.post).toHaveBeenCalledTimes(2);
|
|
272
216
|
expect(spyToastSuccess).not.toBeCalled();
|
|
273
217
|
expect(spyToastError).toBeCalled();
|
|
274
218
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
275
|
-
|
|
276
219
|
spyToastSuccess.mockReset();
|
|
277
220
|
spyToastSuccess.mockRestore();
|
|
278
221
|
});
|
|
@@ -286,10 +229,7 @@ describe('Test Add LG Device', () => {
|
|
|
286
229
|
stations: [{ id: 2, name: 'Station name' }],
|
|
287
230
|
},
|
|
288
231
|
};
|
|
289
|
-
|
|
290
|
-
return response;
|
|
291
|
-
});
|
|
292
|
-
|
|
232
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
293
233
|
const responseToken = {
|
|
294
234
|
status: 200,
|
|
295
235
|
data: {
|
|
@@ -300,10 +240,7 @@ describe('Test Add LG Device', () => {
|
|
|
300
240
|
},
|
|
301
241
|
},
|
|
302
242
|
};
|
|
303
|
-
|
|
304
|
-
return responseToken;
|
|
305
|
-
});
|
|
306
|
-
|
|
243
|
+
mock.onPost(API.IOT.LG.GET_TOKEN()).reply(200, responseToken.data);
|
|
307
244
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
308
245
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
309
246
|
|
|
@@ -321,8 +258,6 @@ describe('Test Add LG Device', () => {
|
|
|
321
258
|
viewButtonBottom.props.onRightClick();
|
|
322
259
|
});
|
|
323
260
|
|
|
324
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
325
|
-
expect(axios.post).toHaveBeenCalledTimes(1); // called once
|
|
326
261
|
expect(spyToastSuccess).not.toBeCalled();
|
|
327
262
|
expect(spyToastError).toBeCalled();
|
|
328
263
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
@@ -340,16 +275,7 @@ describe('Test Add LG Device', () => {
|
|
|
340
275
|
stations: [{ id: 2, name: 'Station name' }],
|
|
341
276
|
},
|
|
342
277
|
};
|
|
343
|
-
|
|
344
|
-
return response;
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
const responseToken = {
|
|
348
|
-
data: {},
|
|
349
|
-
};
|
|
350
|
-
axios.post.mockImplementationOnce(async () => {
|
|
351
|
-
return responseToken;
|
|
352
|
-
});
|
|
278
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
353
279
|
|
|
354
280
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
355
281
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
@@ -368,8 +294,6 @@ describe('Test Add LG Device', () => {
|
|
|
368
294
|
viewButtonBottom.props.onRightClick();
|
|
369
295
|
});
|
|
370
296
|
|
|
371
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
372
|
-
expect(axios.post).toHaveBeenCalledTimes(1); // called once
|
|
373
297
|
expect(spyToastSuccess).not.toBeCalled();
|
|
374
298
|
expect(spyToastError).toBeCalled();
|
|
375
299
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
@@ -13,7 +13,10 @@ const TDSGuide = memo(() => {
|
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
15
|
<View style={styles.container}>
|
|
16
|
-
<ScrollView
|
|
16
|
+
<ScrollView
|
|
17
|
+
style={styles.paddingHorizontal16}
|
|
18
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
19
|
+
>
|
|
17
20
|
<Text
|
|
18
21
|
type="H3"
|
|
19
22
|
semibold
|
|
@@ -73,7 +73,7 @@ const UVIndexGuide = memo(() => {
|
|
|
73
73
|
const onPress = useCallback((item) => {}, []);
|
|
74
74
|
return (
|
|
75
75
|
<SafeAreaView style={styles.container}>
|
|
76
|
-
<ScrollView style={styles.container}>
|
|
76
|
+
<ScrollView style={styles.container} scrollIndicatorInsets={{ right: 1 }}>
|
|
77
77
|
{titles.map((item, index) => {
|
|
78
78
|
const { title, des } = item;
|
|
79
79
|
return (
|
|
@@ -25,7 +25,7 @@ const DEFAULT_LONGITUDE = 106.7035663;
|
|
|
25
25
|
|
|
26
26
|
const ChooseLocation = memo(({ route }) => {
|
|
27
27
|
const t = useTranslations();
|
|
28
|
-
const { location, setAddress, setLocation } = route.params;
|
|
28
|
+
const { location, setAddress, setLocation } = route.params || {};
|
|
29
29
|
const { goBack } = useNavigation();
|
|
30
30
|
const [currentLocation, setCurrentLocation] = useState(location);
|
|
31
31
|
const [loading, setLoading] = useState(false);
|
|
@@ -163,7 +163,10 @@ const SelectAddress = memo(({ route }) => {
|
|
|
163
163
|
<View style={styles.wrap}>
|
|
164
164
|
<View style={styles.searchLocation}>
|
|
165
165
|
<SearchBarLocation input={input} onTextInput={onTextInput} />
|
|
166
|
-
<ScrollView
|
|
166
|
+
<ScrollView
|
|
167
|
+
style={styles.searchData}
|
|
168
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
169
|
+
>
|
|
167
170
|
{searchData.map((item, index) => (
|
|
168
171
|
<RowLocation key={index} item={item} onPress={onPressRowLocation} />
|
|
169
172
|
))}
|
|
@@ -85,7 +85,7 @@ const Summaries = memo(({ unit }) => {
|
|
|
85
85
|
return (
|
|
86
86
|
<>
|
|
87
87
|
{!unitSummaries || !unitSummaries.length ? null : (
|
|
88
|
-
<ScrollView horizontal={true}>
|
|
88
|
+
<ScrollView horizontal={true} scrollIndicatorInsets={{ right: 1 }}>
|
|
89
89
|
{unitSummaries.map((item, index) => (
|
|
90
90
|
<SummaryItem key={index} item={item} goToSummary={goToSummary} />
|
|
91
91
|
))}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { API } from '../../../configs';
|
|
3
1
|
import React from 'react';
|
|
4
|
-
import
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
|
|
5
|
+
import { API } from '../../../configs';
|
|
5
6
|
import UnitDetail from '../Detail';
|
|
6
|
-
import { useIsFocused } from '@react-navigation/native';
|
|
7
|
-
import AsyncStorage from '@react-native-community/async-storage';
|
|
8
7
|
import { SCProvider } from '../../../context';
|
|
9
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
import api from '../../../utils/Apis/axios';
|
|
10
|
+
import NavBar from '../../../commons/NavBar';
|
|
11
|
+
|
|
12
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
10
13
|
|
|
11
14
|
const mockDispatch = jest.fn();
|
|
12
15
|
|
|
@@ -24,8 +27,6 @@ jest.mock('../../../iot/RemoteControl/GoogleHome', () => ({
|
|
|
24
27
|
googleHomeConnect: jest.fn(() => false),
|
|
25
28
|
}));
|
|
26
29
|
|
|
27
|
-
jest.mock('axios');
|
|
28
|
-
|
|
29
30
|
jest.mock('@react-native-community/netinfo', () => {
|
|
30
31
|
return {
|
|
31
32
|
useNetInfo: () => {
|
|
@@ -46,6 +47,7 @@ const wrapComponent = (route, unitData, account) => (
|
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
describe('Test UnitDetail google home disconnect', () => {
|
|
50
|
+
let tree;
|
|
49
51
|
const route = {
|
|
50
52
|
params: {
|
|
51
53
|
unitId: 1,
|
|
@@ -53,15 +55,6 @@ describe('Test UnitDetail google home disconnect', () => {
|
|
|
53
55
|
};
|
|
54
56
|
const account = {};
|
|
55
57
|
|
|
56
|
-
axios.get.mockImplementation(() => ({ status: 200 }));
|
|
57
|
-
|
|
58
|
-
beforeEach(() => {
|
|
59
|
-
jest.clearAllTimers();
|
|
60
|
-
axios.get.mockClear();
|
|
61
|
-
useIsFocused.mockImplementation(() => true);
|
|
62
|
-
AsyncStorage.clear();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
58
|
test('when unit has google home disconnect call api check send email', async () => {
|
|
66
59
|
const unitData = {
|
|
67
60
|
remote_control_options: {
|
|
@@ -76,18 +69,12 @@ describe('Test UnitDetail google home disconnect', () => {
|
|
|
76
69
|
],
|
|
77
70
|
},
|
|
78
71
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
await renderer.create(wrapComponent(route, unitData, account));
|
|
72
|
+
mock.onGet(API.GOOGLE_HOME.CHECK_SEND_EMAIL()).reply(200);
|
|
73
|
+
await act(() => {
|
|
74
|
+
tree = create(wrapComponent(route, unitData, account));
|
|
83
75
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
chip_id: 1,
|
|
89
|
-
is_connected: false,
|
|
90
|
-
}
|
|
91
|
-
);
|
|
76
|
+
const instance = tree.root;
|
|
77
|
+
const NavBars = instance.findAllByType(NavBar);
|
|
78
|
+
expect(NavBars).toHaveLength(0);
|
|
92
79
|
});
|
|
93
80
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
import MapView from 'react-native-maps';
|
|
5
|
+
|
|
3
6
|
import { SCProvider } from '../../../context';
|
|
4
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
5
8
|
import ChooseLocation from '../ChooseLocation';
|
|
6
|
-
import
|
|
7
|
-
import { API, SCConfig } from '../../../configs';
|
|
9
|
+
import { API } from '../../../configs';
|
|
8
10
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
11
|
+
import api from '../../../utils/Apis/axios';
|
|
9
12
|
|
|
10
13
|
const wrapComponent = (route) => (
|
|
11
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -43,7 +46,7 @@ jest.mock('react-native-maps', () => {
|
|
|
43
46
|
};
|
|
44
47
|
});
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
47
50
|
|
|
48
51
|
describe('Test ChooseLocation', () => {
|
|
49
52
|
let tree;
|
|
@@ -52,7 +55,6 @@ describe('Test ChooseLocation', () => {
|
|
|
52
55
|
const mockSetLocation = jest.fn();
|
|
53
56
|
|
|
54
57
|
beforeAll(() => {
|
|
55
|
-
axios.get.mockClear();
|
|
56
58
|
route = {
|
|
57
59
|
params: {
|
|
58
60
|
location: {
|
|
@@ -65,6 +67,24 @@ describe('Test ChooseLocation', () => {
|
|
|
65
67
|
};
|
|
66
68
|
});
|
|
67
69
|
|
|
70
|
+
test('test render without location', async () => {
|
|
71
|
+
await act(async () => {
|
|
72
|
+
tree = await create(wrapComponent({}));
|
|
73
|
+
});
|
|
74
|
+
const instance = tree.root;
|
|
75
|
+
const buttonBottom = instance.findByType(BottomButtonView);
|
|
76
|
+
expect(buttonBottom).toBeDefined();
|
|
77
|
+
await act(async () => {
|
|
78
|
+
await buttonBottom.props.onPressMain();
|
|
79
|
+
});
|
|
80
|
+
const MapViews = instance.findByType(MapView);
|
|
81
|
+
await MapViews.props.onRegionChangeComplete({
|
|
82
|
+
latitude: 1,
|
|
83
|
+
longitude: 1,
|
|
84
|
+
});
|
|
85
|
+
expect(mockSetLocation).not.toBeCalled();
|
|
86
|
+
});
|
|
87
|
+
|
|
68
88
|
test('test done choose location', async () => {
|
|
69
89
|
await act(async () => {
|
|
70
90
|
tree = await create(wrapComponent(route));
|
|
@@ -88,19 +108,12 @@ describe('Test ChooseLocation', () => {
|
|
|
88
108
|
],
|
|
89
109
|
},
|
|
90
110
|
};
|
|
91
|
-
|
|
111
|
+
mock
|
|
112
|
+
.onGet(API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG)
|
|
113
|
+
.reply(200, response.data);
|
|
92
114
|
await act(async () => {
|
|
93
115
|
await buttonBottom.props.onPressMain();
|
|
94
116
|
});
|
|
95
|
-
expect(axios.get).toBeCalledWith(
|
|
96
|
-
API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG,
|
|
97
|
-
{
|
|
98
|
-
params: {
|
|
99
|
-
latlng: '10,10',
|
|
100
|
-
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
101
|
-
},
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
117
|
expect(mockSetAddress).toBeCalledWith('address');
|
|
105
118
|
expect(mockSetLocation).toBeCalledWith({
|
|
106
119
|
description: 'address',
|