@eohjsc/react-native-smart-city 0.3.65 → 0.3.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/package.json +4 -5
  2. package/src/commons/Action/ItemQuickAction.js +1 -2
  3. package/src/commons/Action/__test__/ItemQuickAction.test.js +2 -21
  4. package/src/commons/ActionGroup/CurtainButtonTemplate.js +7 -2
  5. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +19 -6
  6. package/src/commons/ActionGroup/OnOffTemplate/index.js +31 -57
  7. package/src/commons/ActionGroup/OneBigButtonTemplate.js +2 -2
  8. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
  9. package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -8
  10. package/src/commons/ActionGroup/StatesGridActionTemplateStyle.js +1 -1
  11. package/src/commons/ActionGroup/ThreeButtonTemplate.js +6 -2
  12. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +36 -23
  13. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +16 -10
  14. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -2
  15. package/src/commons/ActionGroup/__test__/index.test.js +0 -26
  16. package/src/commons/ActionTemplate/index.js +6 -6
  17. package/src/commons/Device/LinearChart.js +2 -2
  18. package/src/commons/Device/PMSensor/{PMSensorIndicatior.js → PMSensorIndicator.js} +5 -4
  19. package/src/commons/IconComponent/index.js +31 -14
  20. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +6 -6
  21. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +6 -6
  22. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +3 -3
  23. package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -1
  24. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -1
  25. package/src/configs/API.js +2 -0
  26. package/src/configs/Constants.js +15 -1
  27. package/src/iot/RemoteControl/Internet.js +3 -0
  28. package/src/screens/AddNewAction/SelectAction.js +69 -15
  29. package/src/screens/AddNewAction/SelectSensorDevices.js +3 -0
  30. package/src/screens/AddNewAutoSmart/index.js +2 -0
  31. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +1 -1
  32. package/src/screens/AllGateway/GatewayDetail/index.js +2 -2
  33. package/src/screens/Device/components/SensorDisplayItem.js +2 -5
  34. package/src/screens/Device/detail.js +17 -47
  35. package/src/screens/Notification/components/NotificationItem.js +2 -1
  36. package/src/screens/ScriptDetail/index.js +7 -3
  37. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
  38. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
  39. package/src/utils/I18n/translations/en.json +2 -1
  40. package/src/utils/I18n/translations/vi.json +2 -1
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.3.65",
4
+ "version": "0.3.67",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -29,9 +29,8 @@
29
29
  "android-prod": "ENVFILE=.env.production npx react-native run-android",
30
30
  "android-prod-device": "ENVFILE=.env.production npx react-native run-android --variant=release",
31
31
  "android-build": "npx jetifier && cd android && ENVFILE=.env.production ./gradlew assembleRelease",
32
- "check_coverage_config": "node ./scripts/check_coverage_config.js",
33
- "update_coverage_result": "node ./scripts/update_coverage_result.js",
34
- "check_coverage_result": "node ./scripts/check_coverage_result.js",
32
+ "check-coverage": "node ./scripts/check_coverage_config.js",
33
+ "update-coverage": "node ./scripts/update_coverage_result.js",
35
34
  "check_translation_file_change": "node ./scripts/check_translation_file_change.js",
36
35
  "check_create_within_act": "node ./scripts/check_create_within_act.js",
37
36
  "ios-deploy-test": "bundle exec fastlane ios beta",
@@ -102,7 +101,7 @@
102
101
  "@ant-design/icons-react-native": "^2.2.1",
103
102
  "@ant-design/react-native": "^4.0.5",
104
103
  "@babel/helper-environment-visitor": "^7.16.7",
105
- "@eohjsc/highcharts": "^1.1.0",
104
+ "@eohjsc/highcharts": "^1.0.9",
106
105
  "@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
107
106
  "@formatjs/intl-getcanonicallocales": "^1.4.5",
108
107
  "@formatjs/intl-numberformat": "^5.6.2",
