@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.
Files changed (85) hide show
  1. package/android/build.gradle +24 -19
  2. package/package.json +12 -14
  3. package/src/commons/Action/ItemQuickAction.js +0 -1
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +4 -3
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  7. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +5 -4
  8. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
  9. package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -6
  10. package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
  11. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +17 -6
  12. package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -5
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
  14. package/src/commons/ActionGroup/StatesGridActionTemplate.js +20 -6
  15. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
  16. package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
  17. package/src/commons/ActionGroup/TimerActionTemplate.js +2 -3
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
  19. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +14 -37
  20. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +31 -71
  21. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
  22. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +17 -13
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +48 -44
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +22 -56
  25. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +21 -123
  26. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +16 -12
  27. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +38 -73
  28. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +15 -11
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +15 -11
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +31 -21
  32. package/src/commons/ActionGroup/__test__/index.test.js +21 -36
  33. package/src/commons/ActionGroup/index.js +7 -4
  34. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
  35. package/src/commons/Dashboard/MyUnit/index.js +2 -2
  36. package/src/commons/DateTimeRangeChange/index.js +3 -3
  37. package/src/commons/Device/HistoryChart.js +1 -1
  38. package/src/commons/Device/HorizontalBarChart.js +4 -3
  39. package/src/commons/Device/LinearChart.js +5 -3
  40. package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
  41. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
  42. package/src/commons/HeaderAni/index.js +2 -12
  43. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
  44. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +3 -5
  45. package/src/commons/Processing/index.js +0 -1
  46. package/src/commons/Processing/styles.js +0 -3
  47. package/src/commons/SubUnit/OneTap/ItemOneTap.js +0 -1
  48. package/src/commons/Unit/HeaderUnit/index.js +8 -15
  49. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
  50. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
  51. package/src/configs/AccessibilityLabel.js +0 -1
  52. package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
  53. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
  54. package/src/hooks/useMqtt.js +2 -5
  55. package/src/iot/mqtt.js +0 -2
  56. package/src/navigations/UnitStack.js +2 -2
  57. package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
  58. package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
  59. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
  60. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +2 -19
  61. package/src/screens/Automate/AddNewAction/__test__/{SetupConfigCondition.test.js → SetupSensor.test.js} +0 -97
  62. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
  63. package/src/screens/ChangePosition/__test__/index.test.js +32 -34
  64. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
  65. package/src/screens/Device/__test__/detail.test.js +45 -40
  66. package/src/screens/Device/__test__/sensorDisplayItem.test.js +2 -14
  67. package/src/screens/Device/components/ChartWrapper.js +12 -14
  68. package/src/screens/Device/components/SensorDisplayItem.js +2 -18
  69. package/src/screens/Device/components/VisualChart.js +3 -17
  70. package/src/screens/Device/components/__test__/VisualChart.test.js +15 -12
  71. package/src/screens/Device/detail.js +15 -34
  72. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
  73. package/src/screens/Device/styles.js +0 -3
  74. package/src/screens/Sharing/MemberList.js +3 -16
  75. package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
  76. package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
  77. package/src/screens/Unit/SelectAddToFavorites.js +0 -1
  78. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
  79. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
  80. package/src/utils/Apis/axios.js +0 -1
  81. package/src/utils/I18n/translations/en.js +0 -2
  82. package/src/utils/I18n/translations/vi.js +0 -2
  83. package/src/utils/Monitor.js +2 -2
  84. package/src/commons/Highcharts/index.js +0 -111
  85. package/src/commons/icon/index.js +0 -57
@@ -12,9 +12,9 @@ jest.mock('../../../iot/states', () => ({
12
12
  useConfigGlobalState: jest.fn(),
13
13
  }));
14
14
 
