@eohjsc/react-native-smart-city 0.3.42 → 0.3.45

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 (26) hide show
  1. package/package.json +1 -1
  2. package/src/commons/Action/ItemQuickAction.js +20 -52
  3. package/src/commons/Action/__test__/ItemQuickAction.test.js +73 -235
  4. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
  5. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +4 -3
  6. package/src/commons/AlertAction/index.js +1 -1
  7. package/src/configs/Constants.js +1 -0
  8. package/src/iot/RemoteControl/Bluetooth.js +19 -3
  9. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +39 -11
  10. package/src/navigations/UnitStack.js +2 -1
  11. package/src/screens/AddNewGateway/ConnectingWifiDevice.js +48 -23
  12. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +14 -12
  13. package/src/screens/AddNewGateway/RenameNewDevices.js +36 -16
  14. package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +0 -8
  15. package/src/screens/AddNewGateway/ScanGatewayQR.js +2 -2
  16. package/src/screens/AddNewGateway/ScanModbusQR.js +4 -1
  17. package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +2 -2
  18. package/src/screens/AddNewGateway/SelectDeviceType.js +3 -3
  19. package/src/screens/AddNewGateway/ShareWifiPassword.js +7 -2
  20. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +9 -1
  21. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +1 -1
  22. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +12 -0
  23. package/src/screens/Device/detail.js +7 -3
  24. package/src/screens/UVIndexGuide/index.js +8 -13
  25. package/src/utils/Apis/axios.js +5 -0
  26. package/src/utils/__test__/Utils.test.js +115 -0