@@ -83,9 +83,8 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus }) => {
83
83
  >
84
84
  <View style={wrapperStyle}>
85
85
  <IconComponent
86
- icon={action?.icon_kit || action?.icon}
86
+ icon={action?.icon_kit || action?.icon || 'PoweroffOutlined'}
87
87
  isSendingCommand={isSendingCommand}
88
- icon_outlined={'poweroff'}
89
88
  />
90
89
  </View>
91
90
  </TouchableOpacity>
@@ -6,7 +6,7 @@ import { Colors } from '../../../configs';
6
6
  import { AccessibilityLabel } from '../../../configs/Constants';
7
7
  import { factory } from 'factory-girl';
8
8
  import IconComponent from '../../IconComponent';
9
- import { IconFill, IconOutline } from '@ant-design/icons-react-native';
9
+ import { IconOutline } from '@ant-design/icons-react-native';
10
10
 
11
11
  class Sensor {}
12
12
 
@@ -76,25 +76,6 @@ describe('Test ItemQuickAction', () => {
76
76
  expect(buttonOnActionPress).toHaveLength(0);
77
77
  });
78
78
 
79
- it('render with icon_outlined poweroff', async () => {
80
- const mockSetStatus = jest.fn();
81
- sensor.quick_action.on_action.icon = null;
82
- await act(async () => {
83
- tree = await create(
84
- <ItemQuickAction
85
- sensor={sensor}
86
- wrapperStyle={style}
87
- setStatus={mockSetStatus}
88
- />
89
- );
90
- });
91
-
92
- const instance = tree.root;
93
- const icon = instance.findByType(IconOutline);
94
- expect(icon).toBeDefined();
95
- expect(icon.props.name).toEqual('poweroff');
96
- });
97
-
98
79
  it('click quick action icon down , isSendingCommand = true', async () => {
99
80
  await act(async () => {
100
81
  tree = await create(
@@ -114,7 +95,7 @@ describe('Test ItemQuickAction', () => {
114
95
  await buttonOnActionPress.props.onPress();
115
96
  });
116
97
 
117
- const icon = instance.findByType(IconFill);
98
+ const icon = instance.findByType(IconOutline);
118
99
  expect(icon.props.color).toEqual(Colors.TextGray);
119
100
  });
120
101
 
@@ -1,10 +1,10 @@
1
1
  import React, { memo, useCallback, useState } from 'react';
2
2
  import { TouchableOpacity, View, Switch, Image } from 'react-native';
3
- import { Icon } from '@ant-design/react-native';
4
3
  import styles from './CurtainButtonTemplateStyle';
5
4
  import Text from '../Text';
6
5
  import { AccessibilityLabel } from '../../configs/Constants';
7
6
  import { Colors, Images } from '../../configs';
7
+ import IconComponent from '../IconComponent';
8
8
 
9
9
  const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
10
10
  const { configuration } = actionGroup;
@@ -88,7 +88,12 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
88
88
  return (
89
89
  <>
90
90
  <View style={styles.lockDoor}>
91
- <Icon name={icon} size={15} color={color} style={styles.iconLock} />
91
+ <IconComponent
92
+ icon={icon}
93
+ iconSize={15}
94
+ color={color}
95
+ style={styles.iconLock}
96
+ />
92
97
  <Text
93
98
  style={styles.textLockDoor}
94
99
  accessibilityLabel={AccessibilityLabel.TEXT_DOOR_LOOK_ON_OFF}
@@ -1,16 +1,29 @@
1
- import { Icon } from '@ant-design/react-native';
2
1
  import Text from '../../Text';
3
2
 
4
- import React, { memo } from 'react';
3
+ import React, { memo, useMemo } from 'react';
5
4
  import { TouchableOpacity, View } from 'react-native';
6
5
  import { Colors } from '../../../configs';
7
6
  import styles from './OnOffButtonTemplateStyle';
8
7
  import { AccessibilityLabel } from '../../../configs/Constants';
8
+ import IconComponent from '../../IconComponent';
9
9
 
10
10
  const OnOffButtonTemplate = memo(
11
11
  ({ isOn, triggerAction, actionGroup = {}, isLight = false }) => {
12
12
  const { configuration = {}, id } = actionGroup;
13
- const { icon_on, icon_off, text_on, text_off } = configuration;
13
+ const {
14
+ icon_on,
15
+ icon_off,
16
+ icon_kit_on_data,
17
+ icon_kit_off_data,
18
+ text_on,
19
+ text_off,
20
+ } = configuration;
21
+ const icon = useMemo(() => {
22
+ if (isOn) {
23
+ return icon_kit_on_data?.icon || icon_on;
24
+ }
25
+ return icon_kit_off_data?.icon || icon_off;
26
+ }, [isOn, icon_on, icon_off, icon_kit_on_data, icon_kit_off_data]);
14
27
 
15
28
  return (
16
29
  <>
@@ -21,9 +34,9 @@ const OnOffButtonTemplate = memo(
21
34
  accessibilityLabel={`${AccessibilityLabel.ON_OFF_BUTTON}-${id}`}
22
35
  >
23
36
  <View style={styles.smallCircle}>
24
- <Icon
25
- name={isOn ? icon_on : icon_off}
26
- size={44}
37
+ <IconComponent
38
+ icon={icon}
39
+ iconSize={30}
27
40
  color={isOn ? Colors.Green7 : Colors.Gray6}
28
41
  />
29
42
  <Text
@@ -23,13 +23,19 @@ const getComponent = (template) => {
23
23
  const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
24
24
  const { configuration = {} } = actionGroup;
25
25
  const {
26
- action_data,
27
26
  action_on_data,
28
27
  action_off_data,
29
28
  is_on_value,
30
29
  config,
31
30
  allow_config_store_value,
32
- } = configuration;
31
+ } = useMemo(() => {
32
+ return {
33
+ ...configuration,
34
+ action_on_data: configuration.action_on_data || configuration.action_data,
35
+ action_off_data:
36
+ configuration.action_off_data || configuration.action_data,
37
+ };
38
+ }, [configuration]);
33
39
 
34
40
  // eslint-disable-next-line no-unused-vars
35
41
  const [configValues, _] = useConfigGlobalState('configValues');
@@ -45,70 +51,38 @@ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
45
51
  const [isOn, setIsOn] = useState(false);
46
52
  const [tempIsOn, setTempIsOn] = useState(getIsOnValue());
47
53
 
48
- const updateStatusFromPusher = () => {
54
+ const updateStatusFromPusher = useCallback(() => {
49
55
  setTimeout(() => {
50
56
  setTempIsOn(temp);
51
57
  }, 2500);
52
- };
58
+ }, []);
53
59
 
54
60
  const triggerAction = useCallback(async () => {
55
- switch (sensor?.device_type) {
56
- case DEVICE_TYPE.ZIGBEE:
57
- if (action_on_data && action_off_data) {
58
- let data;
59
- if (isOn) {
60
- data = { state: 0 };
61
- if (allow_config_store_value && config) {
62
- data.config_id = config;
63
- data.config_value = 0;
64
- }
65
- await doAction(action_off_data, JSON.stringify(data));
66
- } else {
67
- data = { state: 1 };
68
- if (allow_config_store_value && config) {
69
- data.config_id = config;
70
- data.config_value = 1;
71
- }
72
- await doAction(action_on_data, JSON.stringify(data));
73
- }
74
- }
75
- break;
76
- case DEVICE_TYPE.LG_THINQ:
77
- setTempIsOn((prev) => !prev);
78
- action_data &&
79
- (await doAction(action_data, JSON.stringify({ value: !isOn })));
80
- break;
81
- default:
82
- if (action_data) {
83
- if (isOn) {
84
- await doAction(action_data, false);
85
- } else {
86
- await doAction(action_data, true);
87
- }
88
- }
89
- if (action_on_data && action_off_data) {
90
- if (isOn) {
91
- await doAction(action_off_data, null);
92
- } else {
93
- await doAction(action_on_data, null);
94
- }
95
- }
96
- break;
61
+ const action_data = isOn ? action_off_data : action_on_data;
62
+ if (!action_data) {
63
+ return;
97
64
  }
98
- updateStatusFromPusher();
99
- sensor?.is_managed_by_backend &&
100
- config &&
101
- sensor.device_type === DEVICE_TYPE.LG_THINQ &&
102
- watchMultiConfigs([config]);
65
+ let data = {
66
+ value: isOn ? 0 : 1,
67
+ state: isOn ? 0 : 1, // todo Bang remove this for Zigbee
68
+ };
69
+ if (allow_config_store_value && config) {
70
+ data.config_id = config;
71
+ data.config_value = data.value;
72
+ }
73
+ setTempIsOn((prev) => !prev);
74
+ await doAction(action_data, data);
75
+ updateStatusFromPusher(); // todo Bang read about this magic
76
+
77
+ sensor?.is_managed_by_backend && config && watchMultiConfigs([config]);
103
78
  }, [
104
- allow_config_store_value,
105
- config,
106
- action_data,
79
+ isOn,
107
80
  action_off_data,
108
81
  action_on_data,
82
+ allow_config_store_value,
83
+ config,
109
84
  doAction,
110
- isOn,
111
- sensor?.device_type,
85
+ updateStatusFromPusher,
112
86
  sensor?.is_managed_by_backend,
113
87
  ]);
114
88
 
@@ -138,7 +112,7 @@ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
138
112
  isOn={tempIsOn}
139
113
  triggerAction={triggerAction}
140
114
  actionGroup={actionGroup}
141
- disabled={!action_data && !action_on_data && !action_off_data}
115
+ disabled={!action_on_data && !action_off_data}
142
116
  />
143
117
  </>
144
118
  );
@@ -1,10 +1,10 @@
1
1
  import React, { memo, useCallback } from 'react';
2
2
  import { TouchableOpacity, View } from 'react-native';
3
- import { Icon } from '@ant-design/react-native';
4
3
  import Text from '../Text';
5
4
 
6
5
  import { Colors } from '../../configs';
7
6
  import styles from './OneBigButtonTemplateStyle';
7
+ import IconComponent from '../IconComponent';
8
8
 
9
9
  const OneBigButtonTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
10
10
  const { configuration = {} } = actionGroup;
@@ -19,7 +19,7 @@ const OneBigButtonTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
19
19
  <View style={styles.barrierControlContainer}>
20
20
  <TouchableOpacity style={styles.bigCircle} onPress={onPressDoAction}>
21
21
  <View style={styles.smallCircle}>
22
- <Icon name={icon} size={44} color={Colors.Green7} />
22
+ <IconComponent icon={icon} iconSize={44} color={Colors.Green7} />
23
23
  <Text style={styles.textBig}>{text}</Text>
24
24
  </View>
25
25
  </TouchableOpacity>
@@ -9,8 +9,7 @@ import { useDropdownAction } from './hooks/useDropdownAction';
9
9
  import { useConfigGlobalState } from '../../iot/states';
10
10
  import { useUnwatchLGDeviceConfigControl } from '../../hooks/IoT';
11
11
  import styles from './OptionsDropdownActionTemplateStyle';
12
- import { watchMultiConfigs } from '../../iot/Monitor';
13
- import { DEVICE_TYPE, AccessibilityLabel } from '../../configs/Constants';
12
+ import { AccessibilityLabel } from '../../configs/Constants';
14
13
  import IconComponent from '../../commons/IconComponent';
15
14
  import { useTranslations } from '../../hooks/Common/useTranslations';
16
15
  import SvgDoorState from '../../../assets/images/Device/door-state.svg';
@@ -36,7 +35,6 @@ const OptionsDropdownActionTemplate = ({
36
35
  options = [],
37
36
  icon_kit_data,
38
37
  icon,
39
- icon_outlined,
40
38
  config,
41
39
  allow_config_store_value,
42
40
  } = configuration;
@@ -72,22 +70,16 @@ const OptionsDropdownActionTemplate = ({
72
70
  const newOption = options[selectedIndex];
73
71
  const value = getOptionValue(newOption, allow_config_store_value);
74
72
 
75
- let data = { level: value, key_code: newOption?.value_int };
73
+ let data = {
74
+ value: newOption?.value_int, // todo Bang keep only this
75
+ level: value,
76
+ key_code: newOption?.value_int,
77
+ };
76
78
  if (allow_config_store_value && config) {
77
79
  data.config_id = config;
78
80
  data.config_value = newOption?.value_int;
79
81
  }
80
- data = JSON.stringify(data);
81
-
82
- if (sensor.device_type === DEVICE_TYPE.GOOGLE_HOME) {
83
- data = value;
84
- }
85
82
  doAction(action_data, data);
86
- if (sensor?.is_managed_by_backend) {
87
- config &&
88
- sensor.device_type === DEVICE_TYPE.LG_THINQ &&
89
- watchMultiConfigs([config]);
90
- }
91
83
  hideAlertAction();
92
84
  }, [
93
85
  config,
@@ -97,8 +89,6 @@ const OptionsDropdownActionTemplate = ({
97
89
  hideAlertAction,
98
90
  options,
99
91
  selectedIndex,
100
- sensor?.is_managed_by_backend,
101
- sensor.device_type,
102
92
  ]);
103
93
 
104
94
  useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
@@ -131,7 +121,6 @@ const OptionsDropdownActionTemplate = ({
131
121
  {!checkIcon && (
132
122
  <IconComponent
133
123
  icon={iconKit || icon}
134
- icon_outlined={icon_outlined}
135
124
  isSendingCommand={false}
136
125
  size={17}
137
126
  style={styles.marginRight}
@@ -31,7 +31,6 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
31
31
  text,
32
32
  icon_kit_data,
33
33
  icon,
34
- icon_outlined,
35
34
  action_data,
36
35
  config,
37
36
  is_on_value,
@@ -80,12 +79,8 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
80
79
  return () => <></>;
81
80
  }
82
81
  }, [icon]);
83
-
84
82
  return (
85
- <View
86
- style={[styles.gridItem]}
87
- accessibilityLabel={AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM}
88
- >
83
+ <View accessibilityLabel={AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM}>
89
84
  <TouchableOpacity
90
85
  style={[styles.button, buttonOnOffStyle]}
91
86
  onPress={() => doActionAndWatchConfig(action_data)}
@@ -93,9 +88,10 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
93
88
  {!checkIcon && (
94
89
  <IconComponent
95
90
  icon={iconKit || icon}
96
- icon_outlined={icon_outlined}
97
91
  isSendingCommand={false}
98
- size={24}
92
+ size={40}
93
+ iconSize={40}
94
+ color={'red'}
99
95
  />
100
96
  )}
101
97
  {checkIcon && <View>{iconSvg}</View>}
@@ -31,7 +31,7 @@ export default StyleSheet.create({
31
31
  button: {
32
32
  width: 48,
33
33
  height: 48,
34
- padding: 12,
34
+ padding: 3,
35
35
  borderRadius: 5,
36
36
  borderWidth: 1,
37
37
  borderColor: Colors.Gray4,
@@ -1,6 +1,5 @@
1
1
  import React, { memo, useCallback, useState } from 'react';
2
2
  import { TouchableOpacity, View, Switch } from 'react-native';
3
- import { Icon } from '@ant-design/react-native';
4
3
  import styles from './ThreeButtonTemplateStyle';
5
4
  import Text from '../Text';
6
5
  import { AccessibilityLabel } from '../../configs/Constants';
@@ -58,7 +57,12 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
58
57
  return (
59
58
  <>
60
59
  <View style={styles.lockDoor}>
61
- <Icon name={icon} size={15} color={color} style={styles.iconLock} />
60
+ <IconComponent
61
+ icon={icon}
62
+ iconSize={15}
63
+ color={color}
64
+ style={styles.iconLock}
65
+ />
62
66
  <Text
63
67
  style={styles.textLockDoor}
64
68
  accessibilityLabel={AccessibilityLabel.TEXT_DOOR_LOOK_ON_OFF}
@@ -1,10 +1,10 @@
1
- /* eslint-disable promise/prefer-await-to-callbacks */
2
- import { DEVICE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
3
- import { watchMultiConfigs } from '../../../iot/Monitor';
4
1
  import React from 'react';
5
2
  import { View } from 'react-native';
6
3
  import { useSelector } from 'react-redux';
7
4
  import { act, create } from 'react-test-renderer';
5
+
6
+ import { DEVICE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
7
+ import { watchMultiConfigs } from '../../../iot/Monitor';
8
8
  import OnOffTemplate from '../OnOffTemplate';
9
9
  import OnOffButtonTemplate from '../OnOffTemplate/OnOffButtonTemplate';
10
10
  import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
@@ -95,9 +95,7 @@ describe('Test OnOffTemplate', () => {
95
95
  const localState = {
96
96
  isOnSwich: false,
97
97
  };
98
- useSelector.mockImplementation((cb) => {
99
- return cb(localState);
100
- });
98
+ useSelector.mockImplementation((getter) => getter(localState));
101
99
  });
102
100
 
103
101
  it('render with template OnOffSimpleActionTemplate', async () => {
@@ -164,7 +162,10 @@ describe('Test OnOffTemplate', () => {
164
162
  await act(async () => {
165
163
  await template.props.triggerAction();
166
164
  });
167
- expect(mockDoAction).toHaveBeenCalledWith(action_off_data, null);
165
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, {
166
+ value: 0,
167
+ state: 0,
168
+ });
168
169
  expect(watchMultiConfigs).toBeCalledTimes(0);
169
170
  });
170
171
 
@@ -181,7 +182,10 @@ describe('Test OnOffTemplate', () => {
181
182
  await act(async () => {
182
183
  await template.props.triggerAction();
183
184
  });
184
- expect(mockDoAction).toHaveBeenCalledWith(action_on_data, null);
185
+ expect(mockDoAction).toHaveBeenCalledWith(action_on_data, {
186
+ value: 1,
187
+ state: 1,
188
+ });
185
189
  });
186
190
 
187
191
  it('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
@@ -196,7 +200,10 @@ describe('Test OnOffTemplate', () => {
196
200
  await act(async () => {
197
201
  await template.props.triggerAction();
198
202
  });
199
- expect(mockDoAction).toHaveBeenCalledWith(action_off_data, null);
203
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, {
204
+ value: 0,
205
+ state: 0,
206
+ });
200
207
  expect(watchMultiConfigs).toBeCalledTimes(0);
201
208
  });
202
209
 
@@ -223,7 +230,10 @@ describe('Test OnOffTemplate', () => {
223
230
  await act(async () => {
224
231
  await template[0].props.triggerAction();
225
232
  });
226
- expect(mockDoAction).toHaveBeenCalledWith(action_data, false);
233
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, {
234
+ state: 0,
235
+ value: 0,
236
+ });
227
237
  });
228
238
 
229
239
  it('render with template OnOffSimpleActionTemplate with just action_data lg_thinq', async () => {
@@ -256,10 +266,10 @@ describe('Test OnOffTemplate', () => {
256
266
  await template[0].props.triggerAction();
257
267
  });
258
268
  jest.runAllTimers();
259
- expect(mockDoAction).toHaveBeenCalledWith(
260
- action_data,
261
- JSON.stringify({ value: false })
262
- );
269
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, {
270
+ value: 0,
271
+ state: 0,
272
+ });
263
273
  });
264
274
 
265
275
  it('render with template OnOffSimpleActionTemplate with action_data zigbee trigger off', async () => {
@@ -289,10 +299,12 @@ describe('Test OnOffTemplate', () => {
289
299
  await act(async () => {
290
300
  await template[0].props.triggerAction();
291
301
  });
292
- expect(mockDoAction).toHaveBeenCalledWith(
293
- action_off_data,
294
- JSON.stringify({ state: 0, config_id: 5, config_value: 0 })
295
- );
302
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, {
303
+ state: 0,
304
+ config_id: 5,
305
+ config_value: 0,
306
+ value: 0,
307
+ });
296
308
  });
297
309
 
298
310
  it('render with template OnOffSimpleActionTemplate with action_data zigbee trigger on', async () => {
@@ -322,10 +334,12 @@ describe('Test OnOffTemplate', () => {
322
334
  await act(async () => {
323
335
  await template[0].props.triggerAction();
324
336
  });
325
- expect(mockDoAction).toHaveBeenCalledWith(
326
- action_on_data,
327
- JSON.stringify({ state: 1, config_id: 5, config_value: 1 })
328
- );
337
+ expect(mockDoAction).toHaveBeenCalledWith(action_on_data, {
338
+ state: 1, // todo Bang remove this after production
339
+ config_id: 5,
340
+ config_value: 1,
341
+ value: 1, // this is correct
342
+ });
329
343
  });
330
344
 
331
345
  it('render with template OnOffSimpleActionTemplate with zigbee device wrong action_data', async () => {
@@ -333,7 +347,6 @@ describe('Test OnOffTemplate', () => {
333
347
  template: 'OnOffSimpleActionTemplate',
334
348
  configuration: {
335
349
  config: 5,
336
- action_data: action_data,
337
350
  icon: 'up',
338
351
  is_on_value: [2],
339
352
  allow_config_store_value: true,
@@ -159,10 +159,11 @@ describe('Test OptionsDropdownActionTemplate', () => {
159
159
  });
160
160
  expect(alertAction.props.visible).toBeFalsy();
161
161
 
162
- expect(mockDoAction).toHaveBeenCalledWith(
163
- action_data,
164
- JSON.stringify({ level: '1', key_code: 1 })
165
- );
162
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, {
163
+ level: '1',
164
+ key_code: 1,
165
+ value: 1,
166
+ });
166
167
  is_managed_by_backend
167
168
  ? expect(watchMultiConfigs).not.toBeCalled()
168
169
  : expect(watchMultiConfigs).not.toBeCalled();
@@ -228,10 +229,11 @@ describe('Test OptionsDropdownActionTemplate', () => {
228
229
  });
229
230
  expect(alertAction.props.visible).toBeFalsy();
230
231
 
231
- expect(mockDoAction).toHaveBeenCalledWith(
232
- action_data,
233
- JSON.stringify({ level: 'level-1', key_code: 1 })
234
- ); // doAction with text instead of int
232
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, {
233
+ level: 'level-1',
234
+ key_code: 1,
235
+ value: 1,
236
+ });
235
237
 
236
238
  expect(texts[1].props.children).toEqual('Level2');
237
239
  });
@@ -292,7 +294,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
292
294
  });
293
295
  expect(alertAction.props.visible).toBeTruthy();
294
296
 
295
- // Choosed Level1 option
297
+ // Choose Level1 option
296
298
  await act(async () => {
297
299
  await listChoosingOption[0].props.onPress();
298
300
  });
@@ -306,6 +308,10 @@ describe('Test OptionsDropdownActionTemplate', () => {
306
308
  });
307
309
  expect(alertAction.props.visible).toBeFalsy();
308
310
 
309
- expect(mockDoAction).toHaveBeenCalledWith(action_data, 'level-1'); // doAction with text instead of int
311
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, {
312
+ value: 1,
313
+ level: 'level-1',
314
+ key_code: 1,
315
+ });
310
316
  });
311
317
  });
@@ -25,7 +25,6 @@ describe('Test StatesGridActionTemplate', () => {
25
25
  text: 'item 1',
26
26
  icon_kit_data: 'icon_kit_data',
27
27
  icon: '123',
28
- icon_outlined: 'icon_outlined',
29
28
  action_data: mockActionData,
30
29
  },
31
30
  {
@@ -34,7 +33,6 @@ describe('Test StatesGridActionTemplate', () => {
34
33
  text: 'item 2',
35
34
  icon_kit_data: 'icon_kit_data',
36
35
  icon: 'icon',
37
- icon_outlined: 'icon_outlined',
38
36
  action_data: mockActionData,
39
37
  },
40
38
  ],
@@ -6,7 +6,6 @@ import moment from 'moment';
6
6
 
7
7
  import ActionGroup from '..';
8
8
  import Text from '../../Text';
9
- import { Colors } from '../../../configs';
10
9
  import { AccessibilityLabel } from '../../../configs/Constants';
11
10
  import { SCProvider } from '../../../context';
12
11
  import { mockSCStore } from '../../../context/mockStore';
@@ -402,30 +401,6 @@ describe('Test ActionGroup', () => {
402
401
 
403
402
  const touchs = instance.findAllByType(TouchableOpacity);
404
403
  expect(touchs).toHaveLength(2); // 2 GridItem
405
-
406
- const buttonStyle = {
407
- width: 48,
408
- height: 48,
409
- padding: 12,
410
- borderRadius: 5,
411
- borderWidth: 1,
412
- borderColor: Colors.Gray4,
413
- backgroundColor: Colors.White,
414
- };
415
-
416
- const OnOffStyle = {
417
- OFF: {
418
- borderColor: Colors.Gray4,
419
- backgroundColor: Colors.White,
420
- },
421
- ON: {
422
- borderColor: Colors.Primary,
423
- backgroundColor: Colors.Primary,
424
- },
425
- };
426
-
427
- expect(touchs[0].props.style).toEqual([buttonStyle, OnOffStyle.OFF]);
428
- expect(touchs[1].props.style).toEqual([buttonStyle, OnOffStyle.OFF]);
429
404
  });
430
405
 
431
406
  it('render TimerActionTemplate', async () => {
@@ -492,7 +467,6 @@ describe('Test ActionGroup', () => {
492
467
  options: [],
493
468
  icon_kit_data: 'icon_kit_data',
494
469
  icon: '',
495
- icon_outlined: 'icon_outlined',
496
470
  },
497
471
  };
498
472
  const mockDoAction = jest.fn();