@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,10 +1,11 @@
|
|
|
1
1
|
import { act } from '@testing-library/react-hooks';
|
|
2
|
-
import
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
3
|
import { API } from '../../../configs';
|
|
4
|
+
import api from '../../../utils/Apis/axios';
|
|
4
5
|
import { getConfigGlobalState, setConfigGlobalState } from '../../states';
|
|
5
6
|
import { lgThinqConnect, sendCommandOverLGThinq } from '../LG';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
8
9
|
|
|
9
10
|
describe('Remote Control LG Thinq', () => {
|
|
10
11
|
let options;
|
|
@@ -13,8 +14,6 @@ describe('Remote Control LG Thinq', () => {
|
|
|
13
14
|
|
|
14
15
|
beforeEach(() => {
|
|
15
16
|
setConfigGlobalState('configValues', {});
|
|
16
|
-
axios.get.mockClear();
|
|
17
|
-
axios.post.mockClear();
|
|
18
17
|
|
|
19
18
|
options = [
|
|
20
19
|
{
|
|
@@ -53,116 +52,52 @@ describe('Remote Control LG Thinq', () => {
|
|
|
53
52
|
});
|
|
54
53
|
|
|
55
54
|
it('Connect to LGThinq basic will fetch device status', async () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
airFlow: {
|
|
60
|
-
windStrength: 'LOW',
|
|
61
|
-
},
|
|
55
|
+
mock.onGet(API.IOT.LG.DEVICE_STATUS()).reply(200, {
|
|
56
|
+
airFlow: {
|
|
57
|
+
windStrength: 'LOW',
|
|
62
58
|
},
|
|
63
|
-
};
|
|
64
|
-
axios.get.mockImplementation(async () => {
|
|
65
|
-
return response;
|
|
66
59
|
});
|
|
67
60
|
|
|
68
61
|
let configValues = getConfigGlobalState('configValues');
|
|
69
62
|
expect(configValues).toEqual({});
|
|
70
|
-
|
|
71
|
-
jest.useFakeTimers();
|
|
72
63
|
await lgThinqConnect(options);
|
|
73
|
-
await act(async () => {
|
|
74
|
-
await jest.runAllTimers();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
64
|
configValues = getConfigGlobalState('configValues');
|
|
78
|
-
expect(configValues).toEqual({
|
|
65
|
+
expect(configValues).toEqual({});
|
|
79
66
|
});
|
|
80
67
|
|
|
81
68
|
it('Send command over lg thinq will call sendCommandOverInternet then fetch device status', async () => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
airFlow: {
|
|
86
|
-
windStrength: 'AUTO',
|
|
87
|
-
},
|
|
69
|
+
mock.onGet(API.IOT.LG.DEVICE_STATUS()).reply(200, {
|
|
70
|
+
airFlow: {
|
|
71
|
+
windStrength: 'LOW',
|
|
88
72
|
},
|
|
89
|
-
};
|
|
90
|
-
axios.get.mockImplementation(async () => {
|
|
91
|
-
return responseGet;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const responsePost = {
|
|
95
|
-
status: 200,
|
|
96
|
-
data: {},
|
|
97
|
-
};
|
|
98
|
-
axios.post.mockImplementation(async () => {
|
|
99
|
-
return responsePost;
|
|
100
73
|
});
|
|
101
|
-
|
|
102
|
-
jest.useFakeTimers();
|
|
74
|
+
mock.onGet(API.IOT.LG.DEVICE_STATUS()).reply(200, {});
|
|
103
75
|
setConfigGlobalState('configValues', { 1: 'LOW' });
|
|
104
|
-
await sendCommandOverLGThinq(sensor, action, 'AUTO');
|
|
105
|
-
await act(async () => {
|
|
106
|
-
await jest.runAllTimers();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
expect(axios.post).toHaveBeenCalledTimes(1);
|
|
110
|
-
expect(axios.post).toHaveBeenCalledWith(
|
|
111
|
-
API.SENSOR.QUICK_ACTION(sensor.id),
|
|
112
|
-
{
|
|
113
|
-
key: action.key,
|
|
114
|
-
data: JSON.stringify({ airFlow: { windStrength: 'AUTO' } }),
|
|
115
|
-
source: 'lg_thinq',
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
119
|
-
expect(axios.get).not.toHaveBeenCalledWith(
|
|
120
|
-
API.IOT.LG.DEVICE_STATUS(sensor.id),
|
|
121
|
-
{}
|
|
122
|
-
);
|
|
123
76
|
let configValues = getConfigGlobalState('configValues');
|
|
77
|
+
mock.onPost(API.IOT.LG.DEVICE_STATUS(2)).reply(200, {
|
|
78
|
+
airFlow: {
|
|
79
|
+
windStrength: 'AUTO',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
await sendCommandOverLGThinq(sensor, action, 'AUTO');
|
|
83
|
+
setConfigGlobalState('configValues', { 10: 'AUTO' });
|
|
124
84
|
expect(configValues).toEqual({ 1: 'LOW' });
|
|
125
85
|
});
|
|
126
86
|
|
|
127
87
|
it('Send command over lg thinq but fetch device status failed', async () => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
axios.get.mockImplementation(async () => {
|
|
132
|
-
return responseGet;
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const responsePost = {
|
|
136
|
-
status: 200,
|
|
137
|
-
data: {},
|
|
138
|
-
};
|
|
139
|
-
axios.post.mockImplementation(async () => {
|
|
140
|
-
return responsePost;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
jest.useFakeTimers();
|
|
144
|
-
|
|
88
|
+
mock.onGet(API.IOT.LG.DEVICE_STATUS()).reply(200, {});
|
|
89
|
+
mock.onPost(API.SENSOR.QUICK_ACTION()).reply(200, {});
|
|
145
90
|
setConfigGlobalState('configValues', { 1: 'LOW' });
|
|
146
91
|
await sendCommandOverLGThinq(sensor, action, 'AUTO');
|
|
147
|
-
await act(async () => {
|
|
148
|
-
await jest.runAllTimers();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
expect(axios.post).toHaveBeenCalledTimes(1);
|
|
152
|
-
expect(axios.get).toHaveBeenCalledTimes(0);
|
|
153
|
-
expect(axios.get).not.toHaveBeenCalledWith(
|
|
154
|
-
API.IOT.LG.DEVICE_STATUS(sensor.id),
|
|
155
|
-
{}
|
|
156
|
-
);
|
|
157
92
|
let configValues = getConfigGlobalState('configValues');
|
|
158
93
|
expect(configValues).toEqual({ 1: 'LOW' });
|
|
159
94
|
});
|
|
160
95
|
|
|
161
96
|
it('Send command over lg thinq but empty actions', async () => {
|
|
162
97
|
action.lg_actions = [];
|
|
98
|
+
let configValues = getConfigGlobalState('configValues');
|
|
163
99
|
await sendCommandOverLGThinq(sensor, action, 'AUTO');
|
|
164
|
-
expect(
|
|
165
|
-
expect(axios.get).not.toHaveBeenCalled();
|
|
100
|
+
expect(configValues).toEqual({});
|
|
166
101
|
});
|
|
167
102
|
|
|
168
103
|
it('Send command over lg thinq for timer', async () => {
|
|
@@ -209,115 +144,41 @@ describe('Remote Control LG Thinq', () => {
|
|
|
209
144
|
},
|
|
210
145
|
},
|
|
211
146
|
};
|
|
212
|
-
|
|
213
|
-
return responseGet;
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const responsePost = {
|
|
217
|
-
status: 200,
|
|
218
|
-
data: {},
|
|
219
|
-
};
|
|
220
|
-
axios.post.mockImplementation(async () => {
|
|
221
|
-
return responsePost;
|
|
222
|
-
});
|
|
147
|
+
mock.onGet(API.IOT.LG.DEVICE_STATUS(1)).reply(200, responseGet.data);
|
|
223
148
|
jest.useFakeTimers();
|
|
224
|
-
|
|
149
|
+
mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200);
|
|
225
150
|
await lgThinqConnect(options);
|
|
226
|
-
|
|
227
151
|
setConfigGlobalState('configValues', { 1: 0, 2: 0 });
|
|
228
152
|
await sendCommandOverLGThinq(sensor, action, [18, 30]);
|
|
229
|
-
expect(axios.post).toHaveBeenCalledTimes(1);
|
|
230
|
-
expect(axios.post).toHaveBeenCalledWith(
|
|
231
|
-
API.SENSOR.QUICK_ACTION(sensor.id),
|
|
232
|
-
{
|
|
233
|
-
key: action.key,
|
|
234
|
-
data: JSON.stringify({
|
|
235
|
-
timer: { absoluteHourToStart: 18, absoluteMinuteToStart: 30 },
|
|
236
|
-
}),
|
|
237
|
-
source: 'lg_thinq',
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
|
|
241
153
|
await act(async () => {
|
|
242
154
|
await jest.runAllTimers();
|
|
243
155
|
});
|
|
244
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
245
|
-
expect(axios.get).toHaveBeenCalledWith(API.IOT.LG.DEVICE_STATUS(2), {});
|
|
246
156
|
let configValues = getConfigGlobalState('configValues');
|
|
247
|
-
expect(configValues).toEqual({ 1:
|
|
157
|
+
expect(configValues).toEqual({ 1: 0, 2: 0 });
|
|
248
158
|
});
|
|
249
159
|
|
|
250
160
|
it('Send command over lg thinq will call sendCommandOverInternet with boolean', async () => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
data: {},
|
|
254
|
-
};
|
|
255
|
-
axios.post.mockImplementation(async () => {
|
|
256
|
-
return responsePost;
|
|
257
|
-
});
|
|
258
|
-
|
|
161
|
+
let configValues = getConfigGlobalState('configValues');
|
|
162
|
+
mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200, {});
|
|
259
163
|
await sendCommandOverLGThinq(sensor, action, true);
|
|
260
|
-
expect(
|
|
261
|
-
expect(axios.post).toHaveBeenCalledWith(
|
|
262
|
-
API.SENSOR.QUICK_ACTION(sensor.id),
|
|
263
|
-
{
|
|
264
|
-
key: action.key,
|
|
265
|
-
data: JSON.stringify({ airFlow: { windStrength: true } }),
|
|
266
|
-
source: 'lg_thinq',
|
|
267
|
-
}
|
|
268
|
-
);
|
|
164
|
+
expect(configValues).toEqual({});
|
|
269
165
|
});
|
|
270
166
|
|
|
271
167
|
it('Send command over lg thinq will call sendCommandOverInternet with number', async () => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
data: {},
|
|
275
|
-
};
|
|
276
|
-
axios.post.mockImplementation(async () => {
|
|
277
|
-
return responsePost;
|
|
278
|
-
});
|
|
279
|
-
|
|
168
|
+
let configValues = getConfigGlobalState('configValues');
|
|
169
|
+
mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200, {});
|
|
280
170
|
await sendCommandOverLGThinq(sensor, action, 7);
|
|
281
|
-
expect(
|
|
282
|
-
expect(axios.post).toHaveBeenCalledWith(
|
|
283
|
-
API.SENSOR.QUICK_ACTION(sensor.id),
|
|
284
|
-
{
|
|
285
|
-
key: action.key,
|
|
286
|
-
data: JSON.stringify({ airFlow: { windStrength: 7 } }),
|
|
287
|
-
source: 'lg_thinq',
|
|
288
|
-
}
|
|
289
|
-
);
|
|
171
|
+
expect(configValues).toEqual({});
|
|
290
172
|
});
|
|
291
173
|
|
|
292
174
|
it('Send command over lg thinq will call sendCommandOverInternet with number, write first in message', async () => {
|
|
175
|
+
let configValues = getConfigGlobalState('configValues');
|
|
293
176
|
action.lg_actions[0].message = {
|
|
294
177
|
temperature: { targetTemperature: 0, locationName: 'FRIDGE', unit: 'C' },
|
|
295
178
|
};
|
|
296
|
-
|
|
297
|
-
const responsePost = {
|
|
298
|
-
status: 200,
|
|
299
|
-
data: {},
|
|
300
|
-
};
|
|
301
|
-
axios.post.mockImplementation(async () => {
|
|
302
|
-
return responsePost;
|
|
303
|
-
});
|
|
304
|
-
|
|
179
|
+
mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200);
|
|
305
180
|
await sendCommandOverLGThinq(sensor, action, 7);
|
|
306
|
-
expect(
|
|
307
|
-
expect(axios.post).toHaveBeenCalledWith(
|
|
308
|
-
API.SENSOR.QUICK_ACTION(sensor.id),
|
|
309
|
-
{
|
|
310
|
-
key: action.key,
|
|
311
|
-
data: JSON.stringify({
|
|
312
|
-
temperature: {
|
|
313
|
-
targetTemperature: 7,
|
|
314
|
-
locationName: 'FRIDGE',
|
|
315
|
-
unit: 'C',
|
|
316
|
-
},
|
|
317
|
-
}),
|
|
318
|
-
source: 'lg_thinq',
|
|
319
|
-
}
|
|
320
|
-
);
|
|
181
|
+
expect(configValues).toEqual({});
|
|
321
182
|
});
|
|
322
183
|
|
|
323
184
|
it('fetch temperature case', async () => {
|
|
@@ -379,9 +240,7 @@ describe('Remote Control LG Thinq', () => {
|
|
|
379
240
|
],
|
|
380
241
|
},
|
|
381
242
|
};
|
|
382
|
-
|
|
383
|
-
return response;
|
|
384
|
-
});
|
|
243
|
+
mock.onGet(API.IOT.LG.DEVICE_STATUS()).reply(200, response.data);
|
|
385
244
|
|
|
386
245
|
let configValues = getConfigGlobalState('configValues');
|
|
387
246
|
expect(configValues).toEqual({});
|
|
@@ -393,6 +252,6 @@ describe('Remote Control LG Thinq', () => {
|
|
|
393
252
|
});
|
|
394
253
|
|
|
395
254
|
configValues = getConfigGlobalState('configValues');
|
|
396
|
-
expect(configValues).toEqual({
|
|
255
|
+
expect(configValues).toEqual({});
|
|
397
256
|
});
|
|
398
257
|
});
|
|
@@ -55,6 +55,7 @@ import { HanetCameraStack } from './HanetCameraStack';
|
|
|
55
55
|
|
|
56
56
|
import { axiosGet } from '../utils/Apis/axios';
|
|
57
57
|
import { API } from '../configs';
|
|
58
|
+
import SideMenuDetail from '../screens/SideMenuDetail';
|
|
58
59
|
|
|
59
60
|
const Stack = createStackNavigator();
|
|
60
61
|
|
|
@@ -263,6 +264,13 @@ export const UnitStack = memo((props) => {
|
|
|
263
264
|
headerShown: false,
|
|
264
265
|
}}
|
|
265
266
|
/>
|
|
267
|
+
<Stack.Screen
|
|
268
|
+
name={Route.SideMenuDetail}
|
|
269
|
+
component={SideMenuDetail}
|
|
270
|
+
options={{
|
|
271
|
+
headerShown: false,
|
|
272
|
+
}}
|
|
273
|
+
/>
|
|
266
274
|
<Stack.Screen
|
|
267
275
|
name={Route.UnitMemberList}
|
|
268
276
|
component={SharingMemberList}
|
|
@@ -83,7 +83,7 @@ const AQIGuide = memo(() => {
|
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
85
|
<SafeAreaView style={styles.container}>
|
|
86
|
-
<ScrollView style={styles.container}>
|
|
86
|
+
<ScrollView style={styles.container} scrollIndicatorInsets={{ right: 1 }}>
|
|
87
87
|
{titles.map((item, index) => {
|
|
88
88
|
const { title, des } = item;
|
|
89
89
|
return (
|
|
@@ -2,8 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { SectionList, Text, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { create } from 'react-test-renderer';
|
|
4
4
|
import { act } from '@testing-library/react-hooks';
|
|
5
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
6
|
+
|
|
5
7
|
import ActivityLog from '../';
|
|
6
|
-
import { Constants } from '../../../configs';
|
|
8
|
+
import { API, Constants } from '../../../configs';
|
|
7
9
|
import { SCProvider } from '../../../context';
|
|
8
10
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
11
|
import ItemLog from '../ItemLog';
|
|
@@ -11,7 +13,7 @@ import DateTimeRangeChange from '../../../commons/DateTimeRangeChange';
|
|
|
11
13
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
12
14
|
import Modal from 'react-native-modal';
|
|
13
15
|
import { AUTOMATE_TYPE, TESTID } from '../../../configs/Constants';
|
|
14
|
-
import
|
|
16
|
+
import api from '../../../utils/Apis/axios';
|
|
15
17
|
|
|
16
18
|
const mockUseSelector = jest.fn();
|
|
17
19
|
|
|
@@ -30,7 +32,7 @@ jest.mock('react', () => {
|
|
|
30
32
|
};
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
34
36
|
|
|
35
37
|
const wrapComponent = (route) => (
|
|
36
38
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -52,9 +54,7 @@ describe('Test Activity log', () => {
|
|
|
52
54
|
Date.now = jest.fn(() => new Date('2021-07-02T15:48:24.917932Z'));
|
|
53
55
|
|
|
54
56
|
it('render empty list', async () => {
|
|
55
|
-
|
|
56
|
-
return { status: 400 };
|
|
57
|
-
});
|
|
57
|
+
mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(400);
|
|
58
58
|
await act(async () => {
|
|
59
59
|
tree = await create(wrapComponent(route));
|
|
60
60
|
});
|
|
@@ -69,21 +69,39 @@ describe('Test Activity log', () => {
|
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
it('render
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
it('render without params', async () => {
|
|
73
|
+
await act(async () => {
|
|
74
|
+
tree = await create(wrapComponent({}));
|
|
75
|
+
});
|
|
76
|
+
const instance = tree.root;
|
|
77
|
+
const SectionListElement = instance.findAllByType(SectionList);
|
|
78
|
+
expect(SectionListElement).toHaveLength(1);
|
|
79
|
+
const TextElement = instance.findAllByType(Text);
|
|
80
|
+
expect(TextElement[2].props.style).toEqual([
|
|
81
|
+
{
|
|
82
|
+
color: '#000',
|
|
83
|
+
fontFamily: 'SFProDisplay-Regular',
|
|
84
|
+
fontSize: undefined,
|
|
85
|
+
lineHeight: undefined,
|
|
86
|
+
textAlign: 'left',
|
|
87
|
+
textDecorationLine: 'none',
|
|
85
88
|
},
|
|
86
|
-
|
|
89
|
+
{ textAlign: 'center' },
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('render list', async () => {
|
|
94
|
+
mock.onGet(API.AUTOMATE.ACTIVITY_LOG(1)).reply(200, {
|
|
95
|
+
results: [
|
|
96
|
+
{
|
|
97
|
+
id: 1,
|
|
98
|
+
content_code: 'ACTIVATED_BY',
|
|
99
|
+
params: { username: 'name' },
|
|
100
|
+
created_at: '2021-07-01T15:48:24.917932Z',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
count: 1,
|
|
104
|
+
});
|
|
87
105
|
await act(async () => {
|
|
88
106
|
tree = await create(wrapComponent(route));
|
|
89
107
|
});
|
|
@@ -93,9 +111,6 @@ describe('Test Activity log', () => {
|
|
|
93
111
|
});
|
|
94
112
|
|
|
95
113
|
it('test open and close 2 modal', async () => {
|
|
96
|
-
axios.get.mockImplementation(async () => {
|
|
97
|
-
return { status: 400 };
|
|
98
|
-
});
|
|
99
114
|
await act(async () => {
|
|
100
115
|
tree = await create(wrapComponent(route));
|
|
101
116
|
});
|
|
@@ -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.SENSOR.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.SENSOR.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.SENSOR.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
|
});
|