@eohjsc/react-native-smart-city 0.2.45 → 0.2.46

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/src/Images/Common/logo.png +0 -0
  3. package/src/Images/Common/logo@2x.png +0 -0
  4. package/src/Images/Common/logo@3x.png +0 -0
  5. package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -1
  6. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +2 -0
  7. package/src/commons/SubUnit/ShortDetail.js +1 -1
  8. package/src/configs/Constants.js +7 -0
  9. package/src/configs/Images.js +1 -0
  10. package/src/screens/AddNewAction/SelectAction.js +52 -4
  11. package/src/screens/AddNewAction/SelectSensorDevices.js +27 -5
  12. package/src/screens/AddNewAction/SetupSensor.js +1 -6
  13. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -1
  14. package/src/screens/AddNewAutoSmart/index.js +24 -13
  15. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -1
  16. package/src/screens/AddNewOneTap/index.js +3 -0
  17. package/src/screens/Automate/MultiUnits.js +3 -52
  18. package/src/screens/Automate/__test__/MultiUnits.test.js +3 -246
  19. package/src/screens/Automate/__test__/index.test.js +1 -0
  20. package/src/screens/Automate/index.js +1 -0
  21. package/src/screens/Notification/components/NotificationItem.js +31 -14
  22. package/src/screens/Notification/styles/NotificationItemStyles.js +5 -0
  23. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +12 -3
  24. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +11 -2
  25. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +12 -3
  26. package/src/screens/ScriptDetail/__test__/index.test.js +71 -0
  27. package/src/screens/ScriptDetail/index.js +56 -4
  28. package/src/screens/SetSchedule/__test__/index.test.js +8 -0
  29. package/src/screens/SetSchedule/index.js +28 -6
  30. package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +38 -0
  31. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -1
  32. package/src/screens/TDSGuide/index.js +15 -19
  33. package/src/utils/I18n/translations/en.json +8 -0
  34. package/src/utils/I18n/translations/vi.json +20 -12
  35. package/src/utils/Route/index.js +1 -0
@@ -126,13 +126,13 @@ describe('Test MultiUnits', () => {
126
126
  expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
127
127
  screen: Routes.ScriptDetail,
128
128
  params: {
129
+ automate: response.data[1],
129
130
  id: response.data[1].id,
130
131
  name: response.data[1].script?.name,
131
132
  type: response.data[1].type,
132
133
  havePermission: false,
133
134
  unit: null,
134
135
  isMultiUnits: true,
135
- textCondition: 'Light Value lower than 0',
136
136
  },
137
137
  });
138
138
  const ItemAddNews = instance.findAllByType(ItemAddNew);
@@ -145,6 +145,7 @@ describe('Test MultiUnits', () => {
145
145
  type: AUTOMATE_TYPE.VALUE_CHANGE,
146
146
  isAutomateTab: true,
147
147
  isMultiUnits: true,
148
+ unit: { id: undefined },
148
149
  },
149
150
  });
150
151
  });
@@ -219,6 +220,7 @@ describe('Test MultiUnits', () => {
219
220
  type: AUTOMATE_TYPE.ONE_TAP_ONLY,
220
221
  isAutomateTab: true,
221
222
  isMultiUnits: true,
223
+ unit: { id: undefined },
222
224
  },
223
225
  });
224
226
  });
@@ -234,249 +236,4 @@ describe('Test MultiUnits', () => {
234
236
  const WrapHeaderScrollables = instance.findAllByType(WrapHeaderScrollable);
235
237
  expect(WrapHeaderScrollables[0].props.title).toEqual('');
236
238
  });
