@eohjsc/react-native-smart-city 0.2.82 → 0.2.85
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/assets/images/Event.svg +9 -0
- package/assets/images/brightness.svg +12 -0
- package/package.json +4 -2
- package/src/Images/Common/SuccessfullyConnected.svg +4 -0
- package/src/Images/Common/eye-closed.png +0 -0
- package/src/Images/Common/eye-closed@2x.png +0 -0
- package/src/Images/Common/eye-closed@3x.png +0 -0
- package/src/Images/Common/eye.png +0 -0
- package/src/Images/Common/eye@2x.png +0 -0
- package/src/Images/Common/eye@3x.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +32 -21
- package/src/commons/ActionGroup/LightActionTemplate.js +103 -0
- package/src/commons/ActionGroup/LightActionTemplateStyles.js +57 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +8 -6
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +33 -31
- package/src/commons/ActionGroup/OnOffTemplate/index.js +11 -3
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +10 -7
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +5 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +33 -24
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +59 -0
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +18 -6
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +9 -1
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +25 -13
- package/src/commons/ActionGroup/__test__/index.test.js +48 -14
- package/src/commons/ActionGroup/index.js +3 -0
- package/src/commons/Automate/ItemAutomate.js +1 -1
- package/src/commons/Automate/ItemAutomateStyles.js +5 -1
- package/src/commons/CardShadow/index.js +5 -2
- package/src/commons/CardShadow/styles.js +2 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +16 -0
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +42 -0
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +27 -0
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +18 -0
- package/src/commons/ConnectingProcess/index.js +202 -0
- package/src/commons/ConnectingProcess/styles.js +69 -0
- package/src/commons/Device/HorizontalBarChart.js +7 -1
- package/src/commons/Device/ItemDevice.js +8 -5
- package/src/commons/Device/LinearChart.js +1 -0
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/EmergencyButton/AlertSent.js +2 -2
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +35 -0
- package/src/commons/SubUnit/Favorites/index.js +2 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -0
- package/src/commons/SubUnit/ShortDetail.js +7 -1
- package/src/commons/index.js +2 -0
- package/src/configs/API.js +6 -4
- package/src/configs/Constants.js +25 -0
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/Common/useBlockBackAndroid.js +3 -1
- package/src/iot/RemoteControl/Internet.js +8 -1
- package/src/iot/RemoteControl/index.js +4 -2
- package/src/navigations/AddDeviceStack.js +10 -0
- package/src/screens/AddCommon/SelectSubUnit.js +29 -6
- package/src/screens/AddCommon/SelectUnit.js +24 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +120 -1
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +16 -1
- package/src/screens/AddNewAction/SelectAction.js +46 -28
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -3
- package/src/screens/AddNewAutoSmart/index.js +18 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +55 -16
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +52 -23
- package/src/screens/AddNewGateway/SelectGateway.js +132 -0
- package/src/screens/AddNewGateway/SelectGatewayStyles.js +55 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -52
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +18 -11
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +64 -26
- package/src/screens/Device/styles.js +2 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +197 -15
- package/src/screens/Notification/components/NotificationItem.js +188 -14
- package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +10 -7
- package/src/screens/ScanChipQR/hooks/index.js +48 -40
- package/src/screens/SubUnit/AddSubUnit.js +4 -1
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
- package/src/screens/Unit/Detail.js +33 -1
- package/src/screens/Unit/ManageUnit.js +1 -1
- package/src/screens/Unit/ManageUnitStyles.js +0 -6
- package/src/screens/Unit/SmartAccount.js +5 -1
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
- package/src/screens/Unit/__test__/Detail.test.js +10 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
- package/src/screens/UnitSummary/__test__/index.test.js +3 -3
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/index.js +52 -9
- package/src/utils/Apis/axios.js +1 -1
- package/src/utils/I18n/translations/en.json +16 -0
- package/src/utils/I18n/translations/vi.json +16 -1
- package/src/utils/Route/index.js +2 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import Slider from 'react-native-slider';
|
|
4
|
+
import ColorPicker from 'react-native-wheel-color-picker';
|
|
5
|
+
|
|
6
|
+
import LightActionTemplate from '../LightActionTemplate';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (actionGroup) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<LightActionTemplate actionGroup={actionGroup} doAction={jest.fn()} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
describe('Test CurtainButtonTemplate', () => {
|
|
17
|
+
const actionGroup = {
|
|
18
|
+
configuration: {
|
|
19
|
+
action: 'b1be40f2-f482-4796-8c1a-0431ab49ab5a',
|
|
20
|
+
action_data: {
|
|
21
|
+
color: '#00979D',
|
|
22
|
+
command_prefer_over_bluetooth: true,
|
|
23
|
+
command_prefer_over_googlehome: false,
|
|
24
|
+
command_prefer_over_internet: false,
|
|
25
|
+
googlehome_actions: [Array],
|
|
26
|
+
icon: '123231',
|
|
27
|
+
icon_kit: null,
|
|
28
|
+
id: 5,
|
|
29
|
+
key: 'b1be40f2-f482-4796-8c1a-0431ab49ab5a',
|
|
30
|
+
lg_actions: [Array],
|
|
31
|
+
name: 'change color',
|
|
32
|
+
},
|
|
33
|
+
config_brightness: 18,
|
|
34
|
+
config_color: 17,
|
|
35
|
+
},
|
|
36
|
+
id: 2,
|
|
37
|
+
template: 'light_action_template',
|
|
38
|
+
title: 'controller',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let wrapper;
|
|
42
|
+
|
|
43
|
+
test('render LightActionTemplate', async () => {
|
|
44
|
+
await act(() => {
|
|
45
|
+
wrapper = renderer.create(wrapComponent(actionGroup));
|
|
46
|
+
});
|
|
47
|
+
const instance = wrapper.root;
|
|
48
|
+
const slider = instance.findAllByType(Slider);
|
|
49
|
+
const colorPicker = instance.findAllByType(ColorPicker);
|
|
50
|
+
expect(slider.length).toEqual(1);
|
|
51
|
+
expect(colorPicker.length).toEqual(1);
|
|
52
|
+
await act(async () => {
|
|
53
|
+
await slider[0].props.onSlidingComplete();
|
|
54
|
+
});
|
|
55
|
+
await act(async () => {
|
|
56
|
+
await colorPicker[0].props.onColorChangeComplete();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -146,7 +146,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
146
146
|
<OnOffTemplate
|
|
147
147
|
actionGroup={actionGroup}
|
|
148
148
|
doAction={mockDoAction}
|
|
149
|
-
sensor={{}}
|
|
149
|
+
sensor={{ name: 'Sensor name' }}
|
|
150
150
|
/>
|
|
151
151
|
);
|
|
152
152
|
});
|
|
@@ -157,7 +157,11 @@ describe('Test OnOffTemplate', () => {
|
|
|
157
157
|
await act(async () => {
|
|
158
158
|
await template.props.triggerAction();
|
|
159
159
|
});
|
|
160
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
160
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
161
|
+
action_off_data,
|
|
162
|
+
null,
|
|
163
|
+
'Sensor name turn on / off off'
|
|
164
|
+
);
|
|
161
165
|
expect(watchMultiConfigs).toBeCalledTimes(0);
|
|
162
166
|
});
|
|
163
167
|
|
|
@@ -169,7 +173,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
169
173
|
<OnOffTemplate
|
|
170
174
|
actionGroup={actionGroup}
|
|
171
175
|
doAction={mockDoAction}
|
|
172
|
-
sensor={{}}
|
|
176
|
+
sensor={{ name: 'Sensor name' }}
|
|
173
177
|
/>
|
|
174
178
|
);
|
|
175
179
|
});
|
|
@@ -180,7 +184,11 @@ describe('Test OnOffTemplate', () => {
|
|
|
180
184
|
await act(async () => {
|
|
181
185
|
await template.props.triggerAction();
|
|
182
186
|
});
|
|
183
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
187
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
188
|
+
action_on_data,
|
|
189
|
+
null,
|
|
190
|
+
'Sensor name turn on / off on'
|
|
191
|
+
);
|
|
184
192
|
});
|
|
185
193
|
|
|
186
194
|
test('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
|
|
@@ -190,7 +198,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
190
198
|
<OnOffTemplate
|
|
191
199
|
actionGroup={actionGroup}
|
|
192
200
|
doAction={mockDoAction}
|
|
193
|
-
sensor={{ is_managed_by_backend: true }}
|
|
201
|
+
sensor={{ name: 'Sensor name', is_managed_by_backend: true }}
|
|
194
202
|
/>
|
|
195
203
|
);
|
|
196
204
|
});
|
|
@@ -201,7 +209,11 @@ describe('Test OnOffTemplate', () => {
|
|
|
201
209
|
await act(async () => {
|
|
202
210
|
await template.props.triggerAction();
|
|
203
211
|
});
|
|
204
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
212
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
213
|
+
action_off_data,
|
|
214
|
+
null,
|
|
215
|
+
'Sensor name turn on / off off'
|
|
216
|
+
);
|
|
205
217
|
expect(watchMultiConfigs).toBeCalledTimes(2);
|
|
206
218
|
});
|
|
207
219
|
|
|
@@ -23,6 +23,9 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
23
23
|
text: 'UP',
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
|
+
const sensor = {
|
|
27
|
+
name: 'Sensor name',
|
|
28
|
+
};
|
|
26
29
|
let wrapper;
|
|
27
30
|
|
|
28
31
|
test('render OneBigButtonTemplate', () => {
|
|
@@ -32,6 +35,7 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
32
35
|
<OneBigButtonTemplate
|
|
33
36
|
actionGroup={actionGroup}
|
|
34
37
|
doAction={mockDoAction}
|
|
38
|
+
sensor={sensor}
|
|
35
39
|
/>
|
|
36
40
|
);
|
|
37
41
|
});
|
|
@@ -45,6 +49,10 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
48
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
52
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
53
|
+
action_data,
|
|
54
|
+
null,
|
|
55
|
+
'Sensor name up'
|
|
56
|
+
);
|
|
49
57
|
});
|
|
50
58
|
});
|
|
@@ -10,16 +10,12 @@ import { getTranslate } from '../../../utils/I18n';
|
|
|
10
10
|
import { SCProvider } from '../../../context';
|
|
11
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
12
12
|
|
|
13
|
-
const wrapComponent = (
|
|
14
|
-
actionGroup,
|
|
15
|
-
mockDoAction,
|
|
16
|
-
is_managed_by_backend = false
|
|
17
|
-
) => (
|
|
13
|
+
const wrapComponent = (actionGroup, mockDoAction, sensor) => (
|
|
18
14
|
<SCProvider initState={mockSCStore({})}>
|
|
19
15
|
<OptionsDropdownActionTemplate
|
|
20
16
|
actionGroup={actionGroup}
|
|
21
17
|
doAction={mockDoAction}
|
|
22
|
-
sensor={
|
|
18
|
+
sensor={sensor}
|
|
23
19
|
/>
|
|
24
20
|
</SCProvider>
|
|
25
21
|
);
|
|
@@ -43,6 +39,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
43
39
|
};
|
|
44
40
|
|
|
45
41
|
let actionGroup;
|
|
42
|
+
let sensor;
|
|
46
43
|
let wrapper;
|
|
47
44
|
|
|
48
45
|
beforeEach(() => {
|
|
@@ -68,12 +65,17 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
68
65
|
icon: 'slack',
|
|
69
66
|
},
|
|
70
67
|
};
|
|
68
|
+
sensor = {
|
|
69
|
+
name: 'Sensor name',
|
|
70
|
+
is_managed_by_backend: false,
|
|
71
|
+
};
|
|
71
72
|
});
|
|
72
73
|
|
|
73
74
|
test('render template', async () => {
|
|
74
75
|
const mockDoAction = jest.fn();
|
|
76
|
+
sensor.is_managed_by_backend = true;
|
|
75
77
|
await act(async () => {
|
|
76
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction,
|
|
78
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
77
79
|
});
|
|
78
80
|
const instance = wrapper.root;
|
|
79
81
|
|
|
@@ -88,9 +90,10 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
88
90
|
|
|
89
91
|
test('render template without selectedOption match, get first one', async () => {
|
|
90
92
|
actionGroup.configuration.options[1].value_int = 3;
|
|
93
|
+
sensor.is_managed_by_backend = true;
|
|
91
94
|
const mockDoAction = jest.fn();
|
|
92
95
|
await act(async () => {
|
|
93
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction,
|
|
96
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
94
97
|
});
|
|
95
98
|
const instance = wrapper.root;
|
|
96
99
|
|
|
@@ -102,7 +105,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
102
105
|
const assertUpdateSelectedOption = async (is_managed_by_backend) => {
|
|
103
106
|
const mockDoAction = jest.fn();
|
|
104
107
|
await act(async () => {
|
|
105
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction));
|
|
108
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
106
109
|
});
|
|
107
110
|
const instance = wrapper.root;
|
|
108
111
|
|
|
@@ -147,7 +150,11 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
147
150
|
});
|
|
148
151
|
expect(alertAction.props.visible).toBeFalsy();
|
|
149
152
|
|
|
150
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
153
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
154
|
+
action_data,
|
|
155
|
+
1,
|
|
156
|
+
'Sensor name fan speed 1'
|
|
157
|
+
);
|
|
151
158
|
is_managed_by_backend
|
|
152
159
|
? expect(watchMultiConfigs).not.toBeCalled()
|
|
153
160
|
: expect(watchMultiConfigs).not.toBeCalled();
|
|
@@ -167,7 +174,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
167
174
|
actionGroup.configuration.options[0].value_text = 'level-1';
|
|
168
175
|
const mockDoAction = jest.fn();
|
|
169
176
|
await act(async () => {
|
|
170
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction));
|
|
177
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
171
178
|
});
|
|
172
179
|
const instance = wrapper.root;
|
|
173
180
|
|
|
@@ -212,17 +219,22 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
212
219
|
});
|
|
213
220
|
expect(alertAction.props.visible).toBeFalsy();
|
|
214
221
|
|
|
215
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
222
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
223
|
+
action_data,
|
|
224
|
+
'level-1',
|
|
225
|
+
'Sensor name fan speed level-1'
|
|
226
|
+
); // doAction with text instead of int
|
|
216
227
|
|
|
217
228
|
expect(texts[1].props.children).toEqual('Level2');
|
|
218
229
|
});
|
|
219
230
|
|
|
220
231
|
test('render template without read config', async () => {
|
|
221
232
|
delete actionGroup.configuration.config;
|
|
233
|
+
sensor.is_managed_by_backend = true;
|
|
222
234
|
|
|
223
235
|
const mockDoAction = jest.fn();
|
|
224
236
|
await act(async () => {
|
|
225
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction,
|
|
237
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
226
238
|
});
|
|
227
239
|
const instance = wrapper.root;
|
|
228
240
|
const textDisplaySelected = instance.find(
|
|
@@ -75,6 +75,9 @@ describe('Test ActionGroup', () => {
|
|
|
75
75
|
id: 20,
|
|
76
76
|
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
77
77
|
};
|
|
78
|
+
const sensor = {
|
|
79
|
+
name: 'Sensor name',
|
|
80
|
+
};
|
|
78
81
|
let actionGroupData;
|
|
79
82
|
let wrapper;
|
|
80
83
|
|
|
@@ -154,7 +157,9 @@ describe('Test ActionGroup', () => {
|
|
|
154
157
|
const actionGroup = actionGroupData;
|
|
155
158
|
const mockDoAction = jest.fn();
|
|
156
159
|
await act(() => {
|
|
157
|
-
wrapper = renderer.create(
|
|
160
|
+
wrapper = renderer.create(
|
|
161
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
162
|
+
);
|
|
158
163
|
});
|
|
159
164
|
const instance = wrapper.root;
|
|
160
165
|
const buttons = instance.findAllByType(TouchableOpacity);
|
|
@@ -170,21 +175,27 @@ describe('Test ActionGroup', () => {
|
|
|
170
175
|
});
|
|
171
176
|
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
172
177
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
173
|
-
actionGroup.configuration.action1_data
|
|
178
|
+
actionGroup.configuration.action1_data,
|
|
179
|
+
null,
|
|
180
|
+
'Sensor name up'
|
|
174
181
|
);
|
|
175
182
|
act(() => {
|
|
176
183
|
buttons[1].props.onPress();
|
|
177
184
|
});
|
|
178
185
|
expect(mockDoAction).toHaveBeenCalledTimes(2);
|
|
179
186
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
180
|
-
actionGroup.configuration.action2_data
|
|
187
|
+
actionGroup.configuration.action2_data,
|
|
188
|
+
null,
|
|
189
|
+
'Sensor name stop'
|
|
181
190
|
);
|
|
182
191
|
act(() => {
|
|
183
192
|
buttons[2].props.onPress();
|
|
184
193
|
});
|
|
185
194
|
expect(mockDoAction).toHaveBeenCalledTimes(3);
|
|
186
195
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
187
|
-
actionGroup.configuration.action3_data
|
|
196
|
+
actionGroup.configuration.action3_data,
|
|
197
|
+
null,
|
|
198
|
+
'Sensor name down'
|
|
188
199
|
);
|
|
189
200
|
});
|
|
190
201
|
|
|
@@ -220,7 +231,9 @@ describe('Test ActionGroup', () => {
|
|
|
220
231
|
};
|
|
221
232
|
const mockDoAction = jest.fn();
|
|
222
233
|
await act(() => {
|
|
223
|
-
wrapper = renderer.create(
|
|
234
|
+
wrapper = renderer.create(
|
|
235
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
236
|
+
);
|
|
224
237
|
});
|
|
225
238
|
const instance = wrapper.root;
|
|
226
239
|
const buttons = instance.findAllByType(TouchableOpacity);
|
|
@@ -236,21 +249,27 @@ describe('Test ActionGroup', () => {
|
|
|
236
249
|
});
|
|
237
250
|
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
238
251
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
239
|
-
actionGroup.configuration.action1_data
|
|
252
|
+
actionGroup.configuration.action1_data,
|
|
253
|
+
null,
|
|
254
|
+
'Sensor name up'
|
|
240
255
|
);
|
|
241
256
|
act(() => {
|
|
242
257
|
buttons[1].props.onPress();
|
|
243
258
|
});
|
|
244
259
|
expect(mockDoAction).toHaveBeenCalledTimes(2);
|
|
245
260
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
246
|
-
actionGroup.configuration.action2_data
|
|
261
|
+
actionGroup.configuration.action2_data,
|
|
262
|
+
null,
|
|
263
|
+
'Sensor name stop'
|
|
247
264
|
);
|
|
248
265
|
act(() => {
|
|
249
266
|
buttons[2].props.onPress();
|
|
250
267
|
});
|
|
251
268
|
expect(mockDoAction).toHaveBeenCalledTimes(3);
|
|
252
269
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
253
|
-
actionGroup.configuration.action3_data
|
|
270
|
+
actionGroup.configuration.action3_data,
|
|
271
|
+
null,
|
|
272
|
+
'Sensor name down'
|
|
254
273
|
);
|
|
255
274
|
});
|
|
256
275
|
|
|
@@ -279,7 +298,9 @@ describe('Test ActionGroup', () => {
|
|
|
279
298
|
},
|
|
280
299
|
};
|
|
281
300
|
await act(() => {
|
|
282
|
-
wrapper = renderer.create(
|
|
301
|
+
wrapper = renderer.create(
|
|
302
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
303
|
+
);
|
|
283
304
|
});
|
|
284
305
|
const instance = wrapper.root;
|
|
285
306
|
const buttons = instance.findAllByType(TouchableOpacity);
|
|
@@ -288,7 +309,11 @@ describe('Test ActionGroup', () => {
|
|
|
288
309
|
buttons[0].props.onPress();
|
|
289
310
|
});
|
|
290
311
|
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
291
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
312
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
313
|
+
action_data,
|
|
314
|
+
null,
|
|
315
|
+
'Sensor name up'
|
|
316
|
+
);
|
|
292
317
|
});
|
|
293
318
|
|
|
294
319
|
test('render ActionGroup on_off_button_action_template', async () => {
|
|
@@ -303,9 +328,12 @@ describe('Test ActionGroup', () => {
|
|
|
303
328
|
icon_off: 'caret-up',
|
|
304
329
|
text_off: 'OFF',
|
|
305
330
|
},
|
|
331
|
+
title: 'Power',
|
|
306
332
|
};
|
|
307
333
|
await act(() => {
|
|
308
|
-
wrapper = renderer.create(
|
|
334
|
+
wrapper = renderer.create(
|
|
335
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
336
|
+
);
|
|
309
337
|
});
|
|
310
338
|
const instance = wrapper.root;
|
|
311
339
|
const buttons = instance.findAllByType(TouchableOpacity);
|
|
@@ -329,7 +357,9 @@ describe('Test ActionGroup', () => {
|
|
|
329
357
|
},
|
|
330
358
|
};
|
|
331
359
|
await act(() => {
|
|
332
|
-
wrapper = renderer.create(
|
|
360
|
+
wrapper = renderer.create(
|
|
361
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
362
|
+
);
|
|
333
363
|
});
|
|
334
364
|
const instance = wrapper.root;
|
|
335
365
|
const text = instance.findAllByType(Text);
|
|
@@ -366,7 +396,9 @@ describe('Test ActionGroup', () => {
|
|
|
366
396
|
},
|
|
367
397
|
};
|
|
368
398
|
await act(() => {
|
|
369
|
-
wrapper = renderer.create(
|
|
399
|
+
wrapper = renderer.create(
|
|
400
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
401
|
+
);
|
|
370
402
|
});
|
|
371
403
|
const instance = wrapper.root;
|
|
372
404
|
const texts = instance.findAllByType(Text);
|
|
@@ -413,7 +445,9 @@ describe('Test ActionGroup', () => {
|
|
|
413
445
|
};
|
|
414
446
|
const mockDoAction = jest.fn();
|
|
415
447
|
await act(() => {
|
|
416
|
-
wrapper = renderer.create(
|
|
448
|
+
wrapper = renderer.create(
|
|
449
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
450
|
+
);
|
|
417
451
|
});
|
|
418
452
|
const instance = wrapper.root;
|
|
419
453
|
|
|
@@ -10,6 +10,7 @@ import OnOffTemplate from './OnOffTemplate';
|
|
|
10
10
|
import TimerActionTemplate from './TimerActionTemplate';
|
|
11
11
|
import CurtainButtonTemplate from './CurtainButtonTemplate';
|
|
12
12
|
import SmartTiviActionTemplate from './SmartTiviActionTemplate/SmartTiviActionTemplate';
|
|
13
|
+
import LightActionTemplate from './LightActionTemplate';
|
|
13
14
|
|
|
14
15
|
export const getActionComponent = (template) => {
|
|
15
16
|
switch (template) {
|
|
@@ -35,6 +36,8 @@ export const getActionComponent = (template) => {
|
|
|
35
36
|
return CurtainButtonTemplate;
|
|
36
37
|
case 'SmartTiviActionTemplate':
|
|
37
38
|
return SmartTiviActionTemplate;
|
|
39
|
+
case 'light_action_template':
|
|
40
|
+
return LightActionTemplate;
|
|
38
41
|
default:
|
|
39
42
|
return null;
|
|
40
43
|
}
|
|
@@ -3,10 +3,13 @@ import { View } from 'react-native';
|
|
|
3
3
|
import Text from '../../commons/Text';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
|
|
6
|
-
const Card = memo(({ title, children, style }) => {
|
|
6
|
+
const Card = memo(({ title, children, style, rightHeaderComponent }) => {
|
|
7
7
|
return (
|
|
8
8
|
<View style={[styles.card, style]}>
|
|
9
|
-
|
|
9
|
+
<View style={styles.headerTitle}>
|
|
10
|
+
{!!title && <Text style={styles.headerLeft}>{title}</Text>}
|
|
11
|
+
{!!rightHeaderComponent && rightHeaderComponent}
|
|
12
|
+
</View>
|
|
10
13
|
{children}
|
|
11
14
|
</View>
|
|
12
15
|
);
|
|
@@ -17,9 +17,8 @@ export default StyleSheet.create({
|
|
|
17
17
|
shadowRadius: 3,
|
|
18
18
|
elevation: 6,
|
|
19
19
|
},
|
|
20
|
-
headerTitle: {
|
|
21
|
-
|
|
22
|
-
alignItems: 'flex-end',
|
|
20
|
+
headerTitle: { justifyContent: 'space-between', flexDirection: 'row' },
|
|
21
|
+
headerLeft: {
|
|
23
22
|
color: Colors.Gray8,
|
|
24
23
|
fontSize: 16,
|
|
25
24
|
lineHeight: 24,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import styles from './DeviceItemStyles';
|
|
4
|
+
import FImage from '../../FImage';
|
|
5
|
+
import Text from '../../Text';
|
|
6
|
+
|
|
7
|
+
const DeviceItem = memo(({ icon, name }) => {
|
|
8
|
+
return (
|
|
9
|
+
<View style={styles.container}>
|
|
10
|
+
{!!icon && <FImage source={{ uri: icon }} style={styles.iconSensor} />}
|
|
11
|
+
<Text style={styles.textItem}>{name}</Text>
|
|
12
|
+
</View>
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default DeviceItem;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Constants, Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
const marginItem = 12;
|
|
5
|
+
const marginHorizontal = 5;
|
|
6
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
+
const heightItem = (widthItem / 166) * 60;
|
|
8
|
+
|
|
9
|
+
export default StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
paddingHorizontal: 15,
|
|
12
|
+
borderRadius: 10,
|
|
13
|
+
width: 250,
|
|
14
|
+
height: heightItem,
|
|
15
|
+
borderWidth: 1,
|
|
16
|
+
borderColor: Colors.Gray4,
|
|
17
|
+
backgroundColor: Colors.White,
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
marginBottom: 16,
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
shadowColor: Colors.Shadow,
|
|
23
|
+
shadowOffset: {
|
|
24
|
+
width: 0,
|
|
25
|
+
height: 2,
|
|
26
|
+
},
|
|
27
|
+
shadowOpacity: 0.1,
|
|
28
|
+
shadowRadius: 3,
|
|
29
|
+
elevation: 6,
|
|
30
|
+
paddingLeft: 30,
|
|
31
|
+
paddingRight: 30,
|
|
32
|
+
},
|
|
33
|
+
iconSensor: {
|
|
34
|
+
width: 32,
|
|
35
|
+
height: 32,
|
|
36
|
+
resizeMode: 'contain',
|
|
37
|
+
},
|
|
38
|
+
textItem: {
|
|
39
|
+
marginLeft: 15,
|
|
40
|
+
fontSize: 16,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import ConnectingProcess from '../index';
|
|
4
|
+
import { SafeAreaView } from 'react-native';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = (route) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ConnectingProcess route={route} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
describe('Test ConnectingProcess', () => {
|
|
14
|
+
let tree;
|
|
15
|
+
test('create ConnectingProcess', () => {
|
|
16
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
17
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
18
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
19
|
+
const route = { params: { scan_sensor_data, gateway, station } };
|
|
20
|
+
act(() => {
|
|
21
|
+
tree = renderer.create(wrapComponent(route));
|
|
22
|
+
});
|
|
23
|
+
const instance = tree.root;
|
|
24
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
25
|
+
expect(safeAreaView).toHaveLength(1);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import DeviceItem from '../DeviceItem/DeviceItem';
|
|
4
|
+
import FImage from '../../FImage';
|
|
5
|
+
import Text from '../../Text';
|
|
6
|
+
describe('Test DeviceItem button', () => {
|
|
7
|
+
let tree;
|
|
8
|
+
test('create DeviceItem button', () => {
|
|
9
|
+
act(() => {
|
|
10
|
+
tree = renderer.create(<DeviceItem />);
|
|
11
|
+
});
|
|
12
|
+
const instance = tree.root;
|
|
13
|
+
const image = instance.findAllByType(FImage);
|
|
14
|
+
const text = instance.findAllByType(Text);
|
|
15
|
+
expect(image).toHaveLength(0);
|
|
16
|
+
expect(text).toHaveLength(1);
|
|
17
|
+
});
|
|
18
|
+
});
|