@eohjsc/react-native-smart-city 0.2.96 → 0.2.99

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 (109) hide show
  1. package/README.md +35 -14
  2. package/package.json +16 -4
  3. package/src/commons/Action/ItemQuickAction.js +5 -2
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
  7. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  8. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  9. package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
  10. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +8 -2
  11. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  12. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
  13. package/src/commons/ActionGroup/StatesGridActionTemplate.js +14 -4
  14. package/src/commons/ActionGroup/TimerActionTemplate.js +9 -1
  15. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
  16. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  17. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  18. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  19. package/src/commons/Auth/AccountList.js +1 -1
  20. package/src/commons/{Connecting → Connecting}/__test__/Connecting.test.js +0 -0
  21. package/src/commons/{Connecting → Connecting}/index.js +0 -0
  22. package/src/commons/{Connecting → Connecting}/styles.js +0 -0
  23. package/src/commons/ConnectingProcess/index.js +1 -1
  24. package/src/commons/Device/HistoryChart.js +6 -2
  25. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  26. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  27. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  28. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  29. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  30. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  31. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +113 -0
  32. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  33. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  34. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +93 -0
  35. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  36. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  37. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +182 -0
  38. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  39. package/src/commons/FullLoading/index.js +2 -1
  40. package/src/commons/MenuActionAddnew/index.js +1 -0
  41. package/src/commons/MenuActionList/index.js +1 -0
  42. package/src/commons/MenuActionMore/index.js +1 -1
  43. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  44. package/src/commons/PreventAccess/index.js +67 -0
  45. package/src/commons/PreventAccess/styles.js +33 -0
  46. package/src/commons/WheelDateTimePicker/index.js +2 -1
  47. package/src/configs/API.js +3 -0
  48. package/src/configs/Constants.js +16 -1
  49. package/src/iot/RemoteControl/GoogleHome.js +24 -11
  50. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +32 -0
  51. package/src/navigations/UnitStack.js +8 -0
  52. package/src/screens/AQIGuide/index.js +1 -1
  53. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  54. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  55. package/src/screens/AddCommon/SelectUnit.js +1 -0
  56. package/src/screens/AddLocationMaps/index.js +4 -1
  57. package/src/screens/AddNewAction/SelectSensorDevices.js +14 -3
  58. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +34 -92
  59. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  60. package/src/screens/AddNewAutoSmart/index.js +5 -2
  61. package/src/screens/AddNewDevice/index.js +1 -0
  62. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +1 -1
  63. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
  64. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  65. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  66. package/src/screens/AddNewGateway/index.js +1 -0
  67. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +1 -1
  68. package/src/screens/AddNewOneTap/index.js +3 -2
  69. package/src/screens/Automate/index.js +2 -0
  70. package/src/screens/Device/__test__/detail.test.js +4 -4
  71. package/src/screens/Device/detail.js +44 -6
  72. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -2
  73. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +14 -0
  74. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +19 -1
  75. package/src/screens/EmergencySetting/index.js +4 -1
  76. package/src/screens/Explore/index.js +2 -0
  77. package/src/screens/GuestInfo/__test__/index.test.js +1 -1
  78. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  79. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  80. package/src/screens/ManageAccess/index.js +1 -0
  81. package/src/screens/MoveToAnotherSubUnit/index.js +1 -1
  82. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  83. package/src/screens/ScriptDetail/index.js +3 -3
  84. package/src/screens/SelectUnit/__test__/index.test.js +1 -1
  85. package/src/screens/SelectUnit/index.js +5 -2
  86. package/src/screens/SetSchedule/index.js +6 -2
  87. package/src/screens/SharedUnit/index.js +2 -0
  88. package/src/screens/Sharing/MemberList.js +12 -11
  89. package/src/screens/Sharing/SelectPermission.js +1 -1
  90. package/src/screens/Sharing/hooks/index.js +3 -0
  91. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  92. package/src/screens/SideMenuDetail/__test__/index.test.js +165 -0
  93. package/src/screens/SideMenuDetail/index.js +149 -0
  94. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  95. package/src/screens/SubUnit/ManageSubUnit.js +1 -0
  96. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  97. package/src/screens/TDSGuide/index.js +4 -1
  98. package/src/screens/UVIndexGuide/index.js +1 -1
  99. package/src/screens/Unit/Detail.js +18 -5
  100. package/src/screens/Unit/SelectAddress.js +4 -1
  101. package/src/screens/Unit/Station/index.js +1 -0
  102. package/src/screens/Unit/Summaries.js +1 -1
  103. package/src/screens/Unit/__test__/Detail.test.js +25 -5
  104. package/src/screens/UnitSummary/__test__/index.test.js +32 -0
  105. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +1 -1
  106. package/src/screens/WaterQualityGuide/index.js +1 -1
  107. package/src/utils/I18n/translations/en.json +5 -1
  108. package/src/utils/I18n/translations/vi.json +5 -1
  109. package/src/utils/Route/index.js +1 -0
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+ import axios from 'axios';
3
+ import { act, create } from 'react-test-renderer';
4
+ import { TESTID } from '../../../../configs/Constants';
5
+ import { mockSCStore } from '../../../../context/mockStore';
6
+ import { SCProvider } from '../../../../context';
7
+ import ChooseUserField from '../index';
8
+ import { TouchableOpacity } from 'react-native';
9
+ import { ModalCustom } from '../../../Modal';
10
+
11
+ jest.mock('axios');
12
+
13
+ const wrapComponent = (
14
+ unit = { id: 1 },
15
+ dataItem = {
16
+ type: 'choose_user',
17
+ key: 'user_id',
18
+ action: {
19
+ type: 'action_zigbee',
20
+ id: 1,
21
+ },
22
+ },
23
+ index = 0,
24
+ setDataForm,
25
+ dataForm = [
26
+ {
27
+ type: 'choose_user',
28
+ key: 'user_id',
29
+ action: {
30
+ type: 'action_zigbee',
31
+ id: 1,
32
+ },
33
+ },
34
+ ]
35
+ ) => (
36
+ <SCProvider initState={mockSCStore({})}>
37
+ <ChooseUserField
38
+ unit={unit}
39
+ dataItem={dataItem}
40
+ index={index}
41
+ setDataForm={jest.fn()}
42
+ dataForm={dataForm}
43
+ />
44
+ </SCProvider>
45
+ );
46
+
47
+ describe('Test ChooseUserField', () => {
48
+ let tree;
49
+
50
+ afterEach(() => {
51
+ axios.get.mockClear();
52
+ });
53
+
54
+ const onPressCancel = async (instance, popup) => {
55
+ const buttonCancel = instance.find(
56
+ (el) =>
57
+ el.props.testID ===
58
+ TESTID.CHOOSE_POPUP + TESTID.BOTTOM_VIEW_SECONDARY &&
59
+ el.type === TouchableOpacity
60
+ );
61
+
62
+ await act(async () => {
63
+ await buttonCancel.props.onPress();
64
+ });
65
+ expect(popup.props.isVisible).toBeFalsy();
66
+ };
67
+
68
+ const onPressApply = async (instance, popup) => {
69
+ const buttonApply = instance.find(
70
+ (el) =>
71
+ el.props.testID === TESTID.CHOOSE_POPUP + TESTID.BOTTOM_VIEW_MAIN &&
72
+ el.type === TouchableOpacity
73
+ );
74
+
75
+ await act(async () => {
76
+ await buttonApply.props.onPress();
77
+ });
78
+ expect(popup.props.isVisible).toBeFalsy();
79
+ };
80
+
81
+ test('render ChooseUserField handleOnApply', async () => {
82
+ const response_unit_members = {
83
+ status: 200,
84
+ data: [{ id: 1, name: 'Ken' }],
85
+ };
86
+
87
+ axios.get.mockImplementation(() => {
88
+ return response_unit_members;
89
+ });
90
+ await act(async () => {
91
+ tree = create(wrapComponent());
92
+ });
93
+
94
+ const instance = tree.root;
95
+
96
+ const ChooseField = instance.find(
97
+ (item) =>
98
+ item.props.testID === TESTID.CHOOSE_FIELD &&
99
+ item.type === TouchableOpacity
100
+ );
101
+ await act(async () => {
102
+ await ChooseField.props.onPress();
103
+ });
104
+
105
+ const popup = instance.find(
106
+ (item) =>
107
+ item.props.testID === TESTID.CHOOSE_POPUP && item.type === ModalCustom
108
+ );
109
+ expect(popup.props.isVisible).toBeTruthy();
110
+ await onPressCancel(instance, popup);
111
+ await onPressApply(instance, popup);
112
+ });
113
+ });
@@ -0,0 +1,62 @@
1
+ import React, { memo, useEffect, useState } from 'react';
2
+ import { IconOutline } from '@ant-design/icons-react-native';
3
+ import { TouchableOpacity, View } from 'react-native';
4
+
5
+ import styles from './ChooseFieldStyles';
6
+ import ChoosePopup from './ChoosePopup';
7
+ import { useBoolean } from '../../../hooks/Common';
8
+ import { axiosGet } from '../../../utils/Apis/axios';
9
+ import { API, Colors } from '../../../configs';
10
+ import { TESTID } from '../../../configs/Constants';
11
+ import Text from '../../Text';
12
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
13
+
14
+ const ChooseUserField = ({ unit, dataItem, index, setDataForm, dataForm }) => {
15
+ const [showFilterPopup, setShowFilterPopup, setHideFilterPopup] =
16
+ useBoolean();
17
+ const [choose, setChoose] = useState({});
18
+ const [members, setMembers] = useState([]);
19
+ const t = useTranslations();
20
+ const fetchMembers = async () => {
21
+ const { success, data } = await axiosGet(API.SHARE.UNITS_MEMBERS(unit.id));
22
+ if (success) {
23
+ setMembers(data);
24
+ }
25
+ };
26
+
27
+ useEffect(() => {
28
+ if (!members.length) {
29
+ fetchMembers();
30
+ return;
31
+ }
32
+
33
+ dataItem.data = choose.id;
34
+ dataItem.valid = true;
35
+ dataItem[dataItem.action.type] = dataItem.action.id;
36
+ dataForm[index] = dataItem;
37
+ setDataForm([...dataForm]);
38
+ // eslint-disable-next-line react-hooks/exhaustive-deps
39
+ }, [choose]);
40
+
41
+ return (
42
+ <View style={styles.wrapper}>
43
+ <Text style={styles.textHeadLine}>{t('choose_user')}</Text>
44
+ <TouchableOpacity
45
+ testID={TESTID.CHOOSE_FIELD}
46
+ style={styles.buttonValue}
47
+ onPress={setShowFilterPopup}
48
+ >
49
+ <Text style={styles.value}>{choose.name}</Text>
50
+ <IconOutline name="right" size={20} color={Colors.Gray8} />
51
+ </TouchableOpacity>
52
+ <ChoosePopup
53
+ isVisible={showFilterPopup}
54
+ onHide={setHideFilterPopup}
55
+ members={members}
56
+ title={t('choose_user')}
57
+ onApply={setChoose}
58
+ />
59
+ </View>
60
+ );
61
+ };
62
+ export default memo(ChooseUserField);
@@ -0,0 +1,30 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from '../../../configs';
3
+
4
+ export default StyleSheet.create({
5
+ wrapper: {
6
+ flexDirection: 'row',
7
+ justifyContent: 'space-between',
8
+ alignItems: 'center',
9
+ paddingTop: 30,
10
+ },
11
+ invalid: {
12
+ width: 90,
13
+ textAlign: 'center',
14
+ borderWidth: 0,
15
+ borderBottomWidth: 1,
16
+ borderBottomColor: Colors.Red,
17
+ },
18
+ valid: {
19
+ width: 90,
20
+ textAlign: 'center',
21
+ borderWidth: 0,
22
+ borderBottomWidth: 1,
23
+ borderBottomColor: Colors.Primary,
24
+ },
25
+ textHeadLine: {
26
+ fontSize: 16,
27
+ color: Colors.Gray9,
28
+ fontWeight: 'bold',
29
+ },
30
+ });
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import axios from 'axios';
3
+ import { act, create } from 'react-test-renderer';
4
+ import { TESTID } from '../../../../configs/Constants';
5
+ import { mockSCStore } from '../../../../context/mockStore';
6
+ import { SCProvider } from '../../../../context';
7
+ import PasscodeField from '../index';
8
+
9
+ jest.mock('axios');
10
+ const mockSetState = jest.fn();
11
+
12
+ const wrapComponent = (
13
+ dataItem = {
14
+ type: 'passcode',
15
+ key: 'passcode',
16
+ action: {
17
+ type: 'action_zigbee',
18
+ id: 1,
19
+ },
20
+ },
21
+ index = 0,
22
+ dataForm = [
23
+ {
24
+ type: 'passcode',
25
+ key: 'passcode',
26
+ action: {
27
+ type: 'action_zigbee',
28
+ id: 1,
29
+ },
30
+ },
31
+ ]
32
+ ) => (
33
+ <SCProvider initState={mockSCStore({})}>
34
+ <PasscodeField
35
+ dataItem={dataItem}
36
+ index={index}
37
+ setDataForm={mockSetState}
38
+ dataForm={dataForm}
39
+ />
40
+ </SCProvider>
41
+ );
42
+
43
+ describe('Test PasscodeField', () => {
44
+ let tree;
45
+
46
+ afterEach(() => {
47
+ axios.get.mockClear();
48
+ mockSetState.mockClear();
49
+ });
50
+
51
+ test('render PasscodeField', async () => {
52
+ await act(async () => {
53
+ tree = create(wrapComponent());
54
+ });
55
+
56
+ const instance = tree.root;
57
+ const inputPasscode = instance.find(
58
+ (item) => item.props.testID === TESTID.PASSCODE_FIELD
59
+ );
60
+
61
+ await act(async () => {
62
+ await inputPasscode.props.onChangeText('123');
63
+ });
64
+ expect(mockSetState).toBeCalledWith([
65
+ {
66
+ key: 'passcode',
67
+ type: 'passcode',
68
+ valid: false,
69
+ action: {
70
+ id: 1,
71
+ type: 'action_zigbee',
72
+ },
73
+ },
74
+ ]);
75
+
76
+ await act(async () => {
77
+ await inputPasscode.props.onChangeText('123456');
78
+ });
79
+ expect(mockSetState).toBeCalledWith([
80
+ {
81
+ key: 'passcode',
82
+ type: 'passcode',
83
+ data: '123456',
84
+ valid: true,
85
+ action: {
86
+ id: 1,
87
+ type: 'action_zigbee',
88
+ },
89
+ action_zigbee: 1,
90
+ },
91
+ ]);
92
+ });
93
+ });
@@ -0,0 +1,43 @@
1
+ import React, { memo, useCallback, useState } from 'react';
2
+ import { Text, TextInput, View } from 'react-native';
3
+ import { TESTID } from '../../../configs/Constants';
4
+
5
+ import styles from './PasscodeFieldStyles';
6
+
7
+ const PasscodeField = ({ dataItem, index, setDataForm, dataForm }) => {
8
+ const [invalid, setInvaild] = useState(false);
9
+ const onChangeText = useCallback(
10
+ (value) => {
11
+ if (value.length >= 4 && value.length <= 10) {
12
+ dataItem.data = value;
13
+ dataItem.valid = true;
14
+ dataItem[dataItem.action.type] = dataItem.action.id;
15
+ dataForm[index] = dataItem;
16
+ setInvaild(false);
17
+ setDataForm([...dataForm]);
18
+ } else {
19
+ dataItem.valid = false;
20
+ dataForm[index] = dataItem;
21
+ setInvaild(true);
22
+ setDataForm([...dataForm]);
23
+ }
24
+ },
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ []
27
+ );
28
+
29
+ return (
30
+ <View style={styles.wrapper}>
31
+ <Text style={styles.textHeadLine}>{'Passcode'}</Text>
32
+ <TextInput
33
+ testID={TESTID.PASSCODE_FIELD}
34
+ style={invalid ? styles.invalid : styles.valid}
35
+ placeholder={'******'}
36
+ keyboardType={'numeric'}
37
+ maxLength={10}
38
+ onChangeText={onChangeText}
39
+ />
40
+ </View>
41
+ );
42
+ };
43
+ export default memo(PasscodeField);
@@ -0,0 +1,13 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from '../../../configs';
3
+
4
+ export default StyleSheet.create({
5
+ wrapper: {
6
+ paddingTop: 30,
7
+ },
8
+ textHeadLine: {
9
+ fontSize: 16,
10
+ color: Colors.Gray9,
11
+ fontWeight: 'bold',
12
+ },
13
+ });
@@ -0,0 +1,182 @@
1
+ import React from 'react';
2
+ import axios from 'axios';
3
+ import { act, create } from 'react-test-renderer';
4
+ import { mockSCStore } from '../../../../context/mockStore';
5
+ import { SCProvider } from '../../../../context';
6
+ import ScheduleField from '../index';
7
+ import { TESTID } from '../../../../configs/Constants';
8
+ import { TouchableOpacity } from 'react-native';
9
+
10
+ jest.mock('axios');
11
+ const mockSetState = jest.fn();
12
+
13
+ const wrapComponent = (
14
+ dataItem = {
15
+ type: 'schedule',
16
+ key: 'schedule',
17
+ action: {
18
+ type: 'action_zigbee',
19
+ id: {
20
+ always: 2,
21
+ recurring: 4,
22
+ temporary: 5,
23
+ },
24
+ },
25
+ },
26
+ index = 0,
27
+ dataForm = [
28
+ {
29
+ type: 'schedule',
30
+ key: 'schedule',
31
+ action: {
32
+ type: 'action_zigbee',
33
+ id: {
34
+ always: 2,
35
+ recurring: 4,
36
+ temporary: 5,
37
+ },
38
+ },
39
+ },
40
+ ]
41
+ ) => (
42
+ <SCProvider initState={mockSCStore({})}>
43
+ <ScheduleField
44
+ dataItem={dataItem}
45
+ index={index}
46
+ setDataForm={mockSetState}
47
+ dataForm={dataForm}
48
+ />
49
+ </SCProvider>
50
+ );
51
+
52
+ describe('Test ScheduleField', () => {
53
+ let tree;
54
+ beforeEach(() => {
55
+ Date.now = jest.fn(() => new Date('2022-05-30T15:50:36+01:00'));
56
+ });
57
+ afterEach(() => {
58
+ axios.get.mockClear();
59
+ mockSetState.mockClear();
60
+ });
61
+
62
+ const onPressRecurring = async (instance, schedule) => {
63
+ await act(async () => {
64
+ await schedule.props.onPress();
65
+ });
66
+ const recurring = instance.find(
67
+ (el) =>
68
+ el.props.testID === '0' + TESTID.RECURRING_REPEAT_ITEM &&
69
+ el.type === TouchableOpacity
70
+ );
71
+ await act(async () => {
72
+ await recurring.props.onPress();
73
+ });
74
+ expect(mockSetState).toBeCalledWith([
75
+ {
76
+ key: 'schedule',
77
+ type: 'schedule',
78
+ data: {
79
+ access_schedule: 'recurring',
80
+ recurring_time_end: '2022-05-30T16:50:36+01:00',
81
+ recurring_time_repeat: ['6'],
82
+ recurring_time_start: '2022-05-30T15:50:36+01:00',
83
+ },
84
+ valid: true,
85
+ action: {
86
+ id: {
87
+ always: 2,
88
+ recurring: 4,
89
+ temporary: 5,
90
+ },
91
+ type: 'action_zigbee',
92
+ },
93
+ action_zigbee: 4,
94
+ },
95
+ ]);
96
+ mockSetState.mockClear();
97
+ };
98
+
99
+ const onPressTemporary = async (instance, schedule) => {
100
+ await act(async () => {
101
+ await schedule.props.onPress();
102
+ });
103
+
104
+ expect(mockSetState).toBeCalledWith([
105
+ {
106
+ key: 'schedule',
107
+ type: 'schedule',
108
+ data: {
109
+ access_schedule: 'temporary',
110
+ temporary_time_end: '2022-05-31T15:50:36+01:00',
111
+ temporary_time_start: '2022-05-30T15:50:36+01:00',
112
+ },
113
+ valid: true,
114
+ action: {
115
+ id: {
116
+ always: 2,
117
+ recurring: 4,
118
+ temporary: 5,
119
+ },
120
+ type: 'action_zigbee',
121
+ },
122
+ action_zigbee: 5,
123
+ },
124
+ ]);
125
+ const temporaryEnd = instance.find(
126
+ (el) =>
127
+ el.props.testID === TESTID.TEMPORARY_END_TEXT_BUTTON &&
128
+ el.type === TouchableOpacity
129
+ );
130
+ await act(async () => {
131
+ await temporaryEnd.props.onPress();
132
+ });
133
+ const dateTimePicker = instance.find(
134
+ (el) => el.props.testID === TESTID.WHEEL_DATE_TIME_PICKER
135
+ );
136
+ expect(dateTimePicker.props.isVisible).toBeTruthy();
137
+ const popupDateTimePickerDone = instance.find(
138
+ (el) =>
139
+ el.props.testID ===
140
+ `${TESTID.WHEEL_DATE_TIME_PICKER_BUTTON}${TESTID.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}` &&
141
+ el.type === TouchableOpacity
142
+ );
143
+ await act(async () => {
144
+ await popupDateTimePickerDone.props.onPress();
145
+ });
146
+ expect(dateTimePicker.props.isVisible).toBeFalsy();
147
+ mockSetState.mockClear();
148
+ };
149
+
150
+ test('render ScheduleField choose schedule', async () => {
151
+ await act(async () => {
152
+ tree = await create(wrapComponent());
153
+ });
154
+ expect(mockSetState).toBeCalledWith([
155
+ {
156
+ key: 'schedule',
157
+ type: 'schedule',
158
+ data: { access_schedule: 'always' },
159
+ valid: true,
160
+ action: {
161
+ id: {
162
+ always: 2,
163
+ recurring: 4,
164
+ temporary: 5,
165
+ },
166
+ type: 'action_zigbee',
167
+ },
168
+ action_zigbee: 2,
169
+ },
170
+ ]);
171
+ mockSetState.mockClear();
172
+ const instance = tree.root;
173
+ const schedule = instance.findAll(
174
+ (el) =>
175
+ el.props.testID === TESTID.ACCESS_SCHEDULE_RADIO_BUTTON &&
176
+ el.type === TouchableOpacity
177
+ );
178
+ expect(schedule).toHaveLength(3);
179
+ await onPressRecurring(instance, schedule[1]);
180
+ await onPressTemporary(instance, schedule[2]);
181
+ });
182
+ });