@eohjsc/react-native-smart-city 0.2.99 → 0.3.2
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 +1 -1
- package/package.json +6 -4
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +11 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -20
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- 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/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +0 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
- 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 +137 -2
- 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/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +72 -25
- 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/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +3 -3
- package/src/commons/Device/ItemDevice.js +15 -11
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +19 -14
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/index.js +2 -2
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +24 -55
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -1
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +2 -2
- package/src/configs/API.js +85 -144
- package/src/configs/Constants.js +24 -0
- package/src/configs/SCConfig.js +2 -0
- package/src/context/actionType.ts +8 -0
- package/src/context/mockStore.ts +10 -0
- package/src/context/reducer.ts +38 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- 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/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- 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 +5 -4
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- 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/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
- 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/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -23
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- 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 +3 -3
- 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/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +32 -85
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +53 -22
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +1 -1
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +18 -14
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +30 -31
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +13 -40
- package/src/screens/HanetCamera/Detail.js +1 -1
- 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/components/RequestFaceIDPopup.js +3 -2
- 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/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- 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/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +1 -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 +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +22 -6
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- 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 +16 -11
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SelectUnit/index.js +4 -2
- package/src/screens/SetSchedule/index.js +9 -9
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/SelectPermission.js +121 -76
- 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/SideMenuDetail/__test__/index.test.js +12 -23
- package/src/screens/SideMenuDetail/index.js +2 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/ManageSubUnit.js +12 -7
- 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/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +30 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +34 -21
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Summaries.js +17 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +99 -200
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +84 -51
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- 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/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +70 -41
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/utils/Apis/axios.js +46 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +4 -1
- package/src/utils/I18n/translations/vi.json +5 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Utils.js +11 -7
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import Text from '../../../commons/Text';
|
|
5
|
+
import { TESTID } from '../../../configs/Constants';
|
|
5
6
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
6
7
|
import NumberUpDownActionTemplate from '../NumberUpDownActionTemplate';
|
|
7
8
|
|
|
@@ -30,7 +31,7 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
30
31
|
watchMultiConfigs.mockClear();
|
|
31
32
|
actionGroup = {
|
|
32
33
|
configuration: {
|
|
33
|
-
|
|
34
|
+
allow_config_store_value: false,
|
|
34
35
|
config: 5,
|
|
35
36
|
action_data,
|
|
36
37
|
min_value: 16,
|
|
@@ -57,28 +58,10 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
57
58
|
|
|
58
59
|
const touchs = instance.findAllByType(TouchableOpacity);
|
|
59
60
|
expect(touchs).toHaveLength(2);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('do action call watchConfigs', async () => {
|
|
63
|
-
actionGroup.configuration.keep_track_config = true;
|
|
64
|
-
const mockDoAction = jest.fn();
|
|
65
|
-
await act(async () => {
|
|
66
|
-
wrapper = await create(
|
|
67
|
-
<NumberUpDownActionTemplate
|
|
68
|
-
actionGroup={actionGroup}
|
|
69
|
-
doAction={mockDoAction}
|
|
70
|
-
sensor={{ is_managed_by_backend: true }}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
const instance = wrapper.root;
|
|
75
|
-
const touchs = instance.findAllByType(TouchableOpacity);
|
|
76
|
-
expect(touchs).toHaveLength(2);
|
|
77
61
|
|
|
78
62
|
await act(async () => {
|
|
79
63
|
await touchs[0].props.onPress();
|
|
80
64
|
});
|
|
81
|
-
|
|
82
65
|
expect(watchMultiConfigs).toBeCalled();
|
|
83
66
|
});
|
|
84
67
|
|
|
@@ -104,8 +87,9 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
104
87
|
expect(watchMultiConfigs).not.toBeCalled();
|
|
105
88
|
});
|
|
106
89
|
|
|
107
|
-
test('do action
|
|
90
|
+
test('do action watchConfigs cause allow_config_store_value true', async () => {
|
|
108
91
|
const mockDoAction = jest.fn();
|
|
92
|
+
actionGroup.configuration.allow_config_store_value = true;
|
|
109
93
|
await act(async () => {
|
|
110
94
|
wrapper = await create(
|
|
111
95
|
<NumberUpDownActionTemplate
|
|
@@ -123,11 +107,11 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
123
107
|
await touchs[0].props.onPress();
|
|
124
108
|
});
|
|
125
109
|
|
|
126
|
-
expect(watchMultiConfigs).
|
|
110
|
+
expect(watchMultiConfigs).toBeCalled();
|
|
127
111
|
});
|
|
128
112
|
|
|
129
113
|
test('action down without config', async () => {
|
|
130
|
-
actionGroup.configuration.
|
|
114
|
+
actionGroup.configuration.allow_config_store_value = true;
|
|
131
115
|
actionGroup.configuration.config = undefined;
|
|
132
116
|
const mockDoAction = jest.fn();
|
|
133
117
|
await act(async () => {
|
|
@@ -150,8 +134,10 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
150
134
|
expect(watchMultiConfigs).not.toBeCalled();
|
|
151
135
|
});
|
|
152
136
|
|
|
153
|
-
test('action down
|
|
137
|
+
test('action down allow_config_store_value true', async () => {
|
|
154
138
|
const mockDoAction = jest.fn();
|
|
139
|
+
actionGroup.configuration.allow_config_store_value = true;
|
|
140
|
+
actionGroup.configuration.config = null;
|
|
155
141
|
await act(async () => {
|
|
156
142
|
wrapper = await create(
|
|
157
143
|
<NumberUpDownActionTemplate
|
|
@@ -162,19 +148,23 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
162
148
|
);
|
|
163
149
|
});
|
|
164
150
|
const instance = wrapper.root;
|
|
165
|
-
const touchs = instance.
|
|
166
|
-
|
|
167
|
-
|
|
151
|
+
const touchs = instance.find(
|
|
152
|
+
(el) =>
|
|
153
|
+
el.props.testID === TESTID.NUMBER_ACTION_DOWN &&
|
|
154
|
+
el.type === TouchableOpacity
|
|
155
|
+
);
|
|
168
156
|
await act(async () => {
|
|
169
|
-
await touchs
|
|
157
|
+
await touchs.props.onPress();
|
|
170
158
|
});
|
|
171
159
|
|
|
172
160
|
const text = instance.findByType(Text);
|
|
173
|
-
expect(text.props.children).toEqual('
|
|
161
|
+
expect(text.props.children).toEqual('27 *C');
|
|
174
162
|
});
|
|
175
163
|
|
|
176
|
-
test('action up
|
|
164
|
+
test('action up allow_config_store_value true', async () => {
|
|
177
165
|
const mockDoAction = jest.fn();
|
|
166
|
+
actionGroup.configuration.allow_config_store_value = true;
|
|
167
|
+
actionGroup.configuration.config = null;
|
|
178
168
|
await act(async () => {
|
|
179
169
|
wrapper = await create(
|
|
180
170
|
<NumberUpDownActionTemplate
|
|
@@ -185,19 +175,21 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
185
175
|
);
|
|
186
176
|
});
|
|
187
177
|
const instance = wrapper.root;
|
|
188
|
-
const touchs = instance.
|
|
189
|
-
|
|
190
|
-
|
|
178
|
+
const touchs = instance.find(
|
|
179
|
+
(el) =>
|
|
180
|
+
el.props.testID === TESTID.NUMBER_ACTION_UP &&
|
|
181
|
+
el.type === TouchableOpacity
|
|
182
|
+
);
|
|
191
183
|
await act(async () => {
|
|
192
|
-
await touchs
|
|
184
|
+
await touchs.props.onPress();
|
|
193
185
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
186
|
+
const text = instance.find(
|
|
187
|
+
(el) => el.props.testID === 'abcd' && el.type === Text
|
|
188
|
+
);
|
|
189
|
+
expect(text.props.children).toEqual('29 *C');
|
|
197
190
|
});
|
|
198
191
|
|
|
199
|
-
test('action down with
|
|
200
|
-
actionGroup.configuration.keep_track_config = true;
|
|
192
|
+
test('action down with allow_config_store_value false', async () => {
|
|
201
193
|
const mockDoAction = jest.fn();
|
|
202
194
|
await act(async () => {
|
|
203
195
|
wrapper = await create(
|
|
@@ -209,19 +201,21 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
209
201
|
);
|
|
210
202
|
});
|
|
211
203
|
const instance = wrapper.root;
|
|
212
|
-
const touchs = instance.
|
|
213
|
-
|
|
204
|
+
const touchs = instance.find(
|
|
205
|
+
(el) =>
|
|
206
|
+
el.props.testID === TESTID.NUMBER_ACTION_DOWN &&
|
|
207
|
+
el.type === TouchableOpacity
|
|
208
|
+
);
|
|
214
209
|
|
|
215
210
|
await act(async () => {
|
|
216
|
-
await touchs
|
|
211
|
+
await touchs.props.onPress();
|
|
217
212
|
});
|
|
218
213
|
|
|
219
214
|
const text = instance.findByType(Text);
|
|
220
|
-
expect(text.props.children).toEqual('
|
|
215
|
+
expect(text.props.children).toEqual('24 *C'); // TODO should 24, configValues make changes again
|
|
221
216
|
});
|
|
222
217
|
|
|
223
|
-
test('action up with
|
|
224
|
-
actionGroup.configuration.keep_track_config = true;
|
|
218
|
+
test('action up with allow_config_store_value false', async () => {
|
|
225
219
|
const mockDoAction = jest.fn();
|
|
226
220
|
await act(async () => {
|
|
227
221
|
wrapper = await create(
|
|
@@ -233,15 +227,18 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
233
227
|
);
|
|
234
228
|
});
|
|
235
229
|
const instance = wrapper.root;
|
|
236
|
-
const touchs = instance.
|
|
237
|
-
|
|
230
|
+
const touchs = instance.find(
|
|
231
|
+
(el) =>
|
|
232
|
+
el.props.testID === TESTID.NUMBER_ACTION_UP &&
|
|
233
|
+
el.type === TouchableOpacity
|
|
234
|
+
);
|
|
238
235
|
|
|
239
236
|
await act(async () => {
|
|
240
|
-
await touchs
|
|
237
|
+
await touchs.props.onPress();
|
|
241
238
|
});
|
|
242
239
|
|
|
243
240
|
const text = instance.findByType(Text);
|
|
244
|
-
expect(text.props.children).toEqual('
|
|
241
|
+
expect(text.props.children).toEqual('26 *C'); // TODO should 26, configValues make changes again
|
|
245
242
|
});
|
|
246
243
|
|
|
247
244
|
test('action down limit ', async () => {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import Text from '../../Text';
|
|
5
|
+
import StatesGridActionTemplate from '../StatesGridActionTemplate';
|
|
6
|
+
|
|
7
|
+
const mockDoAction = jest.fn();
|
|
8
|
+
const mockActionData = jest.fn();
|
|
9
|
+
|
|
10
|
+
describe('Test StatesGridActionTemplate', () => {
|
|
11
|
+
let tree;
|
|
12
|
+
const actionGroup = {
|
|
13
|
+
configuration: {
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
config: true,
|
|
17
|
+
active: false,
|
|
18
|
+
text: 'item 1',
|
|
19
|
+
icon_kit_data: 'icon_kit_data',
|
|
20
|
+
icon: '123',
|
|
21
|
+
icon_outlined: 'icon_outlined',
|
|
22
|
+
action_data: mockActionData,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
config: false,
|
|
26
|
+
active: true,
|
|
27
|
+
text: 'item 2',
|
|
28
|
+
icon_kit_data: 'icon_kit_data',
|
|
29
|
+
icon: 'icon',
|
|
30
|
+
icon_outlined: 'icon_outlined',
|
|
31
|
+
action_data: mockActionData,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
is_on_value: true,
|
|
35
|
+
},
|
|
36
|
+
title: 'Title',
|
|
37
|
+
};
|
|
38
|
+
const sensor = {
|
|
39
|
+
is_managed_by_backend: true,
|
|
40
|
+
device_type: '',
|
|
41
|
+
name: 'Sensor name',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
test('test render without params', async () => {
|
|
45
|
+
await act(async () => {
|
|
46
|
+
tree = await create(<StatesGridActionTemplate />);
|
|
47
|
+
});
|
|
48
|
+
const instance = tree.root;
|
|
49
|
+
const Texts = instance.findAllByType(Text);
|
|
50
|
+
expect(Texts).toHaveLength(1);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('test render with params', async () => {
|
|
54
|
+
await act(async () => {
|
|
55
|
+
tree = await create(
|
|
56
|
+
<StatesGridActionTemplate
|
|
57
|
+
doAction={mockDoAction}
|
|
58
|
+
sensor={sensor}
|
|
59
|
+
actionGroup={actionGroup}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
const instance = tree.root;
|
|
64
|
+
const Texts = instance.findAllByType(Text);
|
|
65
|
+
expect(Texts).toHaveLength(3);
|
|
66
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
67
|
+
expect(TouchableOpacities).toHaveLength(2);
|
|
68
|
+
await TouchableOpacities[0].props.onPress();
|
|
69
|
+
expect(mockDoAction).toBeCalledWith(
|
|
70
|
+
mockActionData,
|
|
71
|
+
null,
|
|
72
|
+
`${sensor.name} ${actionGroup.title.toLowerCase()} ${
|
|
73
|
+
actionGroup.configuration.options[0].text
|
|
74
|
+
}`
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Switch } from 'react-native';
|
|
2
|
+
import { Switch, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import TimerActionTemplate from '../TimerActionTemplate';
|
|
5
5
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
6
|
+
import ScrollPicker from 'react-native-wheel-scrollview-picker';
|
|
7
|
+
|
|
6
8
|
import moment from 'moment';
|
|
7
9
|
import Text from '../../Text';
|
|
8
10
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
@@ -15,12 +17,14 @@ jest.mock('../../../iot/states', () => ({
|
|
|
15
17
|
useConfigGlobalState: () => [{ 5: 18, 6: 30 }, null],
|
|
16
18
|
}));
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const mockDoAction = jest.fn();
|
|
21
|
+
|
|
22
|
+
const wrapComponent = (actionGroup, sensor) => (
|
|
19
23
|
<SCProvider initState={mockSCStore({})}>
|
|
20
24
|
<TimerActionTemplate
|
|
21
25
|
actionGroup={actionGroup}
|
|
22
26
|
doAction={mockDoAction}
|
|
23
|
-
sensor={
|
|
27
|
+
sensor={sensor}
|
|
24
28
|
/>
|
|
25
29
|
</SCProvider>
|
|
26
30
|
);
|
|
@@ -39,6 +43,7 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
39
43
|
|
|
40
44
|
let actionGroup;
|
|
41
45
|
let wrapper;
|
|
46
|
+
let sensor;
|
|
42
47
|
|
|
43
48
|
beforeEach(() => {
|
|
44
49
|
watchMultiConfigs.mockClear();
|
|
@@ -50,12 +55,24 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
50
55
|
config_minute: 6,
|
|
51
56
|
},
|
|
52
57
|
};
|
|
58
|
+
sensor = {
|
|
59
|
+
is_managed_by_backend: true,
|
|
60
|
+
device_type: '',
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('render without params', async () => {
|
|
65
|
+
await act(async () => {
|
|
66
|
+
wrapper = await create(wrapComponent());
|
|
67
|
+
});
|
|
68
|
+
const instance = wrapper.root;
|
|
69
|
+
const texts = instance.findAllByType(Text);
|
|
70
|
+
expect(texts).toHaveLength(6);
|
|
53
71
|
});
|
|
54
72
|
|
|
55
73
|
test('render template', async () => {
|
|
56
|
-
const mockDoAction = jest.fn();
|
|
57
74
|
await act(async () => {
|
|
58
|
-
wrapper = await create(wrapComponent(actionGroup,
|
|
75
|
+
wrapper = await create(wrapComponent(actionGroup, sensor));
|
|
59
76
|
});
|
|
60
77
|
const instance = wrapper.root;
|
|
61
78
|
|
|
@@ -66,11 +83,46 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
66
83
|
|
|
67
84
|
const switchButton = instance.findByType(Switch);
|
|
68
85
|
expect(switchButton.props.value).toBeTruthy();
|
|
86
|
+
await switchButton.props.onValueChange();
|
|
87
|
+
expect(mockDoAction).toBeCalled();
|
|
88
|
+
|
|
89
|
+
const bottomScrollPicker = instance.findByType(ScrollPicker);
|
|
90
|
+
expect(bottomScrollPicker).toBeDefined();
|
|
91
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
92
|
+
await TouchableOpacities[0].props.onPress();
|
|
69
93
|
|
|
70
94
|
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
71
|
-
expect(dateTimePicker.props.isVisible).
|
|
95
|
+
expect(dateTimePicker.props.isVisible).toBeTruthy();
|
|
72
96
|
expect(dateTimePicker.props.date).toEqual(
|
|
73
97
|
moment('18:30', 'HH:mm').valueOf()
|
|
74
98
|
);
|
|
75
99
|
});
|
|
100
|
+
|
|
101
|
+
test('render template with config_hour', async () => {
|
|
102
|
+
actionGroup = {
|
|
103
|
+
...actionGroup,
|
|
104
|
+
configuration: {
|
|
105
|
+
...actionGroup.configuration,
|
|
106
|
+
config_hour: 5,
|
|
107
|
+
config_minute: null,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
await act(async () => {
|
|
111
|
+
wrapper = await create(wrapComponent(actionGroup, sensor));
|
|
112
|
+
});
|
|
113
|
+
const instance = wrapper.root;
|
|
114
|
+
|
|
115
|
+
const bottomScrollPicker = instance.findByType(ScrollPicker);
|
|
116
|
+
expect(bottomScrollPicker).toBeDefined();
|
|
117
|
+
|
|
118
|
+
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
119
|
+
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
120
|
+
await dateTimePicker.props.onConfirm();
|
|
121
|
+
|
|
122
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
123
|
+
expect(TouchableOpacities).toHaveLength(3);
|
|
124
|
+
await TouchableOpacities[0].props.onPress();
|
|
125
|
+
await TouchableOpacities[2].props.onPress(3);
|
|
126
|
+
expect(mockDoAction).toBeCalled();
|
|
127
|
+
});
|
|
76
128
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
4
5
|
import TwoButtonTemplate from '../TwoButtonTemplate';
|
|
5
6
|
|
|
6
7
|
jest.mock('react', () => ({
|
|
@@ -31,6 +32,10 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
31
32
|
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
32
33
|
};
|
|
33
34
|
|
|
35
|
+
const sensor = {
|
|
36
|
+
device_type: DEVICE_TYPE.LG_THINQ,
|
|
37
|
+
is_managed_by_backend: true,
|
|
38
|
+
};
|
|
34
39
|
const actionGroup = {
|
|
35
40
|
configuration: {
|
|
36
41
|
button1: {
|
|
@@ -41,6 +46,9 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
41
46
|
icon_on: 'poweroff',
|
|
42
47
|
text_on: 'ON',
|
|
43
48
|
config: 621,
|
|
49
|
+
is_on_value: [true],
|
|
50
|
+
action_on_data,
|
|
51
|
+
action_off_data,
|
|
44
52
|
},
|
|
45
53
|
button2: {
|
|
46
54
|
action_off: 'f49e1577-493d-4bae-a9ab-3b0f96a4ec52',
|
|
@@ -50,6 +58,9 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
50
58
|
icon_on: 'caret-right',
|
|
51
59
|
text_on: 'START',
|
|
52
60
|
config: 621,
|
|
61
|
+
is_on_value: [true],
|
|
62
|
+
action_on_data,
|
|
63
|
+
action_off_data,
|
|
53
64
|
},
|
|
54
65
|
},
|
|
55
66
|
};
|
|
@@ -102,7 +113,44 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
102
113
|
const mockDoAction = jest.fn();
|
|
103
114
|
await act(() => {
|
|
104
115
|
wrapper = create(
|
|
105
|
-
<TwoButtonTemplate
|
|
116
|
+
<TwoButtonTemplate
|
|
117
|
+
actionGroup={actionGroup}
|
|
118
|
+
doAction={mockDoAction}
|
|
119
|
+
sensor={sensor}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
const instance = wrapper.root;
|
|
124
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
125
|
+
expect(touchableOpacities.length).toEqual(2);
|
|
126
|
+
await touchableOpacities[0].props.onPress();
|
|
127
|
+
await touchableOpacities[1].props.onPress();
|
|
128
|
+
expect(mockDoAction).toBeCalled();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('render TouchableOpacity TwoButtonTemplate without is_on_value', async () => {
|
|
132
|
+
const mockDoAction = jest.fn();
|
|
133
|
+
let new_actionGroup = {
|
|
134
|
+
...actionGroup,
|
|
135
|
+
configuration: {
|
|
136
|
+
...actionGroup.configuration,
|
|
137
|
+
button1: {
|
|
138
|
+
...actionGroup.configuration.button1,
|
|
139
|
+
is_on_value: null,
|
|
140
|
+
},
|
|
141
|
+
button2: {
|
|
142
|
+
...actionGroup.configuration.button2,
|
|
143
|
+
is_on_value: null,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
await act(() => {
|
|
148
|
+
wrapper = create(
|
|
149
|
+
<TwoButtonTemplate
|
|
150
|
+
actionGroup={new_actionGroup}
|
|
151
|
+
doAction={mockDoAction}
|
|
152
|
+
sensor={sensor}
|
|
153
|
+
/>
|
|
106
154
|
);
|
|
107
155
|
});
|
|
108
156
|
const instance = wrapper.root;
|
|
@@ -356,8 +356,8 @@ describe('Test ActionGroup', () => {
|
|
|
356
356
|
text_format: '{number} *C',
|
|
357
357
|
},
|
|
358
358
|
};
|
|
359
|
-
await act(() => {
|
|
360
|
-
wrapper = renderer.create(
|
|
359
|
+
await act(async () => {
|
|
360
|
+
wrapper = await renderer.create(
|
|
361
361
|
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
362
362
|
);
|
|
363
363
|
});
|
|
@@ -464,4 +464,139 @@ describe('Test ActionGroup', () => {
|
|
|
464
464
|
moment('2021-09-09T10:00:00.000Z').valueOf()
|
|
465
465
|
);
|
|
466
466
|
});
|
|
467
|
+
|
|
468
|
+
test('render OnOffSmartLock', async () => {
|
|
469
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
470
|
+
const actionGroup = {
|
|
471
|
+
template: 'OnOffSmartLockActionTemplate',
|
|
472
|
+
title: 'Timer',
|
|
473
|
+
configuration: {
|
|
474
|
+
action_off_data: jest.fn(),
|
|
475
|
+
action_on_data: jest.fn(),
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
const mockDoAction = jest.fn();
|
|
479
|
+
await act(() => {
|
|
480
|
+
wrapper = renderer.create(
|
|
481
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
482
|
+
);
|
|
483
|
+
});
|
|
484
|
+
const instance = wrapper.root;
|
|
485
|
+
const texts = instance.findAllByType(Text);
|
|
486
|
+
expect(texts).toHaveLength(5);
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test('render OptionsDropdownActionTemplate', async () => {
|
|
490
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
491
|
+
const actionGroup = {
|
|
492
|
+
template: 'OptionsDropdownActionTemplate',
|
|
493
|
+
title: 'Timer',
|
|
494
|
+
configuration: {
|
|
495
|
+
action_data: jest.fn(),
|
|
496
|
+
options: [],
|
|
497
|
+
icon_kit_data: 'icon_kit_data',
|
|
498
|
+
icon: '',
|
|
499
|
+
icon_outlined: 'icon_outlined',
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
const mockDoAction = jest.fn();
|
|
503
|
+
await act(() => {
|
|
504
|
+
wrapper = renderer.create(
|
|
505
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
506
|
+
);
|
|
507
|
+
});
|
|
508
|
+
const instance = wrapper.root;
|
|
509
|
+
const texts = instance.findAllByType(Text);
|
|
510
|
+
expect(texts).toHaveLength(7);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
test('render CurtainButtonTemplate', async () => {
|
|
514
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
515
|
+
const actionGroup = {
|
|
516
|
+
template: 'curtain_action_template',
|
|
517
|
+
title: 'Timer',
|
|
518
|
+
configuration: {},
|
|
519
|
+
};
|
|
520
|
+
const mockDoAction = jest.fn();
|
|
521
|
+
await act(() => {
|
|
522
|
+
wrapper = renderer.create(
|
|
523
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
const instance = wrapper.root;
|
|
527
|
+
const texts = instance.findAllByType(Text);
|
|
528
|
+
expect(texts).toHaveLength(2);
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
test('render SmartTiviActionTemplate', async () => {
|
|
532
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
533
|
+
const actionGroup = {
|
|
534
|
+
template: 'SmartTiviActionTemplate',
|
|
535
|
+
title: 'Timer',
|
|
536
|
+
configuration: {},
|
|
537
|
+
};
|
|
538
|
+
const mockDoAction = jest.fn();
|
|
539
|
+
await act(() => {
|
|
540
|
+
wrapper = renderer.create(
|
|
541
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
542
|
+
);
|
|
543
|
+
});
|
|
544
|
+
const instance = wrapper.root;
|
|
545
|
+
const texts = instance.findAllByType(Text);
|
|
546
|
+
expect(texts).toHaveLength(4);
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
test('render ColorPickerTemplate', async () => {
|
|
550
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
551
|
+
const actionGroup = {
|
|
552
|
+
template: 'color_picker_template',
|
|
553
|
+
title: 'Timer',
|
|
554
|
+
configuration: {},
|
|
555
|
+
};
|
|
556
|
+
const mockDoAction = jest.fn();
|
|
557
|
+
await act(() => {
|
|
558
|
+
wrapper = renderer.create(
|
|
559
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
560
|
+
);
|
|
561
|
+
});
|
|
562
|
+
const instance = wrapper.root;
|
|
563
|
+
const texts = instance.findAllByType(Text);
|
|
564
|
+
expect(texts).toHaveLength(2);
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
test('render SliderRangeTemplate', async () => {
|
|
568
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
569
|
+
const actionGroup = {
|
|
570
|
+
template: 'slider_range_template',
|
|
571
|
+
title: 'Timer',
|
|
572
|
+
configuration: {},
|
|
573
|
+
};
|
|
574
|
+
const mockDoAction = jest.fn();
|
|
575
|
+
await act(() => {
|
|
576
|
+
wrapper = renderer.create(
|
|
577
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
578
|
+
);
|
|
579
|
+
});
|
|
580
|
+
const instance = wrapper.root;
|
|
581
|
+
const texts = instance.findAllByType(Text);
|
|
582
|
+
expect(texts).toHaveLength(4);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
test('render TwoButtonTemplate', async () => {
|
|
586
|
+
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
587
|
+
const actionGroup = {
|
|
588
|
+
template: 'two_button_action_template',
|
|
589
|
+
title: 'Timer',
|
|
590
|
+
configuration: {},
|
|
591
|
+
};
|
|
592
|
+
const mockDoAction = jest.fn();
|
|
593
|
+
await act(() => {
|
|
594
|
+
wrapper = renderer.create(
|
|
595
|
+
wrapComponent(actionGroup, mockDoAction, sensor)
|
|
596
|
+
);
|
|
597
|
+
});
|
|
598
|
+
const instance = wrapper.root;
|
|
599
|
+
const texts = instance.findAllByType(Text);
|
|
600
|
+
expect(texts).toHaveLength(5);
|
|
601
|
+
});
|
|
467
602
|
});
|
|
@@ -35,9 +35,7 @@ const ItemAutomate = ({
|
|
|
35
35
|
style={[styles.wrap, isSelected && styles.active]}
|
|
36
36
|
>
|
|
37
37
|
<View style={styles.row}>
|
|
38
|
-
<View style={styles.wrapIcon}>
|
|
39
|
-
<Icon />
|
|
40
|
-
</View>
|
|
38
|
+
<View style={styles.wrapIcon}>{!!Icon && <Icon />}</View>
|
|
41
39
|
<View style={styles.wrapTitle}>
|
|
42
40
|
<Text type="H4" bold>
|
|
43
41
|
{t(item?.title)}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import CalendarComponent from '../';
|
|
4
|
+
import { Calendar } from 'react-native-calendars';
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
6
|
+
import BottomSheet from '../../BottomSheet';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
|
|
10
|
+
const mockSetState = jest.fn();
|
|
11
|
+
jest.mock('react', () => {
|
|
12
|
+
return {
|
|
13
|
+
...jest.requireActual('react'),
|
|
14
|
+
useState: jest.fn((init) => [init, mockSetState]),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
const wrapComponent = (route, navigation) => (
|
|
18
|
+
<SCProvider initState={mockSCStore({})}>
|
|
19
|
+
<CalendarComponent route={route} />
|
|
20
|
+
</SCProvider>
|
|
21
|
+
);
|
|
22
|
+
describe('Test Calendar component', () => {
|
|
23
|
+
let tree;
|
|
24
|
+
|
|
25
|
+
test('create Calendar', () => {
|
|
26
|
+
act(() => {
|
|
27
|
+
tree = renderer.create(wrapComponent());
|
|
28
|
+
});
|
|
29
|
+
const instance = tree.root;
|
|
30
|
+
const calendar = instance.findAllByType(Calendar);
|
|
31
|
+
expect(calendar).toHaveLength(1);
|
|
32
|
+
});
|
|
33
|
+
});
|