@eohjsc/react-native-smart-city 0.3.27 → 0.3.30

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 (118) hide show
  1. package/index.js +2 -0
  2. package/package.json +1 -1
  3. package/src/Images/Common/device_icon.png +0 -0
  4. package/src/Images/DevMode/gateway.png +0 -0
  5. package/src/Images/DevMode/gateway@2x.png +0 -0
  6. package/src/Images/DevMode/gateway@3x.png +0 -0
  7. package/src/Images/DevMode/menu.png +0 -0
  8. package/src/Images/DevMode/menu@2x.png +0 -0
  9. package/src/Images/DevMode/menu@3x.png +0 -0
  10. package/src/Images/DevMode/search.png +0 -0
  11. package/src/Images/DevMode/search@2x.png +0 -0
  12. package/src/Images/DevMode/search@3x.png +0 -0
  13. package/src/Images/DevMode/smart.png +0 -0
  14. package/src/Images/DevMode/smart@2x.png +0 -0
  15. package/src/Images/DevMode/smart@3x.png +0 -0
  16. package/src/Images/DevMode/template.png +0 -0
  17. package/src/Images/DevMode/template@2x.png +0 -0
  18. package/src/Images/DevMode/template@3x.png +0 -0
  19. package/src/commons/Action/ItemQuickAction.js +1 -0
  20. package/src/commons/ActionGroup/CurtainButtonTemplate.js +1 -2
  21. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -0
  22. package/src/commons/ActionGroup/SliderRangeTemplate.js +22 -14
  23. package/src/commons/ActionTemplate/CurtainAction.js +60 -0
  24. package/src/commons/ActionTemplate/CurtainActionStyles.js +11 -0
  25. package/src/commons/ActionTemplate/OnOffSmartLockAction.js +44 -0
  26. package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +11 -0
  27. package/src/commons/ActionTemplate/index.js +18 -0
  28. package/src/commons/BottomButtonView/index.js +1 -0
  29. package/src/commons/Button/index.js +2 -0
  30. package/src/commons/CameraDevice/index.js +1 -2
  31. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +20 -12
  32. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +2 -0
  33. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +1 -1
  34. package/src/commons/ConnectingProcess/index.js +11 -0
  35. package/src/commons/Dashboard/MyUnit/index.js +1 -1
  36. package/src/commons/DevMode/Label.js +10 -0
  37. package/src/commons/DevMode/Search.js +20 -0
  38. package/src/commons/DevMode/Styles/LabelStyles.js +8 -0
  39. package/src/commons/DevMode/Styles/SearchStyles.js +21 -0
  40. package/src/commons/DevMode/index.js +3 -0
  41. package/src/commons/Device/ItemAddNew/index.js +5 -1
  42. package/src/commons/Device/ItemDevice.js +12 -9
  43. package/src/commons/Form/TextInput.js +4 -0
  44. package/src/commons/HeaderAni/index.js +1 -0
  45. package/src/commons/MediaPlayerDetail/index.js +0 -20
  46. package/src/commons/MenuActionMore/index.js +11 -1
  47. package/src/commons/Modal/index.js +1 -2
  48. package/src/commons/NavBar/index.js +13 -1
  49. package/src/commons/Popover/index.js +7 -6
  50. package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -1
  51. package/src/commons/SubUnit/ShortDetail.js +1 -0
  52. package/src/commons/SummaryItem/index.js +2 -1
  53. package/src/commons/Tabbar/Styles/indexStyles.js +51 -0
  54. package/src/commons/Tabbar/index.js +110 -0
  55. package/src/commons/Unit/HeaderUnit/index.js +2 -0
  56. package/src/commons/Unit/SharedUnit.js +1 -0
  57. package/src/commons/WrapParallaxScrollView/index.js +16 -2
  58. package/src/configs/Colors.js +4 -0
  59. package/src/configs/Constants.js +16 -0
  60. package/src/configs/Images.js +6 -0
  61. package/src/hooks/Common/useDevicesStatus.js +1 -1
  62. package/src/hooks/IoT/useValueEvaluation.js +10 -19
  63. package/src/iot/RemoteControl/GoogleHome.js +6 -6
  64. package/src/navigations/GatewayStack.js +23 -0
  65. package/src/navigations/Main.js +144 -0
  66. package/src/navigations/SmartStack.js +23 -0
  67. package/src/navigations/TemplateStack.js +23 -0
  68. package/src/navigations/UnitStack.js +5 -8
  69. package/src/screens/AddNewAction/Device/index.js +5 -1
  70. package/src/screens/AddNewAction/SelectAction.js +36 -15
  71. package/src/screens/AddNewAction/__test__/SelectAction.test.js +1 -0
  72. package/src/screens/AddNewAutoSmart/index.js +2 -0
  73. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +13 -1
  74. package/src/screens/AllCamera/__test__/index.test.js +1 -8
  75. package/src/screens/AllCamera/index.js +0 -13
  76. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +10 -11
  77. package/src/screens/Device/detail.js +35 -16
  78. package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +37 -0
  79. package/src/screens/Device/hooks/useFavoriteDevice.js +4 -2
  80. package/src/screens/Drawer/Drawer.test.js +24 -0
  81. package/src/screens/Drawer/index.js +198 -0
  82. package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -3
  83. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +4 -7
  84. package/src/screens/Gateway/__test__/index.test.js +16 -0
  85. package/src/screens/Gateway/index.js +8 -0
  86. package/src/screens/Notification/__test__/NotificationItem.test.js +74 -104
  87. package/src/screens/Notification/components/NotificationItem.js +40 -239
  88. package/src/screens/ScriptDetail/__test__/index.test.js +40 -1
  89. package/src/screens/ScriptDetail/index.js +2 -1
  90. package/src/screens/Sharing/Components/SensorItem.js +4 -1
  91. package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
  92. package/src/screens/Sharing/Components/Styles/TitleCheckBoxStyles.js +4 -0
  93. package/src/screens/Sharing/Components/TitleCheckBox.js +17 -8
  94. package/src/screens/Smart/__test__/index.test.js +16 -0
  95. package/src/screens/Smart/index.js +8 -0
  96. package/src/screens/SubUnit/AddSubUnit.js +1 -1
  97. package/src/screens/SubUnit/EditSubUnit.js +4 -1
  98. package/src/screens/Template/Styles/indexStyles.js +51 -0
  99. package/src/screens/Template/__test__/index.test.js +16 -0
  100. package/src/screens/Template/index.js +84 -0
  101. package/src/screens/Unit/Detail.js +16 -28
  102. package/src/screens/Unit/MoreMenu.js +16 -1
  103. package/src/screens/Unit/SelectAddToFavorites.js +11 -1
  104. package/src/screens/Unit/Station/__test__/index.test.js +41 -0
  105. package/src/screens/Unit/Station/index.js +0 -1
  106. package/src/screens/Unit/Summaries.js +6 -1
  107. package/src/screens/Unit/__test__/Detail.test.js +1 -5
  108. package/src/screens/Unit/components/AutomateScript/index.js +5 -2
  109. package/src/utils/Converter/__test__/timer.test.js +99 -0
  110. package/src/utils/Functions/Search.js +17 -0
  111. package/src/utils/Functions/ShortEmail.js +4 -0
  112. package/src/utils/Functions/__test__/Search.test.js +6 -0
  113. package/src/utils/Functions/__test__/ShortEmail.test.js +6 -0
  114. package/src/utils/I18n/translations/en.json +37 -42
  115. package/src/utils/I18n/translations/vi.json +37 -44
  116. package/src/utils/Route/index.js +6 -0
  117. package/src/commons/Modal/ModalFullVideo.js +0 -48
  118. package/src/commons/Modal/Styles/ModalFullVideoStyles.js +0 -26
