@eohjsc/react-native-smart-city 0.3.37 → 0.3.38

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 (30) hide show
  1. package/package.json +1 -1
  2. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +6 -3
  3. package/src/configs/API.js +1 -1
  4. package/src/configs/AccessibilityLabel.js +8 -1
  5. package/src/configs/Constants.js +9 -12
  6. package/src/screens/AddCommon/SelectSubUnit.js +3 -0
  7. package/src/screens/AddNewGateway/ConnectingWifiDevice.js +4 -2
  8. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +5 -4
  9. package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +1 -4
  10. package/src/screens/AddNewGateway/ShareWifiPassword.js +4 -2
  11. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +1 -0
  12. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +14 -9
  13. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +29 -1
  14. package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +1 -1
  15. package/src/screens/Notification/__test__/NotificationItem.test.js +44 -40
  16. package/src/screens/Notification/components/NotificationItem.js +134 -141
  17. package/src/screens/SmartAccount/Connecting/index.js +3 -0
  18. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +6 -2
  19. package/src/screens/SmartAccount/ListDevice/index.js +17 -12
  20. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +61 -7
  21. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +102 -27
  22. package/src/screens/SmartAccount/SuccessfullyConnected/styles.js +58 -1
  23. package/src/screens/SmartAccount/__test__/Connecting.test.js +3 -0
  24. package/src/screens/UnitSummary/__test__/index.test.js +37 -1
  25. package/src/screens/UnitSummary/index.js +6 -1
  26. package/src/utils/Apis/axios.js +1 -0
  27. package/src/utils/__test__/Utils.test.js +19 -1
  28. package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItem.js +0 -37
  29. package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItemStyles.js +0 -49
  30. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/DeviceItem.test.js +0 -65
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.37",
4
+ "version": "0.3.38",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -113,10 +113,13 @@ const ConfigHistoryChart = memo(({ configs }) => {
113
113
  let params = new URLSearchParams();
114
114
  let configuration = configs.filter((item) => item.id);
115
115
  configuration.map((item) => {
116
- params.append('config', item.id);
116
+ params.append('configs', item.id);
117
117
  });
118
- params.append('date_from', startDate / 1000);
119
- params.append('date_to', endDate / 1000);
118
+ params.append(
119
+ 'date_from',
120
+ moment(startDate).format('YYYY-MM-DD HH:mm:ss')
121
+ );
122
+ params.append('date_to', moment(endDate).format('YYYY-MM-DD HH:mm:ss'));
120
123
  const { success, data } = await axiosGet(API.CONFIG.DISPLAY_HISTORY(), {
121
124
  params,
122
125
  });
@@ -48,7 +48,7 @@ const API = {
48
48
  RENAME_DEVICES: (id) => `/chip_manager/chips/${id}/rename_devices/`,
49
49
  ZIGBEE: {
50
50
  ACCEPT_NEW_DEVICE: (id) =>
51
- `/iot/modules/zigbee/chips/${id}/search_device/`,
51
+ `/iot/modules/zigbee/chips/${id}/device_permit_to_join/`,
52
52
  },
53
53
  },
54
54
  DEVICE: {
@@ -217,6 +217,10 @@ export default {
217
217
  GO_DETAIL: 'GO_DETAIL',
218
218
  NAV_LIST: 'NAV_LIST',
219
219
 
220
+ // Unit summary
221
+ COMPONENT_NAME: 'COMPONENT_NAME',
222
+ WRAP_HEADER_SCROLL: 'WRAP_HEADER_SCROLL',
223
+
220
224
  // Automate
221
225
  AUTOMATE_SCRIPT_ACTION: 'AUTOMATE_SCRIPT_ACTION',
222
226
  AUTOMATE_SCRIPT_NAME: 'AUTOMATE_SCRIPT_NAME',
@@ -423,8 +427,8 @@ export default {
423
427
  MANAGE_UNIT_ALERT: 'MANAGE_UNIT_ALERT',
424
428
  SELECT_UNIT: 'SELECT_UNIT',
425
429
  BUTTON_ADD_AUTO_SMART: 'BUTTON_ADD_AUTO_SMART',
426
- BUTTON_FINISH_SMART_ACCOUNT: 'BUTTON_FINISH_SMART_ACCOUNT',
427
430
  BUTTON_CONNECT_WIFI: 'BUTTON_CONNECT_WIFI',
431
+ BUTTON_BOTTOM_SMART_ACCOUNT: 'BUTTON_BOTTOM_SMART_ACCOUNT',
428
432
  },
429
433
 
430
434
  TERM_AND_POLICY_TITLE: 'TERM_AND_POLICY_TITLE',
@@ -629,6 +633,9 @@ export default {
629
633
  BUTTON_CANCEL_EDIT_ACTION_LIST: 'BUTTON_CANCEL_EDIT_ACTION_LIST',
630
634
  BUTTON_SAVE_EDIT_ACTION_LIST: 'BUTTON_SAVE_EDIT_ACTION_LIST',
631
635
  BUTTON_REMOVE_EDIT_ACTION_LIST: 'BUTTON_REMOVE_EDIT_ACTION_LIST',
636
+
637
+ //Notification
638
+ CUSTOM_TEXT: 'CUSTOM_TEXT',
632
639
  //ButtonWrapper
633
640
  BUTTON_WRAPPER: 'BUTTON_WRAPPER',
634
641
  };
@@ -239,6 +239,15 @@ export const NOTIFICATION_TYPES = {
239
239
  NOTIFY_REMOVE_SUB_UNIT: 'NOTIFY_REMOVE_SUB_UNIT',
240
240
  NOTIFY_REMOVE_DEVICE: 'NOTIFY_REMOVE_DEVICE',
241
241
  NOTIFY_EMERGENCY: 'NOTIFY_EMERGENCY',
242
+ AIR_QUALITY: 'AIR_QUALITY',
243
+ TURBIDITY: 'TURBIDITY',
244
+ PH: 'PH',
245
+ CLO: 'CLO',
246
+ UV: 'UV',
247
+ SMOKE: 'SMOKE',
248
+ FIRE: 'FIRE',
249
+ SOS: 'SOS',
250
+ FILTER_WATER: 'FILTER_WATER',
242
251
  };
243
252
 
244
253
  export const ACTIVITY_LOG_TYPES = {
@@ -247,18 +256,6 @@ export const ACTIVITY_LOG_TYPES = {
247
256
  SCRIPT_UPDATED_BY: 'SCRIPT_UPDATED_BY',
248
257
  };
249
258
 
250
- export const SENSOR_TYPE = {
251
- AIR_QUALITY: 'air_quality',
252
- TURBIDITY: 'turbidity',
253
- PH: 'ph',
254
- CLO: 'clo',
255
- UV: 'uv',
256
- SMOKE: 'smoke',
257
- FIRE: 'fire',
258
- SOS: 'sos',
259
- FILTER_WATER: 'filter_water',
260
- };
261
-
262
259
  export const EMERGENCY_TYPE = {
263
260
  CREATED: 'emergency',
264
261
  RESOLVE: 'resolved_emergency',
@@ -16,6 +16,7 @@ const AddCommonSelectSubUnit = ({ route }) => {
16
16
  smart_account_id_from_backend,
17
17
  username,
18
18
  brand,
19
+ chipId,
19
20
  } = route?.params || {};
20
21
  const [title, setTitle] = useState('');
21
22
  const [subTitle, setSubTitle] = useState('');
@@ -49,6 +50,7 @@ const AddCommonSelectSubUnit = ({ route }) => {
49
50
  smart_account_id_from_backend: smart_account_id_from_backend,
50
51
  username,
51
52
  brand,
53
+ chipId,
52
54
  },
53
55
  });
54
56
  break;
@@ -67,6 +69,7 @@ const AddCommonSelectSubUnit = ({ route }) => {
67
69
  smart_account_id_from_backend,
68
70
  username,
69
71
  brand,
72
+ chipId,
70
73
  ]
71
74
  );
72
75
 
@@ -8,7 +8,8 @@ import ConnectingDevice from './ConnectingDevice';
8
8
 
9
9
  const ConnectingWifiDevice = ({ route }) => {
10
10
  const t = useTranslations();
11
- const { unitId, stationId, gateway, selectedWifi } = route?.params || {};
11
+ const { unitId, stationId, gateway, selectedWifi, qrData } =
12
+ route?.params || {};
12
13
  const [chipId, setChipId] = useState(null);
13
14
  const { goBack } = useNavigation();
14
15
 
@@ -30,7 +31,7 @@ const ConnectingWifiDevice = ({ route }) => {
30
31
  API.UNIT.CHIP_SCAN(unitId),
31
32
  {
32
33
  imei: gateway?.imei,
33
- qr_code: gateway?.imei, // Todo Bang remove after backend deploy
34
+ secret: qrData?.secret,
34
35
  name: gateway?.model,
35
36
  station: stationId,
36
37
  wifi_ssid: selectedWifi.ssid, // for storing
@@ -46,6 +47,7 @@ const ConnectingWifiDevice = ({ route }) => {
46
47
  setChipId(data.id);
47
48
  },
48
49
  [
50
+ qrData,
49
51
  gateway,
50
52
  addingWifiDeviceFail,
51
53
  unitId,
@@ -23,13 +23,14 @@ import AccessibilityLabel from '../../configs/AccessibilityLabel';
23
23
 
24
24
  const ConnectingWifiGuide = ({ route }) => {
25
25
  const t = useTranslations();
26
- const { prefix, qrData, unitId, stationId } = route?.params || {};
26
+ const { qrData, unitId, stationId } = route?.params || {};
27
27
  const { navigate, goBack } = useNavigation();
28
28
  const [wifiList, setWifiList] = useState([]);
29
29
  const [currentState, setCurrentState] = useState(0);
30
30
 
31
31
  const connectToDeviceWifi = useCallback(async () => {
32
- const wifiPrefix = `eoh.${prefix.toLowerCase()}.`;
32
+ const prefix = `${qrData.org_slug}.${qrData.prefix}`;
33
+ const wifiPrefix = `${prefix.toLowerCase()}.`;
33
34
  const buttons = [
34
35
  {
35
36
  text: t('cancel'),
@@ -50,7 +51,7 @@ const ConnectingWifiGuide = ({ route }) => {
50
51
  return;
51
52
  }
52
53
  const wifi = _.find(phoneWifiList, function (x) {
53
- return x.SSID.indexOf(`eoh.${prefix.toLowerCase()}.`) === 0;
54
+ return x.SSID.indexOf(wifiPrefix) === 0;
54
55
  });
55
56
 
56
57
  if (!wifi) {
@@ -118,7 +119,7 @@ const ConnectingWifiGuide = ({ route }) => {
118
119
  undefined
119
120
  );
120
121
  }, 5000); // workaround, todo Bang continue research
121
- }, [goBack, prefix, t]);
122
+ }, [goBack, qrData, t]);
122
123
 
123
124
  useEffect(() => {
124
125
  if (wifiList.length) {
@@ -20,9 +20,7 @@ const ScanWifiDeviceQR = memo(({ route }) => {
20
20
  setLoading(false);
21
21
  return;
22
22
  }
23
- const devicePrefixName = data?.imei?.split('-')[0];
24
- // todo Bang change QR format
25
- if (['ROBOT'].indexOf(devicePrefixName) === -1) {
23
+ if (!data?.prefix || !data?.org_slug) {
26
24
  setIsInvalidQrCode(true);
27
25
  setLoading(false);
28
26
  return;
@@ -30,7 +28,6 @@ const ScanWifiDeviceQR = memo(({ route }) => {
30
28
  navigate(Routes.ConnectingWifiGuide, {
31
29
  unitId,
32
30
  stationId,
33
- prefix: devicePrefixName,
34
31
  qrData: data,
35
32
  });
36
33
  setLoading(true);
@@ -42,7 +42,7 @@ const WifiItem = ({ item, setIsShowPopupPassword, setSelectedWifi }) => {
42
42
  };
43
43
 
44
44
  const ShareWifiPassword = ({ route }) => {
45
- const { wifiList, unitId, stationId } = route?.params || {};
45
+ const { wifiList, unitId, stationId, qrData } = route?.params || {};
46
46
  const t = useTranslations();
47
47
  const navigation = useNavigation();
48
48
 
@@ -98,6 +98,7 @@ const ShareWifiPassword = ({ route }) => {
98
98
  unitId,
99
99
  stationId: stationId,
100
100
  gateway: gatewayInfo,
101
+ qrData: qrData,
101
102
  selectedWifi: {
102
103
  ssid: selectedWifi,
103
104
  password: selectedWifiPassword,
@@ -108,7 +109,7 @@ const ShareWifiPassword = ({ route }) => {
108
109
 
109
110
  return true;
110
111
  },
111
- [navigation, selectedWifi, selectedWifiPassword, stationId, unitId]
112
+ [navigation, qrData, selectedWifi, selectedWifiPassword, stationId, unitId]
112
113
  );
113
114
 
114
115
  const onPasswordReady = useCallback(async () => {
@@ -188,6 +189,7 @@ const ShareWifiPassword = ({ route }) => {
188
189
  value={selectedWifiPassword}
189
190
  textInputStyle={styles.input}
190
191
  selectionColor={Colors.Primary}
192
+ autoFocus
191
193
  />
192
194
  </>
193
195
  </ButtonPopup>
@@ -46,6 +46,7 @@ describe('Test connecting wifi device', () => {
46
46
  unitId: 1,
47
47
  stationId: 2,
48
48
  gateway: {},
49
+ qrData: {},
49
50
  selectedWifi: {},
50
51
  },
51
52
  };
@@ -44,6 +44,7 @@ const ConnectWifiActionButton = async (instance) => {
44
44
 
45
45
  describe('test share wifi password', () => {
46
46
  let tree;
47
+ const routeParams = { qrData: { prefix: 'robot', org_slug: 'eoh' } };
47
48
 
48
49
  beforeEach(() => {
49
50
  const socket = dgram.createSocket({});
@@ -68,7 +69,7 @@ describe('test share wifi password', () => {
68
69
 
69
70
  it('auto connect to wifi prefix on ios', async () => {
70
71
  Platform.OS = 'ios';
71
- const route = { params: { prefix: 'robot' } };
72
+ const route = { params: routeParams };
72
73
  await act(async () => {
73
74
  tree = await renderer.create(wrapComponent(route));
74
75
  });
@@ -85,7 +86,7 @@ describe('test share wifi password', () => {
85
86
 
86
87
  it('fail connect to wifi prefix on ios', async () => {
87
88
  Platform.OS = 'ios';
88
- const route = { params: { prefix: 'robot' } };
89
+ const route = { params: routeParams };
89
90
  WifiManager.connectToProtectedSSIDPrefix.mockImplementationOnce(
90
91
  async () => {
91
92
  throw 'Cannot connect to protected prefix SSID';
@@ -101,7 +102,7 @@ describe('test share wifi password', () => {
101
102
 
102
103
  it('auto connect to wifi android', async () => {
103
104
  Platform.OS = 'android';
104
- const route = { params: { prefix: 'robot' } };
105
+ const route = { params: routeParams };
105
106
  WifiManager.loadWifiList.mockImplementationOnce(async () => [
106
107
  { SSID: 'random-name' },
107
108
  { SSID: 'eoh.lite.xxx' },
@@ -122,7 +123,7 @@ describe('test share wifi password', () => {
122
123
 
123
124
  it('fail connect to wifi android', async () => {
124
125
  Platform.OS = 'android';
125
- const route = { params: { prefix: 'robot' } };
126
+ const route = { params: routeParams };
126
127
  WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => [
127
128
  { SSID: 'random-name' },
128
129
  { SSID: 'eoh.lite.xxx' },
@@ -142,7 +143,7 @@ describe('test share wifi password', () => {
142
143
 
143
144
  it('fail load wifi list android', async () => {
144
145
  Platform.OS = 'android';
145
- const route = { params: { prefix: 'robot' } };
146
+ const route = { params: routeParams };
146
147
  WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => {
147
148
  throw 'Cannot load wifi list to wifi';
148
149
  });
@@ -158,7 +159,7 @@ describe('test share wifi password', () => {
158
159
  it('request wifi list from device', async () => {
159
160
  jest.useFakeTimers();
160
161
  Platform.OS = 'android';
161
- const route = { params: { prefix: 'robot' } };
162
+ const route = { params: routeParams };
162
163
  await act(async () => {
163
164
  tree = await renderer.create(wrapComponent(route));
164
165
  });
@@ -173,7 +174,11 @@ describe('test share wifi password', () => {
173
174
  it('got wifi list from device', async () => {
174
175
  Platform.OS = 'android';
175
176
  const route = {
176
- params: { prefix: 'robot', qrData: 'abc123', unitId: 1, stationId: 1 },
177
+ params: {
178
+ qrData: { org_slug: 'eoh', prefix: 'robot' },
179
+ unitId: 1,
180
+ stationId: 1,
181
+ },
177
182
  };
178
183
  await act(async () => {
179
184
  tree = await renderer.create(wrapComponent(route));
@@ -198,7 +203,7 @@ describe('test share wifi password', () => {
198
203
  unitId: 1,
199
204
  stationId: 1,
200
205
  wifiList: [{ ssid: 'wifi 1' }, { ssid: 'wifi.2' }],
201
- qrData: 'abc123',
206
+ qrData: { org_slug: 'eoh', prefix: 'robot' },
202
207
  });
203
208
 
204
209
  // expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ShareWifiPassword);
@@ -206,7 +211,7 @@ describe('test share wifi password', () => {
206
211
 
207
212
  it('got error while request wifi list from device', async () => {
208
213
  Platform.OS = 'android';
209
- const route = { params: { prefix: 'robot' } };
214
+ const route = { params: routeParams };
210
215
  await act(async () => {
211
216
  tree = await renderer.create(wrapComponent(route));
212
217
  });
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
3
  import MockAdapter from 'axios-mock-adapter';
4
+ import { getPusher } from '../../../utils/Pusher';
5
+ import Routes from '../../../utils/Route';
4
6
  import ConnectingZigbeeDevice from '../ConnectingZigbeeDevice';
5
7
  import { SCProvider } from '../../../context';
6
8
  import { mockSCStore } from '../../../context/mockStore';
@@ -36,7 +38,8 @@ describe('Test connecting modbus device', () => {
36
38
  let tree;
37
39
  let route;
38
40
 
39
- afterEach(() => {
41
+ beforeEach(() => {
42
+ getPusher().resetMock();
40
43
  mockedNavigate.mockClear();
41
44
  });
42
45
 
@@ -59,4 +62,29 @@ describe('Test connecting modbus device', () => {
59
62
  expect(instance.findAllByType(Processing)).toHaveLength(1);
60
63
  expect(mock.history.post).toHaveLength(1);
61
64
  });
65
+
66
+ it('receive sensor-id from channel then rename sensor-id', async () => {
67
+ await act(async () => {
68
+ tree = await create(wrapComponent(route));
69
+ });
70
+ const channels = getPusher().channels;
71
+ let channel;
72
+ for (const key in channels) {
73
+ if (key.indexOf('cache-') === 0) {
74
+ channel = channels[key];
75
+ }
76
+ }
77
+ await act(async () => {
78
+ await channel.trigger('progress', { data: { sensorId: 1 } });
79
+ });
80
+ await act(async () => {
81
+ await channel.trigger('progress', { success: 1 });
82
+ });
83
+ expect(mockedNavigate).toHaveBeenCalledWith(Routes.RenameNewDevices, {
84
+ unitId: 1,
85
+ stationId: 2,
86
+ chipId: 3,
87
+ sensorId: 1,
88
+ });
89
+ });
62
90
  });
@@ -64,7 +64,7 @@ describe('test scan wifi device QR', () => {
64
64
  });
65
65
 
66
66
  it('on scan correct QR code', async () => {
67
- await scanQRCode({ imei: 'ROBOT-xxx' }, jest.fn());
67
+ await scanQRCode({ prefix: 'robot', org_slug: 'eoh' }, jest.fn());
68
68
  expect(mockedNavigate).toHaveBeenCalled();
69
69
  expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ConnectingWifiGuide);
70
70
  });
@@ -6,14 +6,11 @@ import MockAdapter from 'axios-mock-adapter';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
8
  import NotificationItem from '../components/NotificationItem';
9
- import {
10
- NOTIFICATION_TYPES,
11
- SENSOR_TYPE,
12
- EMERGENCY_TYPE,
13
- } from '../../../configs/Constants';
9
+ import { NOTIFICATION_TYPES, EMERGENCY_TYPE } from '../../../configs/Constants';
14
10
  import Routes from '../../../utils/Route';
15
11
  import { API } from '../../../configs';
16
12
  import api from '../../../utils/Apis/axios';
13
+ import { AccessibilityLabel } from '../../../configs/Constants';
17
14
 
18
15
  const wrapComponent = (item) => (
19
16
  <SCProvider initState={mockSCStore({})}>
@@ -132,17 +129,16 @@ describe('test NotificationItem', () => {
132
129
  }
133
130
 
134
131
  const listSensorType = [
135
- SENSOR_TYPE.AIR_QUALITY,
136
- SENSOR_TYPE.TURBIDITY,
137
- SENSOR_TYPE.PH,
138
- SENSOR_TYPE.CLO,
139
- SENSOR_TYPE.UV,
132
+ NOTIFICATION_TYPES.AIR_QUALITY,
133
+ NOTIFICATION_TYPES.TURBIDITY,
134
+ NOTIFICATION_TYPES.PH,
135
+ NOTIFICATION_TYPES.CLO,
136
+ NOTIFICATION_TYPES.UV,
140
137
  ];
141
- for (const sensorType of listSensorType) {
142
- test(`create ItemNotification NOTIFY_INDICATOR sensor_type ${sensorType}`, async () => {
143
- item.content_code = NOTIFICATION_TYPES.NOTIFY_INDICATOR;
138
+ for (const content_code of listSensorType) {
139
+ test(`create ItemNotification ${content_code}`, async () => {
140
+ item.content_code = content_code;
144
141
  item.params = {
145
- sensor_type: sensorType,
146
142
  unit_id: 5,
147
143
  summary_id: 11,
148
144
  };
@@ -164,32 +160,16 @@ describe('test NotificationItem', () => {
164
160
  });
165
161
  }
166
162
 
167
- it('test case NOTIFY_INDICATOR no sensor_type', async () => {
168
- item.content_code = NOTIFICATION_TYPES.NOTIFY_INDICATOR;
169
- item.params = {
170
- sensor_type: null,
171
- unit_id: 5,
172
- summary_id: 11,
173
- };
174
- await act(async () => {
175
- tree = await create(wrapComponent(item));
176
- });
177
- const instance = tree.root;
178
- const button = instance.findAllByType(TouchableOpacity);
179
- expect(button).toHaveLength(0);
180
- });
181
-
182
163
  const listSensorType2 = [
183
- SENSOR_TYPE.SMOKE,
184
- SENSOR_TYPE.FIRE,
185
- SENSOR_TYPE.SOS,
186
- SENSOR_TYPE.FILTER_WATER,
164
+ NOTIFICATION_TYPES.SMOKE,
165
+ NOTIFICATION_TYPES.FIRE,
166
+ NOTIFICATION_TYPES.SOS,
167
+ NOTIFICATION_TYPES.FILTER_WATER,
187
168
  ];
188
- for (const sensorType of listSensorType2) {
189
- test(`create ItemNotification NOTIFY_INDICATOR sensor_type ${sensorType}`, async () => {
190
- item.content_code = NOTIFICATION_TYPES.NOTIFY_INDICATOR;
169
+ for (const content_code of listSensorType2) {
170
+ test(`create ItemNotification ${content_code}`, async () => {
171
+ item.content_code = content_code;
191
172
  item.params = {
192
- sensor_type: sensorType,
193
173
  unit_id: 70,
194
174
  sensor_id: 394,
195
175
  };
@@ -212,10 +192,9 @@ describe('test NotificationItem', () => {
212
192
  });
213
193
  }
214
194
 
215
- it('test onClick Item Notify', async () => {
216
- item.content_code = NOTIFICATION_TYPES.NOTIFY_INDICATOR;
195
+ test('test onClick Item Notify', async () => {
196
+ item.content_code = NOTIFICATION_TYPES.AIR_QUALITY;
217
197
  item.params = {
218
- sensor_type: 'air_quality',
219
198
  unit_id: 5,
220
199
  summary_id: 11,
221
200
  };
@@ -314,4 +293,29 @@ describe('test NotificationItem', () => {
314
293
  const button = instance.findAllByType(TouchableOpacity);
315
294
  expect(button).toHaveLength(0);
316
295
  });
296
+
297
+ test('test case NOTIFY_REMOVE_UNIT to unit_onwer', async () => {
298
+ item.content_code = NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT;
299
+ item.params = {
300
+ unit_id: 1,
301
+ unit_owner_name: 'EoH owner',
302
+ unit_name: 'EoH',
303
+ };
304
+ await act(async () => {
305
+ tree = await create(wrapComponent(item));
306
+ });
307
+ const instance = tree.root;
308
+ const customText = instance.findByProps({
309
+ accessibilityLabel: AccessibilityLabel.CUSTOM_TEXT,
310
+ });
311
+ expect(customText.props.children[0].props.children).toEqual('Unit ');
312
+ expect(customText.props.children[1].props.children).toEqual('EoH');
313
+ expect(customText.props.children[2].props.children).toEqual(
314
+ ' has been removed by '
315
+ );
316
+ expect(customText.props.children[3].props.children).toEqual('EoH owner');
317
+ expect(customText.props.children[4].props.children).toEqual(
318
+ '. You cannot access to this unit anymore.'
319
+ );
320
+ });
317
321
  });