@eohjsc/react-native-smart-city 0.2.99 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- 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/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +135 -0
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/index.js +1 -1
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/LinearChart.js +15 -0
- 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/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/configs/API.js +85 -139
- package/src/configs/Constants.js +11 -0
- package/src/configs/SCConfig.js +2 -0
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +8 -30
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- 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/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/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/__test__/detail.test.js +22 -83
- package/src/screens/Device/detail.js +4 -6
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +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/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +13 -40
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +4 -4
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +4 -3
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +19 -3
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +2 -1
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/SelectPermission.js +107 -70
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/SideMenuDetail/__test__/index.test.js +10 -21
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +47 -44
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +15 -28
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +83 -185
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +13 -39
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/UnitSummary/__test__/index.test.js +18 -43
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/utils/Apis/axios.js +37 -13
- package/src/utils/Utils.js +6 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@types/react": "^17.0.0",
|
|
75
75
|
"@types/react-native": "^0.63.43",
|
|
76
76
|
"@types/react-test-renderer": "^17.0.0",
|
|
77
|
+
"axios-mock-adapter": "^1.21.1",
|
|
77
78
|
"babel-jest": "^26.6.3",
|
|
78
79
|
"detox": "^18.3.1",
|
|
79
80
|
"eslint": "7.14.0",
|
|
@@ -124,6 +125,7 @@
|
|
|
124
125
|
"@react-navigation/stack": "^5.7.0",
|
|
125
126
|
"@sentry/react-native": "^1.7.1",
|
|
126
127
|
"@testing-library/react-hooks": "^6.0.0",
|
|
128
|
+
"apisauce": "^2.1.5",
|
|
127
129
|
"axios": "^0.19.2",
|
|
128
130
|
"dotenv": "^8.2.0",
|
|
129
131
|
"google-libphonenumber": "^3.2.10",
|
|
@@ -17,6 +17,11 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
17
17
|
close_action_data,
|
|
18
18
|
action_off_data,
|
|
19
19
|
action_on_data,
|
|
20
|
+
is_display_lock,
|
|
21
|
+
text1,
|
|
22
|
+
text2,
|
|
23
|
+
text3,
|
|
24
|
+
text_door_lock,
|
|
20
25
|
} = configuration || {};
|
|
21
26
|
const [lock, setLock] = useState(false);
|
|
22
27
|
|
|
@@ -52,21 +57,21 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
52
57
|
{
|
|
53
58
|
style: styles.buttonActionCurtain,
|
|
54
59
|
icon: Images.buttonLeftCurtain,
|
|
55
|
-
text:
|
|
60
|
+
text: text1,
|
|
56
61
|
onPress: onButtonOpenPress,
|
|
57
62
|
testID: TESTID.BUTTON_TEMPLATE_1,
|
|
58
63
|
},
|
|
59
64
|
{
|
|
60
65
|
style: styles.buttonActionCurtainCenter,
|
|
61
66
|
icon: Images.buttonPauseCurtain,
|
|
62
|
-
text:
|
|
67
|
+
text: text2,
|
|
63
68
|
onPress: onButtonStopPress,
|
|
64
69
|
testID: TESTID.BUTTON_TEMPLATE_2,
|
|
65
70
|
},
|
|
66
71
|
{
|
|
67
72
|
style: styles.buttonActionCurtain,
|
|
68
73
|
icon: Images.buttonRightCurtain,
|
|
69
|
-
text:
|
|
74
|
+
text: text3,
|
|
70
75
|
onPress: onButtonClosePress,
|
|
71
76
|
testID: TESTID.BUTTON_TEMPLATE_3,
|
|
72
77
|
},
|
|
@@ -96,7 +101,7 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
96
101
|
style={styles.textLockDoor}
|
|
97
102
|
testID={TESTID.TEXT_DOOR_LOOK_ON_OFF}
|
|
98
103
|
>
|
|
99
|
-
{
|
|
104
|
+
{text_door_lock}{' '}
|
|
100
105
|
</Text>
|
|
101
106
|
</View>
|
|
102
107
|
<Switch
|
|
@@ -115,7 +120,7 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
115
120
|
<RenderThreeButtonActions />
|
|
116
121
|
</View>
|
|
117
122
|
<View style={styles.lockSwitch}>
|
|
118
|
-
{
|
|
123
|
+
{is_display_lock &&
|
|
119
124
|
itemLock(
|
|
120
125
|
lock ? 'lock' : 'unlock',
|
|
121
126
|
lock ? Colors.Primary : Colors.Gray6
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import { Switch } from 'react-native';
|
|
3
4
|
|
|
4
5
|
import AutoLock from '../index';
|
|
5
6
|
import { mockSCStore } from '../../../../../context/mockStore';
|
|
@@ -38,6 +39,9 @@ describe('Test AutoLock', () => {
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
const instance = tree.root;
|
|
42
|
+
const switchs = instance.findByType(Switch);
|
|
43
|
+
await switchs.props.onValueChange();
|
|
44
|
+
|
|
41
45
|
const { buttonEnable, buttonInstant, buttonRelockTiming } =
|
|
42
46
|
getElement(instance);
|
|
43
47
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import { SCProvider } from '../../../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../../../context/mockStore';
|
|
6
|
+
import ItemPasscode from '../ItemPasscode';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = (route = {}) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ItemPasscode route={route} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
describe('Test ItemPasscode', () => {
|
|
15
|
+
let tree;
|
|
16
|
+
test('test render without params', async () => {
|
|
17
|
+
await act(async () => {
|
|
18
|
+
tree = await create(wrapComponent());
|
|
19
|
+
});
|
|
20
|
+
const instance = tree.root;
|
|
21
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
22
|
+
expect(TouchableOpacities).toHaveLength(2);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -40,6 +40,7 @@ describe('Test SetupGeneratePasscode', () => {
|
|
|
40
40
|
const changeDuration = instance.findAll(
|
|
41
41
|
(item) => item.props.testID === TESTID.GENERATE_PASSCODE_SET_DURATION
|
|
42
42
|
);
|
|
43
|
+
|
|
43
44
|
return {
|
|
44
45
|
changeName,
|
|
45
46
|
changeTime,
|
|
@@ -58,5 +59,18 @@ describe('Test SetupGeneratePasscode', () => {
|
|
|
58
59
|
expect(changeName[0]).toBeDefined();
|
|
59
60
|
expect(changeTime[0]).toBeDefined();
|
|
60
61
|
expect(changeDuration[0]).toBeDefined();
|
|
62
|
+
|
|
63
|
+
await changeDuration[0].props.onPressSetMinute();
|
|
64
|
+
await changeDuration[0].props.onPressSelectCircle();
|
|
65
|
+
await changeTime[0].props.onPressSetTime();
|
|
66
|
+
|
|
67
|
+
const wheelDateTimePicker = instance.findAll(
|
|
68
|
+
(item) =>
|
|
69
|
+
item.props.testID ===
|
|
70
|
+
`${TESTID.WHEEL_DATE_TIME_PICKER_BUTTON}${TESTID.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
|
|
71
|
+
);
|
|
72
|
+
await wheelDateTimePicker[5].props.onClick();
|
|
73
|
+
await wheelDateTimePicker[11].props.onClick();
|
|
74
|
+
await wheelDateTimePicker[17].props.onClick();
|
|
61
75
|
});
|
|
62
76
|
});
|
|
@@ -92,7 +92,7 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
92
92
|
return t('not_available');
|
|
93
93
|
}
|
|
94
94
|
return selectedOption.text;
|
|
95
|
-
}, [configuration
|
|
95
|
+
}, [configuration?.config, selectedOption?.text, t]);
|
|
96
96
|
|
|
97
97
|
const iconSvg = useMemo(() => {
|
|
98
98
|
switch (icon) {
|
|
@@ -105,15 +105,19 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
|
|
|
105
105
|
);
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
const StatesGridActionTemplate = ({
|
|
109
|
-
|
|
108
|
+
const StatesGridActionTemplate = ({
|
|
109
|
+
actionGroup = {},
|
|
110
|
+
doAction,
|
|
111
|
+
sensor = {},
|
|
112
|
+
}) => {
|
|
113
|
+
const { configuration = {}, title } = actionGroup;
|
|
110
114
|
|
|
111
115
|
// eslint-disable-next-line no-unused-vars
|
|
112
116
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
113
117
|
|
|
114
118
|
const options = useMemo(() => {
|
|
115
|
-
return configuration
|
|
116
|
-
if (configValues[option
|
|
119
|
+
return (configuration?.options || []).map((option) => {
|
|
120
|
+
if (configValues[option?.config] === option?.is_on_value) {
|
|
117
121
|
return {
|
|
118
122
|
...option,
|
|
119
123
|
active: true,
|
|
@@ -14,9 +14,9 @@ import { Colors } from '../../configs';
|
|
|
14
14
|
import { useConfigGlobalState } from '../../iot/states';
|
|
15
15
|
import BottomScrollPicker from '../BottomScrollPicker';
|
|
16
16
|
|
|
17
|
-
const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
17
|
+
const TimerActionTemplate = ({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
18
18
|
const t = useTranslations();
|
|
19
|
-
const { configuration, title } = actionGroup;
|
|
19
|
+
const { configuration = {}, title } = actionGroup;
|
|
20
20
|
const [showTime, setShowTime] = useState(false);
|
|
21
21
|
const [showHour, setShowHour] = useState(false);
|
|
22
22
|
|
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { TouchableOpacity, Switch } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import CurtainButtonTemplate from '../CurtainButtonTemplate';
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const mockDoAction = jest.fn();
|
|
10
|
+
const mockActionOffData = jest.fn();
|
|
11
|
+
const mockActionOnData = jest.fn();
|
|
12
|
+
const mockCloseActionData = jest.fn();
|
|
13
|
+
|
|
14
|
+
const wrapComponent = (actionGroup = {}, sensor = {}) => (
|
|
10
15
|
<SCProvider initState={mockSCStore({})}>
|
|
11
|
-
<CurtainButtonTemplate
|
|
16
|
+
<CurtainButtonTemplate
|
|
17
|
+
actionGroup={actionGroup}
|
|
18
|
+
doAction={mockDoAction}
|
|
19
|
+
sensor={sensor}
|
|
20
|
+
/>
|
|
12
21
|
</SCProvider>
|
|
13
22
|
);
|
|
14
23
|
|
|
15
24
|
describe('Test CurtainButtonTemplate', () => {
|
|
25
|
+
const sensor = {
|
|
26
|
+
name: 'test',
|
|
27
|
+
};
|
|
16
28
|
const actionGroup = {
|
|
17
29
|
configuration: {
|
|
30
|
+
text_open: 'open',
|
|
31
|
+
is_display_lock: true,
|
|
32
|
+
action_off_data: mockActionOffData,
|
|
33
|
+
action_on_data: mockActionOnData,
|
|
34
|
+
close_action_data: mockCloseActionData,
|
|
18
35
|
action1: '2b949045-8e03-4c07-a855-7794ade2e69c',
|
|
19
36
|
action1_data: {
|
|
20
37
|
color: '#00979D',
|
|
@@ -61,12 +78,44 @@ describe('Test CurtainButtonTemplate', () => {
|
|
|
61
78
|
|
|
62
79
|
let wrapper;
|
|
63
80
|
|
|
81
|
+
test('render without params', async () => {
|
|
82
|
+
await act(() => {
|
|
83
|
+
wrapper = renderer.create(wrapComponent());
|
|
84
|
+
});
|
|
85
|
+
const instance = wrapper.root;
|
|
86
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
87
|
+
expect(touchableOpacities.length).toEqual(3);
|
|
88
|
+
});
|
|
89
|
+
|
|
64
90
|
test('render CurtainButtonTemplate', async () => {
|
|
65
91
|
await act(() => {
|
|
66
|
-
wrapper = renderer.create(wrapComponent(actionGroup));
|
|
92
|
+
wrapper = renderer.create(wrapComponent(actionGroup, sensor));
|
|
67
93
|
});
|
|
68
94
|
const instance = wrapper.root;
|
|
69
95
|
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
70
96
|
expect(touchableOpacities.length).toEqual(3);
|
|
97
|
+
await touchableOpacities[0].props.onPress();
|
|
98
|
+
await touchableOpacities[1].props.onPress();
|
|
99
|
+
await touchableOpacities[2].props.onPress();
|
|
100
|
+
expect(mockDoAction).toBeCalledWith(
|
|
101
|
+
mockCloseActionData,
|
|
102
|
+
null,
|
|
103
|
+
sensor?.name + ' undefined'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const Switchs = instance.findAllByType(Switch);
|
|
107
|
+
expect(Switchs).toHaveLength(1);
|
|
108
|
+
await Switchs[0].props.onValueChange();
|
|
109
|
+
expect(mockDoAction).toBeCalledWith(
|
|
110
|
+
mockActionOnData,
|
|
111
|
+
null,
|
|
112
|
+
`${sensor.name} lock`
|
|
113
|
+
);
|
|
114
|
+
await Switchs[0].props.onValueChange();
|
|
115
|
+
expect(mockDoAction).toBeCalledWith(
|
|
116
|
+
mockActionOffData,
|
|
117
|
+
null,
|
|
118
|
+
`${sensor.name} unlock`
|
|
119
|
+
);
|
|
71
120
|
});
|
|
72
121
|
});
|
|
@@ -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;
|