@@ -0,0 +1,37 @@
1
+ import { renderHook } from '@testing-library/react-hooks';
2
+ import MockAdapter from 'axios-mock-adapter';
3
+ import { API } from '../../../../configs';
4
+ import api from '../../../../utils/Apis/axios';
5
+ import { useEmergencyButton } from '../useEmergencyButton';
6
+
7
+ const mockFetchDataDeviceDetail = jest.fn();
8
+ const mockAcquireLockShowing = jest.fn();
9
+
10
+ const mock = new MockAdapter(api.axiosInstance);
11
+
12
+ describe('Test useEmergencyButton', () => {
13
+ it('Test render', async () => {
14
+ const { result } = renderHook(() =>
15
+ useEmergencyButton(mockFetchDataDeviceDetail, mockAcquireLockShowing)
16
+ );
17
+ jest.useFakeTimers();
18
+ await result.current.onCancelConfirmAlert();
19
+ expect(result.current.showAlertConfirm).toBe(false);
20
+ jest.runAllTimers();
21
+ await result.current.onEmergencyButtonPress();
22
+ mock.onPost(API.EMERGENCY_BUTTON.SEND_ALERT()).reply(200);
23
+ await result.current.onSendNowAlert();
24
+ expect(result.current.showAlertConfirm).toBe(true);
25
+ });
26
+
27
+ it('Test send alert fail', async () => {
28
+ mock.onPost(API.EMERGENCY_BUTTON.SEND_ALERT()).reply(400);
29
+ const { result } = renderHook(() =>
30
+ useEmergencyButton(mockFetchDataDeviceDetail, mockAcquireLockShowing)
31
+ );
32
+ await result.current.onSendNowAlert();
33
+ await result.current.onCloseAlertSent();
34
+ await result.current.onViewDetails();
35
+ expect(result.current.showAlertConfirm).toBe(false);
36
+ });
37
+ });
@@ -17,14 +17,16 @@ export const useFavoriteDevice = (device) => {
17
17
  API.DEVICE.ADD_TO_FAVOURITES(device?.id)
18
18
  );