15
- const wrapComponent = (item, mockDoAction) => (
15
+ const wrapComponent = (actionGroup, mockDoAction) => (
16
16
  <SCProvider initState={mockSCStore({})}>
17
- <OnOffTemplate item={item} doAction={mockDoAction} />
17
+ <OnOffTemplate actionGroup={actionGroup} doAction={mockDoAction} />
18
18
  </SCProvider>
19
19
  );
20
20
 
@@ -26,7 +26,7 @@ jest.mock('@react-navigation/native', () => {
26
26
  });
27
27
 
28
28
  describe('Test OneBigButtonTemplate', () => {
29
- const actionOnData = {
29
+ const action_on_data = {
30
30
  color: '#00979D',
31
31
  command_prefer_over_bluetooth: true,
32
32
  command_prefer_over_googlehome: false,
@@ -37,7 +37,7 @@ describe('Test OneBigButtonTemplate', () => {
37
37
  key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
38
38
  };
39
39
 
40
- const actionOffData = {
40
+ const action_off_data = {
41
41
  color: '#00979D',
42
42
  command_prefer_over_bluetooth: true,
43
43
  command_prefer_over_googlehome: false,
@@ -47,14 +47,14 @@ describe('Test OneBigButtonTemplate', () => {
47
47
  id: 20,
48
48
  key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
49
49
  };
50
- const displayItem = {
50
+ const actionGroup = {
51
51
  configuration: {
52
52
  action_on: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
53
- action_on_data: actionOnData,
53
+ action_on_data: action_on_data,
54
54
  icon_on: 'caret-up',
55
55
  text_on: 'ON',
56
56
  action_off: '5ed1d4dc-a905-47cd-b0c9-f979644bd21b',
57
- action_off_data: actionOffData,
57
+ action_off_data: action_off_data,
58
58
  icon_off: 'caret-up',
59
59
  text_off: 'OFF',
60
60
  config: 1,
@@ -72,7 +72,7 @@ describe('Test OneBigButtonTemplate', () => {
72
72
  const mockDoAction = jest.fn();
73
73
 
74
74
  await act(async () => {
75
- wrapper = create(wrapComponent(displayItem, mockDoAction));
75
+ wrapper = create(wrapComponent(actionGroup, mockDoAction));
76
76
  });
77
77
 
78
78
  const instance = wrapper.root;
@@ -115,7 +115,7 @@ describe('Test OneBigButtonTemplate', () => {
115
115
  ]);
116
116
  const mockDoAction = jest.fn();
117
117
  await act(async () => {
118
- wrapper = create(wrapComponent(displayItem, mockDoAction));
118
+ wrapper = create(wrapComponent(actionGroup, mockDoAction));
119
119
  });
120
120
  const instance = wrapper.root;
121
121
  const button = instance.findByType(TouchableOpacity);
@@ -126,10 +126,10 @@ describe('Test OneBigButtonTemplate', () => {
126
126
  };
127
127
 
128
128
  it('action state on', async () => {
129
- await assertActionCall(true, actionOnData, { state: 0, value: 0 });
129
+ await assertActionCall(true, action_on_data, { state: 0, value: 0 });
130
130
  });
131
131
 
132
132
  it('action state off', async () => {
133
- await assertActionCall(false, actionOffData, { state: 1, value: 1 });
133
+ await assertActionCall(false, action_off_data, { state: 1, value: 1 });
134
134
  });
135
135
  });
@@ -20,17 +20,21 @@ jest.mock('@react-navigation/native', () => {
20
20
  };
21
21
  });
22
22
 
23
- const wrapComponent = (item, doAction, sensor) => (
23
+ const wrapComponent = (actionGroup, doAction, sensor) => (
24
24
  <SCProvider initState={mockSCStore({})}>
25
- <OnOffSmartLock item={item} doAction={doAction} sensor={sensor} />
25
+ <OnOffSmartLock
26
+ actionGroup={actionGroup}
27
+ doAction={doAction}
28
+ sensor={sensor}
29
+ />
26
30
  </SCProvider>
27
31
  );
28
32
 
29
33
  describe('Test OnOffTemplate', () => {
30
34
  let wrapper;
31
- let displayItem;
35
+ let actionGroup;
32
36
 
33
- const actionOnData = {
37
+ const action_on_data = {
34
38
  color: '#00979D',
35
39
  command_prefer_over_bluetooth: true,
36
40
  command_prefer_over_googlehome: false,
@@ -40,7 +44,7 @@ describe('Test OnOffTemplate', () => {
40
44
  id: 20,
41
45
  key: 'key-2',
42
46
  };
43
- const actionOffData = {
47
+ const action_off_data = {
44
48
  color: '#00979D',
45
49
  command_prefer_over_bluetooth: true,
46
50
  command_prefer_over_googlehome: false,
@@ -54,12 +58,12 @@ describe('Test OnOffTemplate', () => {
54
58
  beforeEach(() => {
55
59
  watchMultiConfigs.mockClear();
56
60
  mockDoAction.mockClear();
57
- displayItem = {
61
+ actionGroup = {
58
62
  template: 'OnOffSmartLockActionTemplate',
59
63
  configuration: {
60
64
  config: 5,
61
- action_on_data: actionOnData,
62
- action_off_data: actionOffData,
65
+ action_on_data: action_on_data,
66
+ action_off_data: action_off_data,
63
67
  icon: 'up',
64
68
  is_on_value: '2',
65
69
  },
@@ -74,7 +78,7 @@ describe('Test OnOffTemplate', () => {
74
78
  ]);
75
79
  const sensor = { is_managed_by_backend: true, name: 'Sensor' };
76
80
  await act(async () => {
77
- wrapper = await create(wrapComponent(displayItem, mockDoAction, sensor));
81
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
78
82
  });
79
83
  const instance = wrapper.root;
80
84
  const button = instance.find(
@@ -83,18 +87,18 @@ describe('Test OnOffTemplate', () => {
83
87
  await act(async () => {
84
88
  await button.props.onPress();
85
89
  });
86
- expect(mockDoAction).toBeCalledWith(actionOnData, '{"door_lock":0}');
90
+ expect(mockDoAction).toBeCalledWith(action_on_data, '{"door_lock":0}');
87
91
  });
88
92
 
89
93
  it('render with template OnOffSmartLockActionTemplate doAction unlock', async () => {
90
- displayItem.configuration.is_on_value = null;
94
+ actionGroup.configuration.is_on_value = null;
91
95
  const sensor = { is_managed_by_backend: false, name: 'Sensor' };
92
96
  useConfigGlobalState.mockImplementation(() => [
93
97
  { 5: { value: 0 } },
94
98
  jest.fn(),
95
99
  ]);
96
100
  await act(async () => {
97
- wrapper = await create(wrapComponent(displayItem, mockDoAction, sensor));
101
+ wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
98
102
  });
99
103
  const instance = wrapper.root;
100
104
  const button = instance.find(
@@ -103,6 +107,6 @@ describe('Test OnOffTemplate', () => {
103
107
  await act(async () => {
104
108
  await button.props.onPress();
105
109
  });
106
- expect(mockDoAction).toBeCalledWith(actionOffData, '{"door_lock":1}');
110
+ expect(mockDoAction).toBeCalledWith(action_off_data, '{"door_lock":1}');
107
111
  });
108
112
  });
@@ -10,9 +10,13 @@ import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
10
10
  import { mockSCStore } from '../../../context/mockStore';
11
11
  import { SCProvider } from '../../../context';
12
12
 
13
- const wrapComponent = (item, mockDoAction, sensor) => (
13
+ const wrapComponent = (actionGroup, mockDoAction, sensor) => (
14
14
  <SCProvider initState={mockSCStore({})}>
15
- <OnOffTemplate item={item} doAction={mockDoAction} sensor={sensor} />
15
+ <OnOffTemplate
16
+ actionGroup={actionGroup}
17
+ doAction={mockDoAction}
18
+ sensor={sensor}
19
+ />
16
20
  </SCProvider>
17
21
  );
18
22
 
@@ -30,11 +34,11 @@ jest.mock('@react-navigation/native', () => {
30
34
  });
31
35
 
32
36
  describe('Test OnOffTemplate', () => {
33
- let displayItem;
37
+ let actionGroup;
34
38
  let tree;
35
39
  let sensor;
36
40
 
37
- const actionData = {
41
+ const action_data = {
38
42
  color: '#00979D',
39
43
  command_prefer_over_bluetooth: true,
40
44
  command_prefer_over_googlehome: false,
@@ -44,7 +48,7 @@ describe('Test OnOffTemplate', () => {
44
48
  id: 20,
45
49
  key: 'key-1',
46
50
  };
47
- const actionOnData = {
51
+ const action_on_data = {
48
52
  color: '#00979D',
49
53
  command_prefer_over_bluetooth: true,
50
54
  command_prefer_over_googlehome: false,
@@ -54,7 +58,7 @@ describe('Test OnOffTemplate', () => {
54
58
  id: 20,
55
59
  key: 'key-2',
56
60
  };
57
- const actionOffData = {
61
+ const action_off_data = {
58
62
  color: '#00979D',
59
63
  command_prefer_over_bluetooth: true,
60
64
  command_prefer_over_googlehome: false,
@@ -69,12 +73,12 @@ describe('Test OnOffTemplate', () => {
69
73
  watchMultiConfigs.mockClear();
70
74
  jest.useFakeTimers();
71
75
 
72
- displayItem = {
76
+ actionGroup = {
73
77
  template: 'OnOffSimpleActionTemplate',
74
78
  configuration: {
75
79
  config: 5,
76
- action_on_data: actionOnData,
77
- action_off_data: actionOffData,
80
+ action_on_data: action_on_data,
81
+ action_off_data: action_off_data,
78
82
  icon: 'up',
79
83
  is_on_value: [2],
80
84
  },
@@ -87,7 +91,7 @@ describe('Test OnOffTemplate', () => {
87
91
  it('render with template OnOffSimpleActionTemplate', async () => {
88
92
  const mockDoAction = jest.fn();
89
93
  await act(async () => {
90
- tree = await create(wrapComponent(displayItem, mockDoAction, {}));
94
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
91
95
  });
92
96
  const instance = tree.root;
93
97
  const template = instance.findAllByType(OnOffSimpleTemplate);
@@ -95,10 +99,10 @@ describe('Test OnOffTemplate', () => {
95
99
  });
96
100
 
97
101
  it('render with template on_off_button_action_template', async () => {
98
- displayItem.template = 'on_off_button_action_template';
102
+ actionGroup.template = 'on_off_button_action_template';
99
103
  const mockDoAction = jest.fn();
100
104
  await act(async () => {
101
- tree = await create(wrapComponent(displayItem, mockDoAction, {}));
105
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
102
106
  });
103
107
  const instance = tree.root;
104
108
  const template = instance.findAllByType(OnOffButtonTemplate);
@@ -106,10 +110,10 @@ describe('Test OnOffTemplate', () => {
106
110
  });
107
111
 
108
112
  it('render with wrong template', async () => {
109
- displayItem.template = 'wrong_template';
113
+ actionGroup.template = 'wrong_template';
110
114
  const mockDoAction = jest.fn();
111
115
  await act(async () => {
112
- tree = await create(wrapComponent(displayItem, mockDoAction, {}));
116
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
113
117
  });
114
118
  const instance = tree.root;
115
119
 
@@ -127,7 +131,7 @@ describe('Test OnOffTemplate', () => {
127
131
  it('render with template OnOffSimpleActionTemplate with is_managed_by_backend', async () => {
128
132
  const mockDoAction = jest.fn();
129
133
  await act(async () => {
130
- tree = await create(wrapComponent(displayItem, mockDoAction, {}));
134
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
131
135
  });
132
136
  const instance = tree.root;
133
137
  const template = instance.findAllByType(OnOffSimpleTemplate);
@@ -138,7 +142,7 @@ describe('Test OnOffTemplate', () => {
138
142
  it('template OnOffSimpleActionTemplate doAction with is_on_value, match configValue', async () => {
139
143
  const mockDoAction = jest.fn();
140
144
  await act(async () => {
141
- tree = await create(wrapComponent(displayItem, mockDoAction, sensor));
145
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
142
146
  });
143
147
 
144
148
  const instance = tree.root;
@@ -148,15 +152,15 @@ describe('Test OnOffTemplate', () => {
148
152
  await act(async () => {
149
153
  await template.props.triggerAction();
150
154
  });
151
- expect(mockDoAction).toHaveBeenCalledWith(actionOffData, undefined);
155
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, undefined);
152
156
  expect(watchMultiConfigs).toBeCalledTimes(0);
153
157
  });
154
158
 
155
159
  it('template OnOffSimpleActionTemplate doAction with is_on_value, not match configValue', async () => {
156
- displayItem.configuration.is_on_value = [1];
160
+ actionGroup.configuration.is_on_value = [1];
157
161
  const mockDoAction = jest.fn();
158
162
  await act(async () => {
159
- tree = await create(wrapComponent(displayItem, mockDoAction, sensor));
163
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
160
164
  });
161
165
  const instance = tree.root;
162
166
  const template = instance.findByType(OnOffSimpleTemplate);
@@ -165,13 +169,13 @@ describe('Test OnOffTemplate', () => {
165
169
  await act(async () => {
166
170
  await template.props.triggerAction();
167
171
  });
168
- expect(mockDoAction).toHaveBeenCalledWith(actionOnData, undefined);
172
+ expect(mockDoAction).toHaveBeenCalledWith(action_on_data, undefined);
169
173
  });
170
174
 
171
175
  it('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
172
176
  const mockDoAction = jest.fn();
173
177
  await act(async () => {
174
- tree = await create(wrapComponent(displayItem, mockDoAction, sensor));
178
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
175
179
  });
176
180
  const instance = tree.root;
177
181
  const template = instance.findByType(OnOffSimpleTemplate);
@@ -180,16 +184,16 @@ describe('Test OnOffTemplate', () => {
180
184
  await act(async () => {
181
185
  await template.props.triggerAction();
182
186
  });
183
- expect(mockDoAction).toHaveBeenCalledWith(actionOffData, undefined);
187
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, undefined);
184
188
  expect(watchMultiConfigs).toBeCalledTimes(0);
185
189
  });
186
190
 
187
191
  it('render with template OnOffSimpleActionTemplate with just action_data', async () => {
188
- displayItem = {
192
+ actionGroup = {
189
193
  template: 'OnOffSimpleActionTemplate',
190
194
  configuration: {
191
195
  config: 5,
192
- action_data: actionData,
196
+ action_data: action_data,
193
197
  icon: 'up',
194
198
  is_on_value: [2],
195
199
  },
@@ -197,7 +201,7 @@ describe('Test OnOffTemplate', () => {
197
201
  };
198
202
  const mockDoAction = jest.fn();
199
203
  await act(async () => {
200
- tree = await create(wrapComponent(displayItem, mockDoAction, {}));
204
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
201
205
  });
202
206
  const instance = tree.root;
203
207
  const template = instance.findAllByType(OnOffSimpleTemplate);
@@ -207,16 +211,16 @@ describe('Test OnOffTemplate', () => {
207
211
  await act(async () => {
208
212
  await template[0].props.triggerAction();
209
213
  });
210
- expect(mockDoAction).toHaveBeenCalledWith(actionData, undefined);
214
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, undefined);
211
215
  });
212
216
 
213
217
  it('render with template OnOffSimpleActionTemplate with just action_data lg_thinq', async () => {
214
218
  jest.useFakeTimers();
215
- displayItem = {
219
+ actionGroup = {
216
220
  template: 'OnOffSimpleActionTemplate',
217
221
  configuration: {
218
222
  config: 5,
219
- action_data: actionData,
223
+ action_data: action_data,
220
224
  icon: 'up',
221
225
  is_on_value: [2],
222
226
  },
@@ -225,7 +229,7 @@ describe('Test OnOffTemplate', () => {
225
229
  const mockDoAction = jest.fn();
226
230
  await act(async () => {
227
231
  tree = await create(
228
- wrapComponent(displayItem, mockDoAction, {
232
+ wrapComponent(actionGroup, mockDoAction, {
229
233
  device_type: DEVICE_TYPE.LG_THINQ,
230
234
  is_managed_by_backend: true,
231
235
  })
@@ -242,16 +246,16 @@ describe('Test OnOffTemplate', () => {
242
246
  await act(async () => {
243
247
  jest.runAllTimers();
244
248
  });
245
- expect(mockDoAction).toHaveBeenCalledWith(actionData, undefined);
249
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, undefined);
246
250
  });
247
251
 
248
252
  it('render with template OnOffSimpleActionTemplate with action_data zigbee trigger off', async () => {
249
- displayItem = {
253
+ actionGroup = {
250
254
  template: 'OnOffSimpleActionTemplate',
251
255
  configuration: {
252
256
  config: 5,
253
- action_on_data: actionOnData,
254
- action_off_data: actionOffData,
257
+ action_on_data: action_on_data,
258
+ action_off_data: action_off_data,
255
259
  icon: 'up',
256
260
  is_on_value: [2],
257
261
  allow_config_store_value: true,
@@ -261,7 +265,7 @@ describe('Test OnOffTemplate', () => {
261
265
  const mockDoAction = jest.fn();
262
266
  await act(async () => {
263
267
  tree = await create(
264
- wrapComponent(displayItem, mockDoAction, {
268
+ wrapComponent(actionGroup, mockDoAction, {
265
269
  device_type: DEVICE_TYPE.ZIGBEE,
266
270
  })
267
271
  );
@@ -272,19 +276,19 @@ describe('Test OnOffTemplate', () => {
272
276
  await act(async () => {
273
277
  await template[0].props.triggerAction();
274
278
  });
275
- expect(mockDoAction).toHaveBeenCalledWith(actionOffData, {
279
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, {
276
280
  config_id: 5,
277
281
  config_value: 0,
278
282
  });
279
283
  });
280
284
 
281
285
  it('render with template OnOffSimpleActionTemplate with action_data zigbee trigger on', async () => {
282
- displayItem = {
286
+ actionGroup = {
283
287
  template: 'OnOffSimpleActionTemplate',
284
288
  configuration: {
285
289
  config: 5,
286
- action_on_data: actionOnData,
287
- action_off_data: actionOffData,
290
+ action_on_data: action_on_data,
291
+ action_off_data: action_off_data,
288
292
  icon: 'up',
289
293
  is_on_value: [1],
290
294
  allow_config_store_value: true,
@@ -294,7 +298,7 @@ describe('Test OnOffTemplate', () => {
294
298
  const mockDoAction = jest.fn();
295
299
  await act(async () => {
296
300
  tree = await create(
297
- wrapComponent(displayItem, mockDoAction, {
301
+ wrapComponent(actionGroup, mockDoAction, {
298
302
  device_type: DEVICE_TYPE.ZIGBEE,
299
303
  })
300
304
  );
@@ -305,14 +309,14 @@ describe('Test OnOffTemplate', () => {
305
309
  await act(async () => {
306
310
  await template[0].props.triggerAction();
307
311
  });
308
- expect(mockDoAction).toHaveBeenCalledWith(actionOnData, {
312
+ expect(mockDoAction).toHaveBeenCalledWith(action_on_data, {
309
313
  config_id: 5,
310
314
  config_value: 1,
311
315
  });
312
316
  });
313
317
 
314
318
  it('render with template OnOffSimpleActionTemplate with zigbee device wrong action_data', async () => {
315
- displayItem = {
319
+ actionGroup = {
316
320
  template: 'OnOffSimpleActionTemplate',
317
321
  configuration: {
318
322
  config: 5,
@@ -325,7 +329,7 @@ describe('Test OnOffTemplate', () => {
325
329
  const mockDoAction = jest.fn();
326
330
  await act(async () => {
327
331
  tree = await create(
328
- wrapComponent(displayItem, mockDoAction, {
332
+ wrapComponent(actionGroup, mockDoAction, {
329
333
  device_type: DEVICE_TYPE.ZIGBEE,
330
334
  })
331
335
  );
@@ -340,7 +344,7 @@ describe('Test OnOffTemplate', () => {
340
344
  });
341
345
 
342
346
  it('render with template OnOffSimpleActionTemplate disabled', async () => {
343
- displayItem = {
347
+ actionGroup = {
344
348
  template: 'OnOffSimpleActionTemplate',
345
349
  configuration: {
346
350
  config: 5,
@@ -351,7 +355,7 @@ describe('Test OnOffTemplate', () => {
351
355
  };
352
356
  const mockDoAction = jest.fn();
353
357
  await act(async () => {
354
- tree = await create(wrapComponent(displayItem, mockDoAction, {}));
358
+ tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
355
359
  });
356
360
  const instance = tree.root;
357
361
  const template = instance.findAllByType(OnOffSimpleTemplate);
@@ -5,12 +5,11 @@ import { TouchableOpacity } from 'react-native';
5
5
  import OneBigButtonTemplate from '../OneBigButtonTemplate';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
7
  import { SCProvider } from '../../../context';
8
- import Text from '../../Text';
9
8
 
10
- const wrapComponent = (displayItem, mockDoAction, sensor) => (
9
+ const wrapComponent = (actionGroup, mockDoAction, sensor) => (
11
10
  <SCProvider initState={mockSCStore({})}>
12
11
  <OneBigButtonTemplate
13
- item={displayItem}
12
+ actionGroup={actionGroup}
14
13
  doAction={mockDoAction}
15
14
  sensor={sensor}
16
15
  />
@@ -18,32 +17,27 @@ const wrapComponent = (displayItem, mockDoAction, sensor) => (
18
17
  );
19
18
 
20
19
  describe('Test OneBigButtonTemplate', () => {
21
- let actionData;
22
- let displayItem;
20
+ const action_data = {
21
+ color: '#00979D',
22
+ command_prefer_over_bluetooth: true,
23
+ command_prefer_over_googlehome: false,
24
+ command_prefer_over_internet: false,
25
+ googlehome_actions: [],
26
+ icon: 'caret-up',
27
+ id: 20,
28
+ key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
29
+ };
30
+ const actionGroup = {
31
+ configuration: {
32
+ action: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
33
+ action_data: action_data,
34
+ icon: 'caret-up',
35
+ text: 'UP',
36
+ },
37
+ };
23
38
  let tree;
24
39
  let sensor;
25
40
 
26
- beforeEach(() => {
27
- actionData = {
28
- color: '#00979D',
29
- command_prefer_over_bluetooth: true,
30
- command_prefer_over_googlehome: false,
31
- command_prefer_over_internet: false,
32
- googlehome_actions: [],
33
- icon: 'caret-up',
34
- id: 20,
35
- key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
36
- };
37
- displayItem = {
38
- configuration: {
39
- action: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
40
- action_data: actionData,
41
- icon: 'caret-up',
42
- text: 'UP',
43
- },
44
- };
45
- });
46
-
47
41
  beforeEach(() => {
48
42
  sensor = { name: 'Sensor' };
49
43
  });
@@ -51,7 +45,7 @@ describe('Test OneBigButtonTemplate', () => {
51
45
  it('render OneBigButtonTemplate', async () => {
52
46
  const mockDoAction = jest.fn();
53
47
  await act(async () => {
54
- tree = await create(wrapComponent(displayItem, mockDoAction, sensor));
48
+ tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
55
49
  });
56
50
  const instance = tree.root;
57
51
  const buttons = instance.findAllByType(TouchableOpacity);
@@ -62,34 +56,6 @@ describe('Test OneBigButtonTemplate', () => {
62
56
  });
63
57
 
64
58
  expect(mockDoAction).toHaveBeenCalledTimes(1);
65
- expect(mockDoAction).toHaveBeenCalledWith(actionData, null);
66
- });
67
-
68
- it('render with title', async () => {
69
- const mockDoAction = jest.fn();
70
- displayItem.title = 'xxx';
71
-
72
- await act(async () => {
73
- tree = await create(wrapComponent(displayItem, mockDoAction, sensor));
74
- });
75
- const instance = tree.root;
76
- const texts = instance.findAll(
77
- (el) => el.type === Text && el.props.type === 'H3'
78
- );
79
- expect(texts).toHaveLength(1);
80
-
81
- expect(texts[0].props.children).toEqual('xxx');
82
- });
83
- it('render with no configuration', async () => {
84
- const mockDoAction = jest.fn();
85
- delete displayItem.configuration;
86
-
87
- await act(async () => {
88
- tree = await create(wrapComponent(displayItem, mockDoAction, sensor));
89
- });
90
- const instance = tree.root;
91
- const texts = instance.findAllByType(Text);
92
-
93
- expect(texts[0].props.children).toEqual(undefined);
59
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, null);
94
60
  });
95
61
  });