@eohjsc/react-native-smart-city 0.7.11 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json 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.7.11",
4
+ "version": "0.7.12",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -1,18 +1,19 @@
1
+ import { Image, TouchableOpacity, View } from 'react-native';
1
2
  import React, { useEffect } from 'react';
2
- import { View, TouchableOpacity, Image } from 'react-native';
3
3
  import { useIsFocused, useNavigation } from '@react-navigation/native';
4
+
5
+ import { AccessibilityLabel } from '../../configs/Constants';
4
6
  import { Colors } from '../../configs';
5
- import { useTranslations } from '../../hooks/Common/useTranslations';
6
- import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
7
- import Text from '../../commons/Text';
8
- import styles from './ManageSubUnitStyles';
9
7
  import { IconOutline } from '@ant-design/icons-react-native';
10
8
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
11
- import Routes from '../../utils/Route';
12
9
  import NoSubUnitImage from '../../../assets/images/Illustrations.svg';
13
- import useManageSubUnit from './hooks/useManageSubUnit';
14
- import { AccessibilityLabel } from '../../configs/Constants';
10
+ import Routes from '../../utils/Route';
15
11
  import { RowItem } from '../../commons/RowItem';
12
+ import Text from '../../commons/Text';
13
+ import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
14
+ import styles from './ManageSubUnitStyles';
15
+ import useManageSubUnit from './hooks/useManageSubUnit';
16
+ import { useTranslations } from '../../hooks/Common/useTranslations';
16
17
 