237
-
238
- it('Test render textCondition', async () => {
239
- const response = {
240
- status: 200,
241
- data: [
242
- {
243
- id: 1,
244
- user: 223,
245
- type: 'schedule',
246
- config: null,
247
- value: null,
248
- activate_at: '2021-09-22T14:16:54Z',
249
- condition: null,
250
- script: {
251
- id: 1,
252
- name: 'Tap to up down up down coc coc coc coc coc',
253
- icon: null,
254
- icon_kit:
255
- 'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
256
- },
257
- repeat: 'once',
258
- date_repeat: '2022-01-02',
259
- time_repeat: '09:10:00',
260
- weekday_repeat: ['1', '2', '4', '6'],
261
- },
262
- {
263
- id: 299,
264
- user: 223,
265
- type: 'value_change',
266
- config: 'Light Value',
267
- value: 0,
268
- activate_at: null,
269
- condition: '>',
270
- script: {
271
- id: 300,
272
- name: 'p14',
273
- icon: null,
274
- icon_kit: null,
275
- },
276
- repeat: 'once',
277
- date_repeat: '2022-01-02',
278
- time_repeat: '09:10:00',
279
- weekday_repeat: ['1', '2', '4', '6'],
280
- },
281
- {
282
- id: 300,
283
- user: 223,
284
- type: 'value_change',
285
- config: 'Light Value',
286
- value: 0,
287
- activate_at: null,
288
- condition: '=',
289
- script: {
290
- id: 300,
291
- name: 'p15',
292
- icon: null,
293
- icon_kit: null,
294
- },
295
- repeat: 'once',
296
- date_repeat: '2022-01-02',
297
- time_repeat: '09:10:00',
298
- weekday_repeat: ['1', '2', '4', '6'],
299
- },
300
- {
301
- id: 301,
302
- user: 223,
303
- type: 'schedule',
304
- config: null,
305
- value: null,
306
- activate_at: '2021-09-22T14:16:54Z',
307
- condition: null,
308
- script: {
309
- id: 1,
310
- name: 'Tap to up down up down coc coc coc coc coc',
311
- icon: null,
312
- icon_kit:
313
- 'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
314
- },
315
- repeat: 'once',
316
- date_repeat: '2022-01-02',
317
- time_repeat: '09:10:00',
318
- weekday_repeat: ['1', '2', '4', '6'],
319
- },
320
- {
321
- id: 302,
322
- user: 223,
323
- type: 'schedule',
324
- config: null,
325
- value: null,
326
- activate_at: '2021-09-22T14:16:54Z',
327
- condition: null,
328
- script: {
329
- id: 1,
330
- name: 'Tap to up down up down coc coc coc coc coc',
331
- icon: null,
332
- icon_kit:
333
- 'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
334
- },
335
- repeat: 'every_day',
336
- date_repeat: '2022-01-02',
337
- time_repeat: '09:10:00',
338
- weekday_repeat: ['1', '2', '4', '6'],
339
- },
340
- {
341
- id: 302,
342
- user: 223,
343
- type: 'schedule',
344
- config: null,
345
- value: null,
346
- activate_at: '2021-09-22T14:16:54Z',
347
- condition: null,
348
- script: {
349
- id: 1,
350
- name: 'Tap to up down up down coc coc coc coc coc',
351
- icon: null,
352
- icon_kit:
353
- 'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
354
- },
355
- repeat: 'every_week',
356
- date_repeat: '2022-01-02',
357
- time_repeat: '09:10:00',
358
- weekday_repeat: ['1', '2', '4', '6'],
359
- },
360
- ],
361
- };
362
- await axios.get.mockImplementation(async () => {
363
- return response;
364
- });
365
- useRoute.mockReturnValue({
366
- params: {
367
- isMultiUnits: true,
368
- unitName: null,
369
- unit: null,
370
- },
371
- });
372
- useState.mockImplementationOnce(() => [response.data, mockSetState]);
373
- useState.mockImplementationOnce(() => [
374
- getTranslate('en', 'Automation'),
375
- mockSetState,
376
- ]);
377
- await act(() => {
378
- tree = create(wrapComponent());
379
- });
380
- const instance = tree.root;
381
- const WrapHeaderScrollables = instance.findAllByType(WrapHeaderScrollable);
382
- expect(WrapHeaderScrollables[0].props.title).toEqual(
383
- getTranslate('en', 'multi_units_automate')
384
- );
385
- const TouchableOpacities = instance.findAllByType(TouchableOpacity);
386
- act(() => {
387
- TouchableOpacities[2].props.onPress();
388
- });
389
- expect(mockSetState).toBeCalledWith(getTranslate('en', 'Automation'));
390
- const ItemOneTaps = instance.findAllByType(ItemOneTap);
391
- act(() => {
392
- ItemOneTaps[0].props.onPressItem();
393
- });
394
- expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
395
- screen: Routes.ScriptDetail,
396
- params: {
397
- id: response.data[0].id,
398
- name: response.data[0].script?.name,
399
- type: response.data[0].type,
400
- havePermission: false,
401
- unit: null,
402
- isMultiUnits: true,
403
- textCondition: '09:10 02/01/2022',
404
- },
405
- });
406
- act(() => {
407
- ItemOneTaps[1].props.onPressItem();
408
- });
409
- expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
410
- screen: Routes.ScriptDetail,
411
- params: {
412
- id: response.data[1].id,
413
- name: response.data[1].script?.name,
414
- type: response.data[1].type,
415
- havePermission: false,
416
- unit: null,
417
- isMultiUnits: true,
418
- textCondition: 'Light Value higher than 0',
419
- },
420
- });
421
- act(() => {
422
- ItemOneTaps[2].props.onPressItem();
423
- });
424
- expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
425
- screen: Routes.ScriptDetail,
426
- params: {
427
- id: response.data[2].id,
428
- name: response.data[2].script?.name,
429
- type: response.data[2].type,
430
- havePermission: false,
431
- unit: null,
432
- isMultiUnits: true,
433
- textCondition: 'Light Value equal 0',
434
- },
435
- });
436
- act(() => {
437
- ItemOneTaps[3].props.onPressItem();
438
- });
439
- expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
440
- screen: Routes.ScriptDetail,
441
- params: {
442
- id: response.data[3].id,
443
- name: response.data[3].script?.name,
444
- type: response.data[3].type,
445
- havePermission: false,
446
- unit: null,
447
- isMultiUnits: true,
448
- textCondition: '09:10 02/01/2022',
449
- },
450
- });
451
- act(() => {
452
- ItemOneTaps[4].props.onPressItem();
453
- });
454
- expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
455
- screen: Routes.ScriptDetail,
456
- params: {
457
- id: response.data[4].id,
458
- name: response.data[4].script?.name,
459
- type: response.data[4].type,
460
- havePermission: false,
461
- unit: null,
462
- isMultiUnits: true,
463
- textCondition: 'Every day at 09:10',
464
- },
465
- });
466
- act(() => {
467
- ItemOneTaps[5].props.onPressItem();
468
- });
469
- expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
470
- screen: Routes.ScriptDetail,
471
- params: {
472
- id: response.data[5].id,
473
- name: response.data[5].script?.name,
474
- type: response.data[5].type,
475
- havePermission: false,
476
- unit: null,
477
- isMultiUnits: true,
478
- textCondition: 'Tue, Wed, Fri, Sun',
479
- },
480
- });
481
- });
482
239
  });
