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