19
19
  success && setAction(Action.ADD_DEVICES_TO_FAVORITES, [device.id]);
20
- }, [device, setAction]);
20
+ // eslint-disable-next-line react-hooks/exhaustive-deps
21
+ }, [device]);
21
22
 
22
23
  const removeFromFavorites = useCallback(async () => {
23
24
  const { success } = await axiosPost(
24
25
  API.DEVICE.REMOVE_FROM_FAVOURITES(device?.id)
25
26
  );
26
27
  success && setAction(Action.REMOVE_DEVICES_FROM_FAVORITES, [device.id]);
27
- }, [device, setAction]);
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
29
+ }, [device]);
28
30
 
29
31
  return {
30
32
  isFavorite,
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { SafeAreaView } from 'react-native';
3
+ import renderer, { act } from 'react-test-renderer';
4
+ import { SCProvider } from '../../context';
5
+ import { mockSCStore } from '../../context/mockStore';
6
+ import Drawer from './index';
7
+
8
+ const wrapComponent = () => (
9
+ <SCProvider initState={mockSCStore({})}>
10
+ <Drawer navigation={jest.fn()} />
11
+ </SCProvider>
12
+ );
13
+
14
+ describe('Drawer', () => {
15
+ let tree;
16
+ test('drawer snapshot', async () => {
17
+ await act(async () => {
18
+ tree = await renderer.create(wrapComponent());
19
+ });
20
+ const instance = tree.root;
21
+ const safeView = instance.findAllByType(SafeAreaView);
22
+ expect(safeView).toHaveLength(1);
23
+ });
24
+ });
@@ -0,0 +1,198 @@
1
+ import React from 'react';
2
+ import {
3
+ View,
4
+ Image,
5
+ TouchableOpacity,
6
+ ScrollView,
7
+ SafeAreaView,
8
+ StyleSheet,
9
+ } from 'react-native';
10
+ import { IconOutline } from '@ant-design/icons-react-native';
11
+ import { Icon } from '@ant-design/react-native';
12
+ import t from '../../hooks/Common/useTranslations';
13
+
14
+ import { Images, Colors } from '../../configs';
15
+ import Text from '../../commons/Text';
16
+ import Routes from '../../utils/Route';
17
+ import { TESTID } from '../../configs/Constants';
18
+ import { useSCContextSelector } from '../../context';
19
+ import { CommonActions, useNavigation } from '@react-navigation/native';
20
+
21
+ const DrawerContainer = ({ navigation }) => {
22
+ const user = useSCContextSelector((state) => state.auth.account.user);
23
+ const { dispatch } = useNavigation();
24
+ const doLogout = () => {
25
+ const resetAction = CommonActions.reset({
26
+ index: 0,
27
+ routes: [{ name: Routes.Main }],
28
+ });
29
+ dispatch(resetAction);
30
+ };
31
+
32
+ const goToHelp = () => {};
33
+
34
+ const goToAbloutUs = () => {};
35
+
36
+ return (
37
+ <SafeAreaView style={styles.wrap}>
38
+ <ScrollView contentContainerStyle={styles.scrollView}>
39
+ <View style={[styles.row, styles.logoWrap]}>
40
+ <Image
41
+ source={Images.logo}
42
+ style={styles.logo}
43
+ testID={TESTID.SIDE_MENU_LOGO}
44
+ />
45
+
46
+ <View style={styles.avatarBackground}>
47
+ {user.avatar ? (
48
+ <Image
49
+ source={{ uri: user.avatar }}
50
+ style={styles.avatar}
51
+ testID={TESTID.SIDE_MENU_AVATAR_USER}
52
+ />
53
+ ) : (
54
+ <View style={styles.avatar} testID={TESTID.SIDE_MENU_AVATAR_USER}>
55
+ <Icon name={'user'} size={27} />
56
+ </View>
57
+ )}
58
+ <View style={styles.textContainer}>
59
+ <Text
60
+ style={[styles.fullName]}
61
+ testID={TESTID.SIDE_MENU_USER_NAME}
62
+ >
63
+ {user?.name || ''}
64
+ </Text>
65
+ <Text style={[styles.email]} testID={TESTID.SIDE_MENU_USER_PHONE}>
66
+ {user ? user.phone_number : ''}
67
+ </Text>
68
+ </View>
69
+ </View>
70
+ </View>
71
+ <View style={styles.containerRow}>
72
+ <View>
73
+ <Row onPress={goToHelp} image={'global'} name={t('help')} />
74
+ <Row
75
+ onPress={goToAbloutUs}
76
+ image={'mail'}
77
+ name={t('about_us')}
78
+ testID={TESTID.SIDE_MENU_POLICY_ITEM}
79
+ />
80
+ <Row
81
+ onPress={doLogout}
82
+ image={'export'}
83
+ name={t('exit_dev_mode')}
84
+ />
85
+ </View>
86
+ </View>
87
+ </ScrollView>
88
+ </SafeAreaView>
89
+ );
90
+ };
91
+
92
+ export const Row = ({ name, onPress, image, borderBottom, testID }) => {
93
+ return (
94
+ <TouchableOpacity
95
+ onPress={onPress}
96
+ style={[
97
+ styles.row,
98
+ styles.optionWrap,
99
+ borderBottom && styles.borderBottom,
100
+ ]}
101
+ testID={testID}
102
+ >
103
+ <IconOutline name={image} size={24} />
104
+
105
+ <View style={styles.wrapText}>
106
+ <Text style={[styles.text]}>{name}</Text>
107
+ </View>
108
+ </TouchableOpacity>
109
+ );
110
+ };
111
+
112
+ const styles = StyleSheet.create({
113
+ wrapText: {
114
+ flexDirection: 'row',
115
+ marginLeft: 20,
116
+ },
117
+ text: {
118
+ fontSize: 16,
119
+ color: Colors.Gray9,
120
+ },
121
+ wrap: {
122
+ flex: 1,
123
+ flexDirection: 'column',
124
+ backgroundColor: Colors.White,
125
+ },
126
+ scrollView: {
127
+ flex: 1,
128
+ justifyContent: 'space-between',
129
+ },
130
+ row: {
131
+ flexDirection: 'row',
132
+ alignItems: 'center',
133
+ justifyContent: 'flex-start',
134
+ },
135
+ borderBottom: {
136
+ borderBottomColor: Colors.Gray4,
137
+ borderBottomWidth: 1,
138
+ },
139
+ logoWrap: {
140
+ paddingTop: 32,
141
+ paddingLeft: 28,
142
+ paddingRight: 23,
143
+ },
144
+ optionWrap: {
145
+ paddingTop: 20,
146
+ paddingBottom: 20,
147
+ paddingRight: 32,
148
+ },
149
+ logo: {
150
+ width: 32,
151
+ height: 16,
152
+ position: 'absolute',
153
+ top: 10,
154
+ left: 30,
155
+ },
156
+
157
+ // header
158
+ avatarBackground: {
159
+ flexDirection: 'row',
160
+ flex: 1,
161
+ paddingVertical: 22,
162
+ borderBottomColor: Colors.Gray4,
163
+ borderBottomWidth: 1,
164
+ },
165
+ avatar: {
166
+ height: 50,
167
+ width: 50,
168
+ borderRadius: 25,
169
+ borderWidth: 0.5,
170
+ borderColor: Colors.Gray5,
171
+ justifyContent: 'center',
172
+ alignItems: 'center',
173
+ },
174
+ textContainer: {
175
+ marginLeft: 15,
176
+ justifyContent: 'flex-start',
177
+ flex: 1,
178
+ },
179
+ fullName: {
180
+ backgroundColor: Colors.TextTransparent,
181
+ fontSize: 16,
182
+ marginBottom: 6,
183
+ color: Colors.Black,
184
+ fontWeight: 'bold',
185
+ },
186
+ email: {
187
+ backgroundColor: Colors.TextTransparent,
188
+ fontSize: 14,
189
+ color: Colors.Gray8,
190
+ },
191
+ containerRow: {
192
+ paddingHorizontal: 28,
193
+ flex: 1,
194
+ justifyContent: 'space-between',
195
+ },
196
+ });
197
+
198
+ export default DrawerContainer;
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useState } from 'react';
2
- import { SafeAreaView, StyleSheet, TextInput, View } from 'react-native';
2
+ import { StyleSheet, TextInput, View } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
  import { Section, ViewButtonBottom } from '../../commons';
