@eohjsc/react-native-smart-city 0.4.40 → 0.4.41
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 +1 -1
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -5
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -5
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
- package/src/commons/ActionGroup/SliderRangeTemplate.js +5 -3
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +6 -20
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +133 -135
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +35 -13
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +71 -31
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +13 -17
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +44 -48
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +56 -22
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +123 -21
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +12 -16
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +73 -38
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +20 -20
- package/src/commons/ActionGroup/__test__/index.test.js +36 -21
- package/src/commons/ActionGroup/index.js +4 -7
- package/src/commons/HeaderAni/index.js +12 -2
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +5 -3
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +1 -0
- package/src/commons/icon/index.js +57 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/iot/mqtt.js +2 -0
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +40 -45
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -2
- package/src/screens/Device/components/SensorDisplayItem.js +18 -2
- package/src/screens/Device/detail.js +31 -13
- package/src/screens/Device/styles.js +3 -0
- package/src/screens/Sharing/MemberList.js +16 -3
- package/src/screens/Unit/SelectAddToFavorites.js +1 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +1 -1
- package/src/utils/I18n/translations/en.js +2 -0
- package/src/utils/I18n/translations/vi.js +2 -0
|
@@ -10,152 +10,150 @@ import { useUnwatchLGDeviceConfigControl } from '../../../hooks/IoT';
|
|
|
10
10
|
import Text from '../../Text';
|
|
11
11
|
import styles from './TwoButtonTemplateStyles';
|
|
12
12
|
|
|
13
|
-
const TwoButtonTemplate = memo(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const isLight = false;
|
|
13
|
+
const TwoButtonTemplate = memo(({ item = {}, doAction, sensor = {} }) => {
|
|
14
|
+
const { configuration = {} } = item;
|
|
15
|
+
const { button1, button2 } = configuration;
|
|
16
|
+
const [isOn, setIsOn] = useState(true);
|
|
17
|
+
const [isStart, setIsStart] = useState(true);
|
|
18
|
+
const [configValues] = useConfigGlobalState('configValues');
|
|
19
|
+
const isLight = false;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
21
|
+
const triggerAction1 = useCallback(async () => {
|
|
22
|
+
if (button1?.action_on_data && button1?.action_off_data) {
|
|
23
|
+
if (isOn) {
|
|
24
|
+
await doAction(button1?.action_off_data, null);
|
|
25
|
+
} else {
|
|
26
|
+
await doAction(button1?.action_on_data, null);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
}
|
|
29
|
+
if (sensor?.is_managed_by_backend) {
|
|
30
|
+
configuration.config &&
|
|
31
|
+
sensor.device_type === DEVICE_TYPE.LG_THINQ &&
|
|
32
|
+
watchMultiConfigs([configuration.config]);
|
|
33
|
+
}
|
|
34
|
+
}, [
|
|
35
|
+
button1,
|
|
36
|
+
configuration.config,
|
|
37
|
+
doAction,
|
|
38
|
+
isOn,
|
|
39
|
+
sensor?.is_managed_by_backend,
|
|
40
|
+
sensor.device_type,
|
|
41
|
+
]);
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (
|
|
53
|
-
sensor?.is_managed_by_backend &&
|
|
54
|
-
sensor.device_type === DEVICE_TYPE.LG_THINQ
|
|
55
|
-
) {
|
|
56
|
-
configuration.config && watchMultiConfigs([configuration.config]);
|
|
43
|
+
const triggerAction2 = useCallback(async () => {
|
|
44
|
+
if (button2?.action_on_data && button2?.action_off_data) {
|
|
45
|
+
if (isStart) {
|
|
46
|
+
await doAction(button2?.action_off_data, null);
|
|
47
|
+
} else {
|
|
48
|
+
await doAction(button2?.action_on_data, null);
|
|
57
49
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
}
|
|
51
|
+
if (
|
|
52
|
+
sensor?.is_managed_by_backend &&
|
|
53
|
+
sensor.device_type === DEVICE_TYPE.LG_THINQ
|
|
54
|
+
) {
|
|
55
|
+
configuration.config && watchMultiConfigs([configuration.config]);
|
|
56
|
+
}
|
|
57
|
+
}, [
|
|
58
|
+
button2?.action_off_data,
|
|
59
|
+
button2?.action_on_data,
|
|
60
|
+
configuration.config,
|
|
61
|
+
doAction,
|
|
62
|
+
isStart,
|
|
63
|
+
sensor?.is_managed_by_backend,
|
|
64
|
+
sensor.device_type,
|
|
65
|
+
]);
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
const configValue1 = configValues[button1?.config];
|
|
72
|
-
const configValue2 = configValues[button2?.config];
|
|
73
|
-
if (button1?.is_on_value && button1?.is_on_value.length > 0) {
|
|
74
|
-
setIsOn(button1?.is_on_value.includes(configValue1?.value));
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (button2?.is_on_value && button2?.is_on_value.length > 0) {
|
|
78
|
-
setIsStart(button2?.is_on_value.includes(configValue2?.value));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
67
|
+
useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
|
|
81
68
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const configValue1 = configValues[button1?.config];
|
|
71
|
+
const configValue2 = configValues[button2?.config];
|
|
72
|
+
if (button1?.is_on_value && button1?.is_on_value.length > 0) {
|
|
73
|
+
setIsOn(button1?.is_on_value.includes(configValue1?.value));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (button2?.is_on_value && button2?.is_on_value.length > 0) {
|
|
77
|
+
setIsStart(button2?.is_on_value.includes(configValue2?.value));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
94
80
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
icon_on: button2?.icon_on,
|
|
108
|
-
icon_off: button2?.icon_off,
|
|
109
|
-
text_on: button2?.text_on,
|
|
110
|
-
text_off: button2?.text_off,
|
|
111
|
-
onPress: triggerAction2,
|
|
112
|
-
isCheckOnOff: isStart,
|
|
113
|
-
accessibilityLabel: AccessibilityLabel.BUTTON_TEMPLATE_1,
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
return (
|
|
117
|
-
<>
|
|
118
|
-
{buttons.map((item, index) => (
|
|
119
|
-
<TouchableOpacity
|
|
120
|
-
accessibilityLabel={item.accessibilityLabel}
|
|
121
|
-
style={styles.bigCircle}
|
|
122
|
-
onPress={item.onPress}
|
|
123
|
-
key={index}
|
|
124
|
-
>
|
|
125
|
-
<View style={styles.smallCircle}>
|
|
126
|
-
<Icon
|
|
127
|
-
name={item?.isCheckOnOff ? item?.icon_on : item?.icon_off}
|
|
128
|
-
size={44}
|
|
129
|
-
color={item?.isCheckOnOff ? Colors.Green7 : Colors.Gray6}
|
|
130
|
-
/>
|
|
131
|
-
<Text
|
|
132
|
-
style={[
|
|
133
|
-
styles.textBig,
|
|
134
|
-
{ color: item?.isCheckOnOff ? Colors.Gray8 : Colors.Gray6 },
|
|
135
|
-
]}
|
|
136
|
-
>
|
|
137
|
-
{item?.isCheckOnOff ? item?.text_on : item?.text_off}
|
|
138
|
-
</Text>
|
|
139
|
-
</View>
|
|
140
|
-
</TouchableOpacity>
|
|
141
|
-
))}
|
|
142
|
-
</>
|
|
143
|
-
);
|
|
144
|
-
};
|
|
81
|
+
setIsOn(configValue1?.value);
|
|
82
|
+
setIsStart(configValue2?.value);
|
|
83
|
+
}, [
|
|
84
|
+
configuration.config,
|
|
85
|
+
configValues,
|
|
86
|
+
configuration.is_on_value,
|
|
87
|
+
configuration,
|
|
88
|
+
button1?.config,
|
|
89
|
+
button1?.is_on_value,
|
|
90
|
+
button2?.config,
|
|
91
|
+
button2?.is_on_value,
|
|
92
|
+
]);
|
|
145
93
|
|
|
94
|
+
const RenderTwoButtonAction = () => {
|
|
95
|
+
const buttons = [
|
|
96
|
+
{
|
|
97
|
+
icon_on: button1?.icon_on,
|
|
98
|
+
icon_off: button1?.icon_off,
|
|
99
|
+
text_on: button1?.text_on,
|
|
100
|
+
text_off: button1?.text_off,
|
|
101
|
+
onPress: triggerAction1,
|
|
102
|
+
isCheckOnOff: isOn,
|
|
103
|
+
accessibilityLabel: AccessibilityLabel.BUTTON_TEMPLATE_1,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
icon_on: button2?.icon_on,
|
|
107
|
+
icon_off: button2?.icon_off,
|
|
108
|
+
text_on: button2?.text_on,
|
|
109
|
+
text_off: button2?.text_off,
|
|
110
|
+
onPress: triggerAction2,
|
|
111
|
+
isCheckOnOff: isStart,
|
|
112
|
+
accessibilityLabel: AccessibilityLabel.BUTTON_TEMPLATE_1,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
146
115
|
return (
|
|
147
116
|
<>
|
|
148
|
-
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
117
|
+
{buttons.map((button, index) => (
|
|
118
|
+
<TouchableOpacity
|
|
119
|
+
accessibilityLabel={button.accessibilityLabel}
|
|
120
|
+
style={styles.bigCircle}
|
|
121
|
+
onPress={button.onPress}
|
|
122
|
+
key={index}
|
|
123
|
+
>
|
|
124
|
+
<View style={styles.smallCircle}>
|
|
125
|
+
<Icon
|
|
126
|
+
name={button?.isCheckOnOff ? button?.icon_on : button?.icon_off}
|
|
127
|
+
size={44}
|
|
128
|
+
color={button?.isCheckOnOff ? Colors.Green7 : Colors.Gray6}
|
|
129
|
+
/>
|
|
130
|
+
<Text
|
|
131
|
+
style={[
|
|
132
|
+
styles.textBig,
|
|
133
|
+
{ color: button?.isCheckOnOff ? Colors.Gray8 : Colors.Gray6 },
|
|
134
|
+
]}
|
|
135
|
+
>
|
|
136
|
+
{button?.isCheckOnOff ? button?.text_on : button?.text_off}
|
|
137
|
+
</Text>
|
|
138
|
+
</View>
|
|
139
|
+
</TouchableOpacity>
|
|
140
|
+
))}
|
|
156
141
|
</>
|
|
157
142
|
);
|
|
158
|
-
}
|
|
159
|
-
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<>
|
|
147
|
+
<View style={styles.wrap}>
|
|
148
|
+
<RenderTwoButtonAction />
|
|
149
|
+
</View>
|
|
150
|
+
{!!item.title && !isLight && (
|
|
151
|
+
<Text size={20} semibold center>
|
|
152
|
+
{item.title}
|
|
153
|
+
</Text>
|
|
154
|
+
)}
|
|
155
|
+
</>
|
|
156
|
+
);
|
|
157
|
+
});
|
|
160
158
|
|
|
161
159
|
export default TwoButtonTemplate;
|
|
@@ -25,21 +25,17 @@ jest.mock('../../../iot/states', () => ({
|
|
|
25
25
|
useConfigGlobalState: jest.fn(),
|
|
26
26
|
}));
|
|
27
27
|
|
|
28
|
-
const wrapComponent = (
|
|
28
|
+
const wrapComponent = (item, doAction, sensor) => (
|
|
29
29
|
<SCProvider initState={mockSCStore({})}>
|
|
30
|
-
<ColorPickerTemplate
|
|
31
|
-
actionGroup={actionGroup}
|
|
32
|
-
doAction={doAction}
|
|
33
|
-
sensor={sensor}
|
|
34
|
-
/>
|
|
30
|
+
<ColorPickerTemplate item={item} doAction={doAction} sensor={sensor} />
|
|
35
31
|
</SCProvider>
|
|
36
32
|
);
|
|
37
33
|
|
|
38
34
|
describe('Test ColorPickerTemplate', () => {
|
|
39
35
|
let wrapper;
|
|
40
|
-
let
|
|
36
|
+
let displayItem;
|
|
41
37
|
|
|
42
|
-
const
|
|
38
|
+
const actionColorData = {
|
|
43
39
|
color: '#00979D',
|
|
44
40
|
command_prefer_over_bluetooth: false,
|
|
45
41
|
command_prefer_over_googlehome: false,
|
|
@@ -50,11 +46,11 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
50
46
|
beforeEach(() => {
|
|
51
47
|
watchMultiConfigs.mockClear();
|
|
52
48
|
mockDoAction.mockClear();
|
|
53
|
-
|
|
49
|
+
displayItem = {
|
|
54
50
|
template: 'ColorPickerTemplate',
|
|
55
51
|
configuration: {
|
|
56
52
|
config: 5,
|
|
57
|
-
action_color_data:
|
|
53
|
+
action_color_data: actionColorData,
|
|
58
54
|
},
|
|
59
55
|
title: '',
|
|
60
56
|
};
|
|
@@ -68,7 +64,7 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
68
64
|
name: 'Sensor',
|
|
69
65
|
};
|
|
70
66
|
await act(async () => {
|
|
71
|
-
wrapper = await create(wrapComponent(
|
|
67
|
+
wrapper = await create(wrapComponent(displayItem, mockDoAction, sensor));
|
|
72
68
|
});
|
|
73
69
|
const instance = wrapper.root;
|
|
74
70
|
const pickers = instance.findAllByType(ColorPicker);
|
|
@@ -94,7 +90,7 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
94
90
|
device_type: DEVICE_TYPE.LG_THINQ,
|
|
95
91
|
};
|
|
96
92
|
await act(async () => {
|
|
97
|
-
wrapper = await create(wrapComponent(
|
|
93
|
+
wrapper = await create(wrapComponent(displayItem, mockDoAction, sensor));
|
|
98
94
|
});
|
|
99
95
|
const instance = wrapper.root;
|
|
100
96
|
const pickers = instance.findAllByType(ColorPicker);
|
|
@@ -108,7 +104,7 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
108
104
|
device_type: DEVICE_TYPE.LG_THINQ,
|
|
109
105
|
};
|
|
110
106
|
await act(async () => {
|
|
111
|
-
wrapper = await create(wrapComponent(
|
|
107
|
+
wrapper = await create(wrapComponent(displayItem, mockDoAction, sensor));
|
|
112
108
|
});
|
|
113
109
|
const instance = wrapper.root;
|
|
114
110
|
const wheelpicker = instance.findByType(WheelColorPicker);
|
|
@@ -118,4 +114,30 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
118
114
|
// NOTE: Hinh will fix it later
|
|
119
115
|
expect(mockSetAction).not.toBeCalled();
|
|
120
116
|
});
|
|
117
|
+
|
|
118
|
+
it('test WheelColorPicker onChangeColorComplete', async () => {
|
|
119
|
+
const sensor = {
|
|
120
|
+
is_managed_by_backend: true,
|
|
121
|
+
name: 'Sensor',
|
|
122
|
+
device_type: DEVICE_TYPE.LG_THINQ,
|
|
123
|
+
};
|
|
124
|
+
await act(async () => {
|
|
125
|
+
wrapper = await create(wrapComponent(displayItem, mockDoAction, sensor));
|
|
126
|
+
});
|
|
127
|
+
const instance = wrapper.root;
|
|
128
|
+
const wheelpicker = instance.findByType(WheelColorPicker);
|
|
129
|
+
await act(async () => {
|
|
130
|
+
await wheelpicker.props.onStart();
|
|
131
|
+
});
|
|
132
|
+
// NOTE: Hinh will fix it later
|
|
133
|
+
expect(mockSetAction).toBeCalledTimes(0);
|
|
134
|
+
expect(mockDoAction).toBeCalledTimes(0);
|
|
135
|
+
|
|
136
|
+
await act(async () => {
|
|
137
|
+
await wheelpicker.props.onChangeColorComplete('#ffffff');
|
|
138
|
+
});
|
|
139
|
+
// NOTE: Hinh will fix it later
|
|
140
|
+
expect(mockSetAction).toBeCalledTimes(0);
|
|
141
|
+
expect(mockDoAction).toBeCalledTimes(1);
|
|
142
|
+
});
|
|
121
143
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ActivityIndicator, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import Text from '../../../commons/Text';
|
|
5
5
|
import { DEVICE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
|
|
6
6
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
7
7
|
import NumberUpDownActionTemplate from '../NumberUpDownActionTemplate';
|
|
8
|
+
import styles from '../NumberUpDownActionTemplateStyle';
|
|
8
9
|
|
|
9
10
|
jest.mock('../../../iot/Monitor');
|
|
10
11
|
|
|
@@ -20,7 +21,7 @@ jest.mock('@react-navigation/native', () => {
|
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
describe('Test NumberUpDownTemplate', () => {
|
|
23
|
-
const
|
|
24
|
+
const actionData = {
|
|
24
25
|
color: '#00979D',
|
|
25
26
|
command_prefer_over_bluetooth: true,
|
|
26
27
|
command_prefer_over_googlehome: false,
|
|
@@ -31,16 +32,16 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
31
32
|
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
let
|
|
35
|
+
let displayItem;
|
|
35
36
|
let wrapper;
|
|
36
37
|
|
|
37
38
|
beforeEach(() => {
|
|
38
39
|
watchMultiConfigs.mockClear();
|
|
39
|
-
|
|
40
|
+
displayItem = {
|
|
40
41
|
configuration: {
|
|
41
42
|
allow_config_store_value: false,
|
|
42
43
|
config: 5,
|
|
43
|
-
action_data,
|
|
44
|
+
action_data: actionData,
|
|
44
45
|
min_value: 16,
|
|
45
46
|
max_value: 30,
|
|
46
47
|
text_format: '{number} *C',
|
|
@@ -53,7 +54,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
53
54
|
await act(async () => {
|
|
54
55
|
wrapper = await create(
|
|
55
56
|
<NumberUpDownActionTemplate
|
|
56
|
-
|
|
57
|
+
item={displayItem}
|
|
57
58
|
doAction={mockDoAction}
|
|
58
59
|
sensor={{
|
|
59
60
|
is_managed_by_backend: true,
|
|
@@ -80,7 +81,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
80
81
|
await act(async () => {
|
|
81
82
|
wrapper = await create(
|
|
82
83
|
<NumberUpDownActionTemplate
|
|
83
|
-
|
|
84
|
+
item={displayItem}
|
|
84
85
|
doAction={mockDoAction}
|
|
85
86
|
sensor={{ is_managed_by_backend: false }}
|
|
86
87
|
/>
|
|
@@ -102,7 +103,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
102
103
|
await act(async () => {
|
|
103
104
|
wrapper = await create(
|
|
104
105
|
<NumberUpDownActionTemplate
|
|
105
|
-
|
|
106
|
+
item={displayItem}
|
|
106
107
|
doAction={mockDoAction}
|
|
107
108
|
sensor={{
|
|
108
109
|
is_managed_by_backend: true,
|
|
@@ -124,11 +125,11 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
124
125
|
|
|
125
126
|
it('do action watchConfigs cause allow_config_store_value true', async () => {
|
|
126
127
|
const mockDoAction = jest.fn();
|
|
127
|
-
|
|
128
|
+
displayItem.configuration.allow_config_store_value = true;
|
|
128
129
|
await act(async () => {
|
|
129
130
|
wrapper = await create(
|
|
130
131
|
<NumberUpDownActionTemplate
|
|
131
|
-
|
|
132
|
+
item={displayItem}
|
|
132
133
|
doAction={mockDoAction}
|
|
133
134
|
sensor={{
|
|
134
135
|
is_managed_by_backend: true,
|
|
@@ -149,13 +150,13 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
149
150
|
});
|
|
150
151
|
|
|
151
152
|
it('action down without config', async () => {
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
displayItem.configuration.allow_config_store_value = true;
|
|
154
|
+
displayItem.configuration.config = undefined;
|
|
154
155
|
const mockDoAction = jest.fn();
|
|
155
156
|
await act(async () => {
|
|
156
157
|
wrapper = await create(
|
|
157
158
|
<NumberUpDownActionTemplate
|
|
158
|
-
|
|
159
|
+
item={displayItem}
|
|
159
160
|
doAction={mockDoAction}
|
|
160
161
|
sensor={{ is_managed_by_backend: true }}
|
|
161
162
|
/>
|
|
@@ -174,12 +175,12 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
174
175
|
|
|
175
176
|
it('action down allow_config_store_value true', async () => {
|
|
176
177
|
const mockDoAction = jest.fn();
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
displayItem.configuration.allow_config_store_value = true;
|
|
179
|
+
displayItem.configuration.config = null;
|
|
179
180
|
await act(async () => {
|
|
180
181
|
wrapper = await create(
|
|
181
182
|
<NumberUpDownActionTemplate
|
|
182
|
-
|
|
183
|
+
item={displayItem}
|
|
183
184
|
doAction={mockDoAction}
|
|
184
185
|
sensor={{ is_managed_by_backend: true }}
|
|
185
186
|
/>
|
|
@@ -201,12 +202,12 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
201
202
|
|
|
202
203
|
it('action up allow_config_store_value true', async () => {
|
|
203
204
|
const mockDoAction = jest.fn();
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
displayItem.configuration.allow_config_store_value = true;
|
|
206
|
+
displayItem.configuration.config = null;
|
|
206
207
|
await act(async () => {
|
|
207
208
|
wrapper = await create(
|
|
208
209
|
<NumberUpDownActionTemplate
|
|
209
|
-
|
|
210
|
+
item={displayItem}
|
|
210
211
|
doAction={mockDoAction}
|
|
211
212
|
sensor={{ is_managed_by_backend: true }}
|
|
212
213
|
/>
|
|
@@ -222,7 +223,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
222
223
|
await touchs.props.onPress();
|
|
223
224
|
});
|
|
224
225
|
const text = instance.find(
|
|
225
|
-
(el) => el.props.accessibilityLabel === '
|
|
226
|
+
(el) => el.props.accessibilityLabel === 'text_format' && el.type === Text
|
|
226
227
|
);
|
|
227
228
|
expect(text.props.children).toEqual('29 *C');
|
|
228
229
|
});
|
|
@@ -232,7 +233,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
232
233
|
await act(async () => {
|
|
233
234
|
wrapper = await create(
|
|
234
235
|
<NumberUpDownActionTemplate
|
|
235
|
-
|
|
236
|
+
item={displayItem}
|
|
236
237
|
doAction={mockDoAction}
|
|
237
238
|
sensor={{ is_managed_by_backend: true }}
|
|
238
239
|
/>
|
|
@@ -258,7 +259,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
258
259
|
await act(async () => {
|
|
259
260
|
wrapper = await create(
|
|
260
261
|
<NumberUpDownActionTemplate
|
|
261
|
-
|
|
262
|
+
item={displayItem}
|
|
262
263
|
doAction={mockDoAction}
|
|
263
264
|
sensor={{ is_managed_by_backend: true }}
|
|
264
265
|
/>
|
|
@@ -280,12 +281,12 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
280
281
|
});
|
|
281
282
|
|
|
282
283
|
it('action down limit ', async () => {
|
|
283
|
-
|
|
284
|
+
displayItem.configuration.min_value = 25;
|
|
284
285
|
const mockDoAction = jest.fn();
|
|
285
286
|
await act(async () => {
|
|
286
287
|
wrapper = await create(
|
|
287
288
|
<NumberUpDownActionTemplate
|
|
288
|
-
|
|
289
|
+
item={displayItem}
|
|
289
290
|
doAction={mockDoAction}
|
|
290
291
|
sensor={{ is_managed_by_backend: true }}
|
|
291
292
|
/>
|
|
@@ -304,12 +305,12 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
304
305
|
});
|
|
305
306
|
|
|
306
307
|
it('action up limit ', async () => {
|
|
307
|
-
|
|
308
|
+
displayItem.configuration.max_value = 25;
|
|
308
309
|
const mockDoAction = jest.fn();
|
|
309
310
|
await act(async () => {
|
|
310
311
|
wrapper = await create(
|
|
311
312
|
<NumberUpDownActionTemplate
|
|
312
|
-
|
|
313
|
+
item={displayItem}
|
|
313
314
|
doAction={mockDoAction}
|
|
314
315
|
sensor={{ is_managed_by_backend: true }}
|
|
315
316
|
/>
|
|
@@ -328,11 +329,11 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
328
329
|
});
|
|
329
330
|
it('render template have title', async () => {
|
|
330
331
|
const mockDoAction = jest.fn();
|
|
331
|
-
|
|
332
|
+
displayItem.title = 'title';
|
|
332
333
|
await act(async () => {
|
|
333
334
|
wrapper = await create(
|
|
334
335
|
<NumberUpDownActionTemplate
|
|
335
|
-
|
|
336
|
+
item={displayItem}
|
|
336
337
|
doAction={mockDoAction}
|
|
337
338
|
sensor={{
|
|
338
339
|
is_managed_by_backend: true,
|
|
@@ -347,11 +348,11 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
347
348
|
});
|
|
348
349
|
it('render template watch config not exits', async () => {
|
|
349
350
|
const mockDoAction = jest.fn();
|
|
350
|
-
|
|
351
|
+
displayItem.configuration.config = 100;
|
|
351
352
|
await act(async () => {
|
|
352
353
|
wrapper = await create(
|
|
353
354
|
<NumberUpDownActionTemplate
|
|
354
|
-
|
|
355
|
+
item={displayItem}
|
|
355
356
|
doAction={mockDoAction}
|
|
356
357
|
sensor={{
|
|
357
358
|
is_managed_by_backend: true,
|
|
@@ -368,7 +369,7 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
368
369
|
await act(async () => {
|
|
369
370
|
wrapper = await create(
|
|
370
371
|
<NumberUpDownActionTemplate
|
|
371
|
-
|
|
372
|
+
item={displayItem}
|
|
372
373
|
doAction={mockDoAction}
|
|
373
374
|
sensor={{
|
|
374
375
|
is_managed_by_backend: true,
|
|
@@ -402,4 +403,43 @@ describe('Test NumberUpDownTemplate', () => {
|
|
|
402
403
|
26
|
|
403
404
|
);
|
|
404
405
|
});
|
|
406
|
+
|
|
407
|
+
it('render isWidgetOrder', async () => {
|
|
408
|
+
const mockDoAction = jest.fn();
|
|
409
|
+
await act(async () => {
|
|
410
|
+
wrapper = await create(
|
|
411
|
+
<NumberUpDownActionTemplate
|
|
412
|
+
item={displayItem}
|
|
413
|
+
doAction={mockDoAction}
|
|
414
|
+
sensor={{
|
|
415
|
+
is_managed_by_backend: true,
|
|
416
|
+
device_type: DEVICE_TYPE.LG_THINQ,
|
|
417
|
+
}}
|
|
418
|
+
isWidgetOrder
|
|
419
|
+
/>
|
|
420
|
+
);
|
|
421
|
+
});
|
|
422
|
+
const rootElement = wrapper.root.findAllByType(View)[0];
|
|
423
|
+
expect(rootElement.props.style).toEqual(styles.wrapOrderItem);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it('render default value', async () => {
|
|
427
|
+
const mockDoAction = jest.fn();
|
|
428
|
+
await act(async () => {
|
|
429
|
+
wrapper = await create(
|
|
430
|
+
<NumberUpDownActionTemplate
|
|
431
|
+
doAction={mockDoAction}
|
|
432
|
+
sensor={{
|
|
433
|
+
is_managed_by_backend: true,
|
|
434
|
+
device_type: DEVICE_TYPE.LG_THINQ,
|
|
435
|
+
}}
|
|
436
|
+
isWidgetOrder
|
|
437
|
+
/>
|
|
438
|
+
);
|
|
439
|
+
});
|
|
440
|
+
const rootElement = wrapper.root.findByProps({
|
|
441
|
+
accessibilityLabel: 'text_format',
|
|
442
|
+
});
|
|
443
|
+
expect(rootElement.props.children).toEqual('');
|
|
444
|
+
});
|
|
405
445
|
});
|