@@ -1,4 +1,4 @@
1
- import React, { memo, useCallback, useMemo } from 'react';
1
+ import React, { memo, useMemo } from 'react';
2
2
  import {
3
3
  View,
4
4
  ScrollView,
@@ -6,8 +6,8 @@ import {
6
6
  TouchableOpacity,
7
7
  SafeAreaView,
8
8
  } from 'react-native';
9
- import { useTranslations } from '../../hooks/Common/useTranslations';
10
9
 
10
+ import { useTranslations } from '../../hooks/Common/useTranslations';
11
11
  import { Colors, Theme } from '../../configs';
12
12
  import Text from '../../commons/Text';
13
13
  import useTitleHeader from '../../hooks/Common/useTitleHeader';
@@ -35,31 +35,31 @@ const UVIndexGuide = memo(() => {
35
35
  {
36
36
  type: 'Low',
37
37
  title: t('1-2 Low'),
38
- color: '#52C41A',
38
+ color: Colors.Green6,
39
39
  des: t('text_1_2_uv'),
40
40
  },
41
41
  {
42
42
  type: 'Moderate',
43
43
  title: t('3-5 Moderate'),
44
- color: '#FADB14',
44
+ color: Colors.Yellow6,
45
45
  des: t('text_3_5_uv'),
46
46
  },
47
47
  {
48
48
  type: 'High',
49
49
  title: t('6-7 High'),
50
- color: '#FA8C16',
50
+ color: Colors.Orange6,
51
51
  des: t('text_6_7_uv'),
52
52
  },
53
53
  {
54
54
  type: 'Very High',
55
55
  title: t('8-10 Very High'),
56
- color: '#F5222D',
56
+ color: Colors.Red6,
57
57
  des: t('text_8_10_uv'),
58
58
  },
59
59
  {
60
60
  type: 'Extreme',
61
61
  title: t('11+ Extreme'),
62
- color: '#722ED1',
62
+ color: Colors.Purple6,
63
63
  des: t('text_11+_uv'),
64
64
  },
65
65
  ],
@@ -70,7 +70,6 @@ const UVIndexGuide = memo(() => {
70
70
 
71
71
  const { titles, uvIndex } = data;
72
72
 
73
- const onPress = useCallback((item) => {}, []);
74
73
  return (
75
74
  <SafeAreaView style={styles.container}>
76
75
  <ScrollView style={styles.container} scrollIndicatorInsets={{ right: 1 }}>
@@ -100,11 +99,7 @@ const UVIndexGuide = memo(() => {
100
99
  {uvIndex.map((item, index) => {
101
100
  const { title, color, des } = item;
102
101
  return (
103
- <TouchableOpacity
104
- style={styles.containerUV}
105
- key={index.toString()}
106
- onPress={() => onPress(item)}
107
- >
102
+ <TouchableOpacity style={styles.containerUV} key={index.toString()}>
108
103
  <View
109
104
  style={{
110
105
  ...styles.box,
@@ -59,6 +59,11 @@ const parseErrorResponse = async (error) => {
59
59
 
60
60
  if (typeof message === 'string') {
61
61
  let hideError = false;
62
+
63
+ if (message.includes(PROBLEM_CODE.ADDRESS_CHANGING)) {
64
+ hideError = true;
65
+ }
66
+
62
67
  if (message === 'Network Error') {
63
68
  const netState = await NetInfo.fetch();
64
69
  if (!netState.isConnected) {
@@ -1,9 +1,24 @@
1
+ import { Linking } from 'react-native';
2
+ import { act } from 'react-test-renderer';
3
+ import Toast from 'react-native-toast-message';
4
+
5
+ import api from '../Apis/axios';
1
6
  import {
2
7
  validateEmail,
3
8
  formatMoney,
4
9
  insertToString,
5
10
  removeFromString,
6
11
  isObjectEmpty,
12
+ setAxiosDefaultLanguage,
13
+ deleteDefaultAuthToken,
14
+ setAxiosDefaultAuthToken,
15
+ shortEmailName,
16
+ formatNumberCompact,
17
+ standardizeCameraScreenSize,
18
+ openMapDirection,
19
+ ToastBottomHelper,
20
+ object_Ids,
21
+ notImplemented,
7
22
  } from '../Utils';
8
23
 
9
24
  describe('Test utils', () => {
@@ -11,20 +26,120 @@ describe('Test utils', () => {
11
26
  const result = validateEmail('eoh.2020@gmail.com');
12
27
  expect(result).toEqual(true);
13
28
  });
29
+
14
30
  it('test formatMoney', async () => {
15
31
  const result = formatMoney(10000);
16
32
  expect(result).toEqual('10.000 đ');
17
33
  });
34
+
18
35
  it('test insertToString', async () => {
19
36
  const result = insertToString('test', 1, 2);
20
37
  expect(result).toEqual('t2est');
21
38
  });
39
+
22
40
  it('test removeFromString', async () => {
23
41
  const result = removeFromString('test', 1);
24
42
  expect(result).toEqual('tst');
25
43
  });
44
+
26
45
  it('test isObjectEmpty', async () => {
27
46
  const result = isObjectEmpty({ id: 1 });
28
47
  expect(result).toEqual(false);
29
48
  });
49
+
50
+ it('test setAxiosDefaultLanguage', () => {
51
+ setAxiosDefaultLanguage('en');
52
+ expect(api.headers['Accept-Language']).toBe('en');
53
+ });
54
+
55
+ it('test setAxiosDefaultAuthToken', () => {
56
+ setAxiosDefaultAuthToken('token');
57
+ expect(api.headers.Authorization).toBe('Token token');
58
+ });
59
+
60
+ it('test deleteDefaultAuthToken', () => {
61
+ deleteDefaultAuthToken();
62
+ expect(api.headers.Authorization).toBe(undefined);
63
+ });
64
+
65
+ it('test shortEmailName', async () => {
66
+ const shortEmail = await shortEmailName('test@gmail.com');
67
+ expect(shortEmail).toBe('test');
68
+ });
69
+
70
+ it('test formatNumberCompact', async () => {
71
+ const number = await formatNumberCompact(10000);
72
+ expect(number).toBe('10K');
73
+ });
74
+
75
+ it('test standardizeCameraScreenSize', async () => {
76
+ const size = await standardizeCameraScreenSize(100);
77
+ expect(size).toEqual({
78
+ standardizeWidth: 98,
79
+ standardizeHeight: 42,
80
+ });
81
+ });
82
+
83
+ it('Test openMapDirection', async () => {
84
+ // Linking.openURL = jest.fn(() => Promise.reject('mockError'));
85
+ await act(async () => {
86
+ await openMapDirection({ lat: 10, lng: 10 })();
87
+ });
88
+ expect(Linking.openURL).toBeCalledWith(
89
+ 'https://www.google.com/maps/dir/?api=1&origin=&destination=10,10'
90
+ );
91
+ });
92
+
93
+ it('test ToastBottomHelper', async () => {
94
+ await act(async () => {
95
+ ToastBottomHelper.success('msg', 'line2');
96
+ });
97
+ expect(Toast.show).toBeCalledWith({
98
+ position: 'bottom',
99
+ text1: 'msg',
100
+ text2: 'line2',
101
+ type: 'success',
102
+ visibilityTime: 1000,
103
+ });
104
+
105
+ await act(async () => {
106
+ ToastBottomHelper.error('msg', 'line2');
107
+ });
108
+ expect(Toast.show).toBeCalledWith({
109
+ position: 'bottom',
110
+ text1: 'msg',
111
+ text2: 'line2',
112
+ type: 'error',
113
+ visibilityTime: 1000,
114
+ });
115
+
116
+ await act(async () => {
117
+ ToastBottomHelper.info('msg', 'line2');
118
+ });
119
+ expect(Toast.show).toBeCalledWith({
120
+ position: 'bottom',
121
+ text1: 'msg',
122
+ text2: 'line2',
123
+ type: 'info',
124
+ visibilityTime: 1000,
125
+ });
126
+ });
127
+
128
+ it('test object_Ids', async () => {
129
+ const data = await object_Ids([{ id: 1, device: [], actions: [] }]);
130
+ expect(data).toEqual({
131
+ stationIds: [1],
132
+ deviceIds: [],
133
+ actionIds: [],
134
+ configIds: [],
135
+ });
136
+ });
137
+
138
+ it('test notImplemented', async () => {
139
+ const mockTranslate = jest.fn();
140
+ await act(async () => {
141
+ notImplemented(mockTranslate);
142
+ });
143
+ expect(mockTranslate).toBeCalledWith('feature_under_development');
144
+ });
30
145
  });