@@ -53,7 +53,7 @@ export const EmergencyContactsAddNew = ({ route }) => {
53
53
  }, [goBack, group.id, t, textName, textPhone]);
54
54
 
55
55
  return (
56
- <SafeAreaView style={styles.wrap}>
56
+ <View style={styles.wrap}>
57
57
  <WrapHeaderScrollable title={t('create_contact')}>
58
58
  <Section type={'border'}>
59
59
  <TextInput
@@ -87,7 +87,7 @@ export const EmergencyContactsAddNew = ({ route }) => {
87
87
  onRightClick={onSave}
88
88
  />
89
89
  </View>
90
- </SafeAreaView>
90
+ </View>
91
91
  );
92
92
  };
93
93
 
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
- import { SafeAreaView, StyleSheet, View, Platform } from 'react-native';
2
+ import { StyleSheet, View } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -70,9 +70,9 @@ export const EmergencyContactsSelectContacts = ({ route }) => {
70
70
  loadMembers(unitId);
71
71
  }, [loadMembers, unitId]);
72
72
  return (
73
- <SafeAreaView style={styles.container}>
73
+ <View style={styles.container}>
74
74
  <WrapHeaderScrollable title={t('select_contacts')} loading={loading}>
75
- <Section type={'border'} style={styles.section}>
75
+ <Section type={'border'}>
76
76
  {dataContact.map((contact, index) => (
77
77
  <RowUser
78
78
  key={contact.id.toString()}
@@ -108,7 +108,7 @@ export const EmergencyContactsSelectContacts = ({ route }) => {
108
108
  onRightClick={goSave}
109
109
  rightDisabled={false}
110
110
  />
111
- </SafeAreaView>
111
+ </View>
112
112
  );
113
113
  };
114
114
 
@@ -117,9 +117,6 @@ const styles = StyleSheet.create({
117
117
  flex: 1,
118
118
  backgroundColor: Colors.Gray2,
119
119
  },
120
- section: {
121
- marginTop: Platform.OS === 'ios' ? 40 : 0,
122
- },
123
120
  buttonRemove: {
124
121
  height: 40,
125
122
  width: 40,
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { act, create } from 'react-test-renderer';
4
+ import Gateway from '..';
5
+
6
+ describe('Test Template screen', () => {
7
+ let tree;
8
+ it('Test render', async () => {
9
+ await act(async () => {
10
+ tree = await create(<Gateway />);
11
+ });
12
+ const instance = tree.root;
13
+ const Views = instance.findAllByType(View);
14
+ expect(Views).toHaveLength(1);
15
+ });
16
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+
4
+ const Gateway = () => {
5
+ return <View />;
6
+ };
7
+
8
+ export default Gateway;
@@ -50,57 +50,18 @@ describe('test NotificationItem', () => {
50
50
  item = { ...item, is_read: false, content_code: '' };
51
51
  });
52
52
  let tree;
53
- const listCase = [
54
- {
55
- content_code: NOTIFICATION_TYPES.REMIND_TO_MAKE_PAYMENT,
56
- screen: Routes.SmartParkingBookingDetails,
57
- params: { id: 1 },
58
- },
59
- {
60
- content_code: NOTIFICATION_TYPES.EXPIRE_PARKING_SESSION,
61
- screen: Routes.SmartParkingBookingDetails,
62
- params: { id: 1 },
63
- },
64
- {
65
- content_code: NOTIFICATION_TYPES.REMIND_TO_SCAN_QR_CODE,
66
- screen: Routes.SmartParkingBookingDetails,
67
- params: { id: 1 },
68
- },
69
- {
70
- content_code: NOTIFICATION_TYPES.BOOKING_SUCCESSFULLY,
71
- screen: Routes.SmartParkingBookingDetails,
72
- params: { id: 1 },
73
- },
74
- {
75
- content_code: NOTIFICATION_TYPES.BOOKING_EXPIRED_AND_VIOLATION_CREATED,
76
- screen: Routes.SmartParkingBookingDetails,
77
- params: { id: 1 },
78
- },
79
- {
80
- content_code: NOTIFICATION_TYPES.MOVE_CAR_WITHOUT_PAY_VIOLATION,
81
- screen: Routes.SmartParkingBookingDetails,
82
- params: { id: 1 },
83
- },
84
- {
85
- content_code: NOTIFICATION_TYPES.PAY_FINE_SUCCESSFULLY,
86
- screen: Routes.SmartParkingBookingDetails,
87
- params: { id: 1 },
88
- },
89
- {
90
- content_code: NOTIFICATION_TYPES.STOP_VIOLATION_FREE_PARKING_ZONE,
91
- screen: Routes.SmartParkingBookingDetails,
92
- params: { id: 1 },
93
- },
94
- {
95
- content_code: NOTIFICATION_TYPES.PAY_FINE_AND_EXTEND_SUCCESSFULLY,
96
- screen: Routes.SmartParkingBookingDetails,
97
- params: { id: 1 },
98
- },
53
+
54
+ const listCase2 = [
55
+ NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT,
56
+ NOTIFICATION_TYPES.NOTIFY_REMOVE_MEMBER,
57
+ NOTIFICATION_TYPES.NOTIFY_MEMBER_LEAVE_UNIT,
58
+ NOTIFICATION_TYPES.NOTIFY_REMOVE_SUB_UNIT,
59
+ NOTIFICATION_TYPES.NOTIFY_REMOVE_DEVICE,
99
60
  ];
100
61
 
101
- for (const notify of listCase) {
102
- test(`create ItemNotification ${notify.content_code}`, () => {
103
- item.content_code = notify.content_code;
62
+ for (const content_code of listCase2) {
63
+ test(`create ItemNotification ${content_code}`, () => {
64
+ item.content_code = content_code;
104
65
  act(() => {
105
66
  tree = create(wrapComponent(item));
106
67
  });
@@ -109,33 +70,23 @@ describe('test NotificationItem', () => {
109
70
  act(() => {
110
71
  button.props.onPress();
111
72
  });
112
- expect(mockNavigate).toHaveBeenCalledWith(Routes.SmartParkingStack, {
113
- screen: notify.screen,
114
- params: { id: 1 },
115
- });
73
+ expect(mockNavigate).not.toHaveBeenCalled();
116
74
  });
117
75
  }
118
76
 
119
- const listCaseSmartParking2 = [
120
- {
121
- content_code: NOTIFICATION_TYPES.USER_CANCEL,
122
- screen: Routes.MyBookingList,
123
- params: { tab: 1 },
124
- },
125
- {
126
- content_code: NOTIFICATION_TYPES.SYSTEM_CANCEL_NO_PAYMENT,
127
- screen: Routes.MyBookingList,
128
- params: { tab: 1 },
129
- },
130
- {
131
- content_code: NOTIFICATION_TYPES.PARKING_COMPLETED,
132
- screen: Routes.MyBookingList,
133
- params: { tab: 1 },
134
- },
77
+ const listCaseUnitDetail = [
78
+ NOTIFICATION_TYPES.NOTIFY_RENAME_UNIT,
79
+ NOTIFICATION_TYPES.NOTIFY_UPDATE_ADDRESS,
80
+ NOTIFICATION_TYPES.NOTIFY_RENAME_SUB_UNIT,
81
+ NOTIFICATION_TYPES.NOTIFY_INVITE_MEMBER,
135
82
  ];
136
- for (const notify of listCaseSmartParking2) {
137
- test(`create ItemNotification ${notify.content_code}`, () => {
138
- item.content_code = notify.content_code;
83
+
84
+ for (const content_code of listCaseUnitDetail) {
85
+ test(`create ItemNotification ${content_code}`, () => {
86
+ item.content_code = content_code;
87
+ item.params = {
88
+ unit_id: 1,
89
+ };
139
90
  act(() => {
140
91
  tree = create(wrapComponent(item));
141
92
  });
@@ -144,25 +95,24 @@ describe('test NotificationItem', () => {
144
95
  act(() => {
145
96
  button.props.onPress();
146
97
  });
147
- expect(mockNavigate).toHaveBeenCalledWith(Routes.SmartParkingStack, {
148
- screen: notify.screen,
149
- params: { tab: 1 },
98
+ expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
99
+ screen: Routes.UnitDetail,
100
+ params: {
101
+ unitId: 1,
102
+ },
150
103
  });
151
104
  });
152
105
  }
153
106
 
154
- const listCase2 = [
155
- NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT,
156
- NOTIFICATION_TYPES.NOTIFY_REMOVE_MEMBER,
157
- NOTIFICATION_TYPES.NOTIFY_MEMBER_LEAVE_UNIT,
158
- NOTIFICATION_TYPES.NOTIFY_REMOVE_SUB_UNIT,
159
- NOTIFICATION_TYPES.NOTIFY_REMOVE_DEVICE,
160
- 'default case',
161
- ];
107
+ const listCaseDeviceDetail = [NOTIFICATION_TYPES.NOTIFY_DEVICE_DISCONNECT];
162
108
 
163
- for (const content_code of listCase2) {
109
+ for (const content_code of listCaseDeviceDetail) {
164
110
  test(`create ItemNotification ${content_code}`, () => {
165
111
  item.content_code = content_code;
112
+ item.params = {
113
+ unit_id: 1,
114
+ sensor_id: 1,
115
+ };
166
116
  act(() => {
167
117
  tree = create(wrapComponent(item));
168
118
  });
@@ -171,7 +121,13 @@ describe('test NotificationItem', () => {
171
121
  act(() => {
172
122
  button.props.onPress();
173
123
  });
174
- expect(mockNavigate).not.toHaveBeenCalled();
124
+ expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
125
+ screen: Routes.DeviceDetail,
126
+ params: {
127
+ unitId: 1,
128
+ sensorId: 1,
129
+ },
130
+ });
175
131
  });
176
132
  }
177
133
 
@@ -208,6 +164,21 @@ describe('test NotificationItem', () => {
208
164
  });
209
165
  }
210
166
 
167
+ test('test case NOTIFY_INDICATOR no sensor_type', () => {
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
+ act(() => {
175
+ tree = create(wrapComponent(item));
176
+ });
177
+ const instance = tree.root;
178
+ const button = instance.findAllByType(TouchableOpacity);
179
+ expect(button).toHaveLength(0);
180
+ });
181
+
211
182
  const listSensorType2 = [
212
183
  SENSOR_TYPE.SMOKE,
213
184
  SENSOR_TYPE.FIRE,
@@ -274,25 +245,8 @@ describe('test NotificationItem', () => {
274
245
  tree = create(wrapComponent(item));
275
246
  });
276
247
  const instance = tree.root;
277
- const button = instance.findByType(TouchableOpacity);
278
- act(() => {
279
- button.props.onPress();
280
- });
281
- expect(mockNavigate).not.toHaveBeenCalledWith();
282
- });
283
-
284
- test('test render Notify params is object', () => {
285
- item.content_code = 'NEW CASE';
286
- item.params = { unit_id: 1 };
287
- act(() => {
288
- tree = create(wrapComponent(item));
289
- });
290
- const instance = tree.root;
291
- const button = instance.findByType(TouchableOpacity);
292
- act(() => {
293
- button.props.onPress();
294
- });
295
- expect(mockNavigate).not.toHaveBeenCalledWith();
248
+ const button = instance.findAllByType(TouchableOpacity);
249
+ expect(button).toHaveLength(0);
296
250
  });
297
251
 
298
252
  test('test notify emergency ', () => {
@@ -344,4 +298,20 @@ describe('test NotificationItem', () => {
344
298
  },
345
299
  });
346
300
  });
301
+
302
+ test('test notify emergency not params type', () => {
303
+ item.content_code = NOTIFICATION_TYPES.NOTIFY_EMERGENCY;
304
+ item.params = {
305
+ unit_id: 1,
306
+ sensor_id: 1,
307
+ type: null,
308
+ };
309
+
310
+ act(() => {
311
+ tree = create(wrapComponent(item));
312
+ });
313
+ const instance = tree.root;
314
+ const button = instance.findAllByType(TouchableOpacity);
315
+ expect(button).toHaveLength(0);
316
+ });
347
317
  });