@@ -152,6 +152,7 @@ describe('Test Automate', () => {
152
152
  expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
153
153
  screen: Routes.ScriptDetail,
154
154
  params: {
155
+ automate: response.data[0].automates[0],
155
156
  isAutomateTab: true,
156
157
  isMultiUnits: true,
157
158
  name: 'script',
@@ -69,6 +69,7 @@ const Automate = () => {
69
69
  havePermission: isOwner || idUser === item?.user,
70
70
  unit: { id },
71
71
  isAutomateTab: true,
72
+ automate: item,
72
73
  isMultiUnits: type === UNIT_TYPES.MULTI,
73
74
  },
74
75
  });
@@ -1,11 +1,11 @@
1
1
  import React, { memo, useCallback, useMemo, useState } from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
2
+ import { View, TouchableOpacity, Image } from 'react-native';
3
3
  import moment from 'moment';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
 
6
6
  import styles from '../styles/NotificationItemStyles';
7
7
  import Text from '../../../commons/Text';
8
- import { Colors, API } from '../../../configs';
8
+ import { Colors, API, Images } from '../../../configs';
9
9
  import IconComponent from '../../../commons/IconComponent';
10
10
  import { NOTIFICATION_TYPES } from '../../../configs/Constants';
11
11
  import { useTranslations } from '../../../hooks/Common/useTranslations';
@@ -18,14 +18,18 @@ const NotificationItem = memo(({ item }) => {
18
18
  const { id, icon, created_at, is_read, params, content_code } = item;
19
19
  const [isRead, setIsRead] = useState(is_read);
20
20
  const timeFormat = moment(created_at).format('LT DD/MM/YYYY');
21
+ const regex = useMemo(() => {
22
+ return /\B'|'\B/g;
23
+ }, []);
24
+
21
25
  let arrParams = useMemo(() => {
22
26
  const values = [];
23
- const paramsJSON = JSON.parse(params.replace(/'/g, '"'));
27
+ const paramsJSON = JSON.parse(params.replace(regex, '"'));
24
28
  Object.entries(paramsJSON).forEach(([key, value]) => {
25
29
  values.push(value);
26
30
  });
27
31
  return values;
28
- }, [params]);
32
+ }, [params, regex]);
29
33
 
30
34
  const customColorText = (text, params) => {
31
35
  return text.split('**').map((str, i) =>
@@ -42,7 +46,7 @@ const NotificationItem = memo(({ item }) => {
42
46
  };
43
47
 
44
48
  const renderItem = useCallback(() => {
45
- const paramsJSON = JSON.parse(params.replace(/'/g, '"'));
49
+ const paramsJSON = JSON.parse(params.replace(regex, '"'));
46
50
  const booking_id = paramsJSON.booking_id && paramsJSON.booking_id;
47
51
  switch (content_code) {
48
52
  case NOTIFICATION_TYPES.NOTIFY_INVITE_MEMBER:
@@ -60,7 +64,12 @@ const NotificationItem = memo(({ item }) => {
60
64
  },
61
65
  });
62
66
  },
63
- textInviteMember: t('accept_invitation'),
67
+ iconContent: (
68
+ <IconComponent
69
+ icon_outlined={'usergroup-add'}
70
+ style={styles.iconInviteMember}
71
+ />
72
+ ),
64
73
  };
65
74
  case NOTIFICATION_TYPES.REMIND_TO_MAKE_PAYMENT:
66
75
  return {
@@ -211,10 +220,19 @@ const NotificationItem = memo(({ item }) => {
211
220
  params: { id: booking_id },
212
221
  }),
213
222
  };
223
+ case NOTIFICATION_TYPES.REMINDER:
224
+ return {
225
+ content: customColorText(
226
+ t('text_notification_content_update_reminder'),
227
+ arrParams
228
+ ),
229
+ redirect: () => navigation.navigate(Routes.PersonalHealthStack),
230
+ iconContent: <Image source={Images.logo} style={styles.logo} />,
231
+ };
214
232
  }
215
- }, [arrParams, content_code, navigation, params, t]);
233
+ }, [arrParams, content_code, navigation, params, regex, t]);
216
234
 
217
- const { content, redirect, textInviteMember } = renderItem() || {};
235
+ const { content, redirect, iconContent } = renderItem() || {};
218
236
 
219
237
  const onItemPress = useCallback(() => {
220
238
  if (!isRead) {
@@ -224,16 +242,15 @@ const NotificationItem = memo(({ item }) => {
224
242
  setIsRead(true);
225
243
  }, [id, isRead, redirect]);
226
244
 
245
+ if (!content) {
246
+ return null;
247
+ }
248
+
227
249
  return (
228
250
  <TouchableOpacity onPress={onItemPress}>
229
251
  <View style={[styles.container, !isRead && styles.backgroundGray]}>
230
252
  <View style={styles.wrapIcon}>
231
- {textInviteMember ? (
232
- <IconComponent
233
- icon_outlined={'usergroup-add'}
234
- style={styles.iconInviteMember}
235
- />
236
- ) : (
253
+ {iconContent || (
237
254
  <IconComponent iconKit={icon} style={styles.iconNotification} />
238
255
  )}
239
256
  </View>
@@ -47,4 +47,9 @@ export default StyleSheet.create({
47
47
  borderRadius: 50,
48
48
  width: 120,
49
49
  },
50
+ logo: {
51
+ width: 20,
52
+ height: 20,
53
+ resizeMode: 'contain',
54
+ },
50
55
  });
@@ -1,10 +1,19 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
3
  import axios from 'axios';
4
+
5
+ import { SCProvider } from '../../../context';
6
+ import { mockSCStore } from '../../../context/mockStore';
4
7
  import ScanChipQR from '..';
5
8
  import QRScan from '../components/QRScan';
6
9
  import Routes from '../../../utils/Route';
7
10
 
11
+ const wrapComponent = (route) => (
12
+ <SCProvider initState={mockSCStore({})}>
13
+ <ScanChipQR route={route} />
14
+ </SCProvider>
15
+ );
16
+
8
17
  const mockedNavigate = jest.fn();
9
18
  const mockedGoBack = jest.fn();
10
19
 
@@ -45,7 +54,7 @@ describe('test ScanChipQR', () => {
45
54
  test('create ScanChipQR', async () => {
46
55
  let tree;
47
56
  await act(async () => {
48
- tree = await create(<ScanChipQR route={route} />);
57
+ tree = await create(wrapComponent(route));
49
58
  });
50
59
  const instance = tree.root;
51
60
  const qrScan = instance.findAllByType(QRScan);
@@ -69,7 +78,7 @@ describe('test ScanChipQR', () => {
69
78
  let tree;
70
79
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
71
80
  await act(async () => {
72
- tree = await create(<ScanChipQR route={route} />);
81
+ tree = await create(wrapComponent(route));
73
82
  });
74
83
  const instance = tree.root;
75
84
  const qrScan = instance.findByType(QRScan);
@@ -100,7 +109,7 @@ describe('test ScanChipQR', () => {
100
109
  let tree;
101
110
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
102
111
  await act(async () => {
103
- tree = await create(<ScanChipQR route={route} />);
112
+ tree = await create(wrapComponent(route));
104
113
  });
105
114
  const instance = tree.root;
106
115
  const qrScan = instance.findByType(QRScan);
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  import { RNCamera } from 'react-native-camera';
3
3
  import { act, create } from 'react-test-renderer';
4
+
5
+ import { SCProvider } from '../../../../../context';
6
+ import { mockSCStore } from '../../../../../context/mockStore';
4
7
  import QRScan from '../index';
5
8
 
6
9
  const mockedPop = jest.fn();
@@ -17,6 +20,12 @@ jest.mock('@react-navigation/native', () => {
17
20
  };
18
21
  });
19
22
 
23
+ const wrapComponent = (data) => (
24
+ <SCProvider initState={mockSCStore({})}>
25
+ <QRScan {...data} />
26
+ </SCProvider>
27
+ );
28
+
20
29
  describe('Test QRScan', () => {
21
30
  let data;
22
31
 
@@ -32,7 +41,7 @@ describe('Test QRScan', () => {
32
41
 
33
42
  test('render QRScan', async () => {
34
43
  act(() => {
35
- tree = create(<QRScan {...data} />);
44
+ tree = create(wrapComponent(data));
36
45
  });
37
46
  const instance = tree.root;
38
47
  const RNCam = instance.findAllByType(RNCamera);
@@ -41,7 +50,7 @@ describe('Test QRScan', () => {
41
50
 
42
51
  test('onBarCodeRead', async () => {
43
52
  act(() => {
44
- tree = create(<QRScan {...data} />);
53
+ tree = create(wrapComponent(data));
45
54
  });
46
55
  const instance = tree.root;
47
56
  const RNCam = instance.findByType(RNCamera);
@@ -1,11 +1,20 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
3
  import axios from 'axios';
4
+
5
+ import { SCProvider } from '../../../context';
6
+ import { mockSCStore } from '../../../context/mockStore';
4
7
  import ScanSensorQR from '..';
5
8
  import QRScan from '../../ScanChipQR/components/QRScan';
6
9
  import API from '../../../configs/API';
7
10
  import Routes from '../../../utils/Route';
8
11
 
12
+ const wrapComponent = (route) => (
13
+ <SCProvider initState={mockSCStore({})}>
14
+ <ScanSensorQR route={route} />
15
+ </SCProvider>
16
+ );
17
+
9
18
  const mockedNavigate = jest.fn();
10
19
  const mockedGoBack = jest.fn();
11
20
 
@@ -46,7 +55,7 @@ describe('test ScanSensorQR', () => {
46
55
  test('create ScanSensorQR', async () => {
47
56
  let tree;
48
57
  await act(async () => {
49
- tree = await create(<ScanSensorQR route={route} />);
58
+ tree = await create(wrapComponent(route));
50
59
  });
51
60
  const instance = tree.root;
52
61
  const qrScan = instance.findAllByType(QRScan);
@@ -70,7 +79,7 @@ describe('test ScanSensorQR', () => {
70
79
  let tree;
71
80
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
72
81
  await act(async () => {
73
- tree = await create(<ScanSensorQR route={route} />);
82
+ tree = await create(wrapComponent(route));
74
83
  });
75
84
  const instance = tree.root;
76
85
  const qrScan = instance.findByType(QRScan);
@@ -103,7 +112,7 @@ describe('test ScanSensorQR', () => {
103
112
  let tree;
104
113
  const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
105
114
  await act(async () => {
106
- tree = await create(<ScanSensorQR route={route} />);
115
+ tree = await create(wrapComponent(route));
107
116
  });
108
117
  const instance = tree.root;
109
118
  const qrScan = instance.findByType(QRScan);
@@ -16,6 +16,7 @@ import { API } from '../../../configs';
16
16
  import { TouchableOpacity } from 'react-native';
17
17
  import Routes from '../../../utils/Route';
18
18
  import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
19
+ import ItemAutomate from '../../../commons/Automate/ItemAutomate';
19
20
 
20
21
  const wrapComponent = (route) => (
21
22
  <SCProvider initState={mockSCStore({})}>
@@ -297,4 +298,74 @@ describe('Test ScriptDetail', () => {
297
298
  `automate.${AUTOMATE_TYPE.ONE_TAP}`
298
299
  );
299
300
  _testGoToActivityLog(AUTOMATE_TYPE.VALUE_CHANGE, 'automate');
301
+
302
+ test('Test render textCondition value change >', async () => {
303
+ route.params = {
304
+ ...route.params,
305
+ type: AUTOMATE_TYPE.VALUE_CHANGE,
306
+ automate: {
307
+ repeat: 'once',
308
+ date_repeat: '2022-01-02',
309
+ time_repeat: '09:10:00',
310
+ weekday_repeat: ['1', '2', '4', '6'],
311
+ config_name: 'Light Value',
312
+ value: 3,
313
+ condition: '>',
314
+ },
315
+ };
316
+ await act(() => {
317
+ tree = create(wrapComponent(route));
318
+ });
319
+ const instance = tree.root;
320
+ const itemAutomate = instance.findByType(ItemAutomate);
321
+ expect(itemAutomate.props.textCondition).toEqual(
322
+ 'Light Value higher than 3'
323
+ );
324
+ });
325
+
326
+ test('Test render textCondition value change =', async () => {
327
+ route.params = {
328
+ ...route.params,
329
+ type: AUTOMATE_TYPE.VALUE_CHANGE,
330
+ automate: {
331
+ repeat: 'once',
332
+ date_repeat: '2022-01-02',
333
+ time_repeat: '09:10:00',
334
+ weekday_repeat: ['1', '2', '4', '6'],
335
+ config_name: 'Light Value',
336
+ value: 3,
337
+ condition: '=',
338
+ },
339
+ };
340
+ await act(() => {
341
+ tree = create(wrapComponent(route));
342
+ });
343
+ const instance = tree.root;
344
+ const itemAutomate = instance.findByType(ItemAutomate);
345
+ expect(itemAutomate.props.textCondition).toEqual('Light Value equal 3');
346
+ });
347
+
348
+ test('Test render textCondition value change <', async () => {
349
+ route.params = {
350
+ ...route.params,
351
+ type: AUTOMATE_TYPE.VALUE_CHANGE,
352
+ automate: {
353
+ repeat: 'once',
354
+ date_repeat: '2022-01-02',
355
+ time_repeat: '09:10:00',
356
+ weekday_repeat: ['1', '2', '4', '6'],
357
+ config_name: 'Light Value',
358
+ value: 3,
359
+ condition: '<',
360
+ },
361
+ };
362
+ await act(() => {
363
+ tree = create(wrapComponent(route));
364
+ });
365
+ const instance = tree.root;
366
+ const itemAutomate = instance.findByType(ItemAutomate);
367
+ expect(itemAutomate.props.textCondition).toEqual(
368
+ 'Light Value lower than 3'
369
+ );
370
+ });
300
371
  });