17
18
  const RightComponent = ({ onAddSubUnit, onRearrangeSubUnit }) => (
18
19
  <View style={styles.rightComponent}>
@@ -50,7 +51,9 @@ const StationList = ({ stations, onEditSubUnit }) => {
50
51
  />
51
52
  }
52
53
  text={item.name}
53
- subtext={`${item.devices?.length} ${t('devices').toLowerCase()}`}
54
+ subtext={`${item.devices?.length || 0} ${t(
55
+ 'devices'
56
+ ).toLowerCase()}`}
54
57
  onPress={() => onEditSubUnit(item)}
55
58
  rightComponent={
56
59
  <IconOutline name="right" size={20} color={Colors.Gray6} />
@@ -1,15 +1,16 @@
1
1
  import React, { useState } from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
3
- import { isEqual } from 'lodash';
2
+ import { TouchableOpacity, View } from 'react-native';
3
+
4
4
  import { API } from '../../configs';
5
- import { axiosPost } from '../../utils/Apis/axios';
6
- import styles from './RearrrageSubUnitStyle';
7
- import Text from '../../commons/Text';
8
5
  import FlatListDnD from '../../commons/FlatListDnD';
9
- import ViewButtonBottom from '../../commons/ViewButtonBottom';
10
6
  import { HeaderCustom } from '../../commons/Header';
11
7
  import Rearrange from '../../../assets/images/Rearrange.svg';
8
+ import Text from '../../commons/Text';
12
9
  import { ToastBottomHelper } from '../../utils/Utils';
10
+ import ViewButtonBottom from '../../commons/ViewButtonBottom';
11
+ import { axiosPost } from '../../utils/Apis/axios';
12
+ import { isEqual } from 'lodash';
13
+ import styles from './RearrrageSubUnitStyle';
13
14
  import { useNavigation } from '@react-navigation/native';
14
15
  import { useTranslations } from '../../hooks/Common/useTranslations';
15
16
 
@@ -55,7 +56,7 @@ const RearrangeSubUnit = ({ route }) => {
55
56
  >
56
57
  <Text style={styles.indexText}>{item.name}</Text>
57
58
  <Text style={styles.deviceText}>
58
- {`${item.devices.length} ${t('devices').toLowerCase()}`}
59
+ {`${item.devices?.length || 0} ${t('devices').toLowerCase()}`}
59
60
  </Text>
60
61
  </View>
61
62
  </View>
@@ -1,17 +1,18 @@
1
- import React from 'react';
2
1
  import { ScrollView, TouchableOpacity } from 'react-native';
3
- import { create } from 'react-test-renderer';
4
- import { act } from '@testing-library/react-hooks';
5
- import ManageSubUnit from '../ManageSubUnit';
6
- import { SCProvider } from '../../../context';
7
- import { mockSCStore } from '../../../context/mockStore';
8
- import { RowItem } from '../../../commons/RowItem';
9
- import Routes from '../../../utils/Route';
2
+
3
+ import API from '../../../configs/API';
10
4
  import { AccessibilityLabel } from '../../../configs/Constants';
5
+ import ManageSubUnit from '../ManageSubUnit';
11
6
  import MockAdapter from 'axios-mock-adapter';
7
+ import React from 'react';
8
+ import Routes from '../../../utils/Route';
9
+ import { RowItem } from '../../../commons/RowItem';
10
+ import { SCProvider } from '../../../context';
11
+ import { act } from '@testing-library/react-hooks';
12
12
  import api from '../../../utils/Apis/axios';
13
+ import { create } from 'react-test-renderer';
14
+ import { mockSCStore } from '../../../context/mockStore';
13
15
  import { useNavigation } from '@react-navigation/native';
14
- import API from '../../../configs/API';
15
16
 
16
17
  const mock = new MockAdapter(api.axiosInstance);
17
18
 
@@ -58,6 +59,20 @@ describe('Test ManageSubUnit', () => {
58
59
  screen: Routes.EditSubUnit,
59
60
  });
60
61
  });
62
+
63
+ it('render ManageSubUnit station without device', async () => {
64
+ data = [{ id: 1, name: 'station' }];
65
+ mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, { stations: data });
66
+ await act(async () => {
67
+ tree = await create(wrapComponent(route));
68
+ });
69
+ const instance = tree.root;
70
+ const subUnitScrollViews = instance.findAllByType(ScrollView);
71
+ expect(subUnitScrollViews).toHaveLength(1);
72
+ const rowItem = instance.findAllByType(RowItem);
73
+ expect(rowItem).toHaveLength(1);
74
+ });
75
+
61
76
  it('ManageSubUnit add sub unit', async () => {
62
77
  await act(async () => {
63
78
  tree = await create(wrapComponent(route));
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
- import { create } from 'react-test-renderer';
3
- import { act } from '@testing-library/react-hooks';
4
1
  import { API } from '../../../configs';
5
- import { ViewButtonBottom } from '../../../commons';
2
+ import DraggableFlatList from 'react-native-draggable-flatlist';
3
+ import MockAdapter from 'axios-mock-adapter';
4
+ import React from 'react';
5
+ import RearrageSubUnit from '../RearrageSubUnit';
6
6
  import { SCProvider } from '../../../context';
7
- import { mockSCStore } from '../../../context/mockStore';
7
+ import { ToastBottomHelper } from '../../../utils/Utils';
8
+ import { ViewButtonBottom } from '../../../commons';
9
+ import { act } from '@testing-library/react-hooks';
8
10
  import api from '../../../utils/Apis/axios';
9
- import RearrageSubUnit from '../RearrageSubUnit';
10
- import MockAdapter from 'axios-mock-adapter';
11
+ import { create } from 'react-test-renderer';
12
+ import { mockSCStore } from '../../../context/mockStore';
11
13
  import { useNavigation } from '@react-navigation/native';
12
- import { ToastBottomHelper } from '../../../utils/Utils';
13
- import DraggableFlatList from 'react-native-draggable-flatlist';
14
14
 
15
15
  const mock = new MockAdapter(api.axiosInstance);
16
16
 
@@ -93,6 +93,16 @@ describe('Test RearrangeSubUnit', () => {
93
93
  });
94
94
 
95
95
  it('test call api error', async () => {
96
+ route = {
97
+ params: {
98
+ unit: { id: 1, name: 'unit 1' },
99
+ stations: [
100
+ { id: 1, name: 'station 1', devices: [{ id: 1, name: 'device 1' }] },
101
+ { id: 2, name: 'station 2' },
102
+ ],
103
+ },
104
+ };
105
+
96
106
  await act(async () => {
97
107
  tree = await create(wrapComponent(route));
98
108
  });
@@ -106,7 +116,7 @@ describe('Test RearrangeSubUnit', () => {
106
116
  expect(flatListDnD.props.data).toEqual(route.params.stations);
107
117
 
108
118
  const swappedStations = [
109
- { id: 2, name: 'station 2', devices: [{ id: 1, name: 'device 2' }] },
119
+ { id: 2, name: 'station 2' },
110
120
  { id: 1, name: 'station 1', devices: [{ id: 1, name: 'device 1' }] },
111
121
  ];
112
122