@eohjsc/react-native-smart-city 0.4.40 → 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 (41) hide show
  1. package/android/build.gradle +24 -19
  2. package/package.json +12 -14
  3. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +1 -2
  4. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +11 -1
  5. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
  6. package/src/commons/Dashboard/MyUnit/index.js +2 -2
  7. package/src/commons/DateTimeRangeChange/index.js +3 -3
  8. package/src/commons/Device/HistoryChart.js +1 -1
  9. package/src/commons/Device/HorizontalBarChart.js +4 -3
  10. package/src/commons/Device/LinearChart.js +5 -3
  11. package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
  12. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
  13. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
  14. package/src/commons/Processing/index.js +0 -1
  15. package/src/commons/Processing/styles.js +0 -3
  16. package/src/commons/Unit/HeaderUnit/index.js +8 -15
  17. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
  18. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
  19. package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
  20. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
  21. package/src/hooks/useMqtt.js +2 -5
  22. package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
  23. package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
  24. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
  25. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +2 -19
  26. package/src/screens/Automate/AddNewAction/__test__/{SetupConfigCondition.test.js → SetupSensor.test.js} +0 -97
  27. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
  28. package/src/screens/ChangePosition/__test__/index.test.js +32 -34
  29. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
  30. package/src/screens/Device/components/ChartWrapper.js +12 -14
  31. package/src/screens/Device/components/VisualChart.js +3 -17
  32. package/src/screens/Device/components/__test__/VisualChart.test.js +15 -12
  33. package/src/screens/Device/detail.js +2 -3
  34. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
  35. package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
  36. package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
  37. package/src/screens/Unit/__test__/SelectAddress.test.js +12 -5
  38. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
  39. package/src/utils/Apis/axios.js +0 -1
  40. package/src/utils/Monitor.js +2 -2
  41. package/src/commons/Highcharts/index.js +0 -111
@@ -10,17 +10,17 @@
10
10
  // original location:
11
11
  // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12
12
 
13
- def DEFAULT_COMPILE_SDK_VERSION = 33
14
- def DEFAULT_BUILD_TOOLS_VERSION = '33.0.0'
15
- def DEFAULT_MIN_SDK_VERSION = 24
16
- def DEFAULT_TARGET_SDK_VERSION = 33
13
+ def DEFAULT_COMPILE_SDK_VERSION = 28
14
+ def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
15
+ def DEFAULT_MIN_SDK_VERSION = 16
16
+ def DEFAULT_TARGET_SDK_VERSION = 28
17
17
 
18
18
  def safeExtGet(prop, fallback) {
19
19
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20
20
  }
21
21
 
22
22
  apply plugin: 'com.android.library'
23
- apply plugin: 'maven-publish'
23
+ apply plugin: 'maven'
24
24
 
25
25
  buildscript {
26
26
  // The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -38,6 +38,9 @@ buildscript {
38
38
  }
39
39
  }
40
40
 
41
+ apply plugin: 'com.android.library'
42
+ apply plugin: 'maven'
43
+
41
44
  android {
42
45
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
43
46
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
@@ -103,17 +106,17 @@ def configureReactNativePom(def pom) {
103
106
  afterEvaluate { project ->
104
107
  // some Gradle build hooks ref:
105
108
  // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
106
- // task androidJavadoc(type: Javadoc) {
107
- // source = android.sourceSets.main.java.srcDirs
108
- // classpath += files(android.bootClasspath)
109
- // classpath += files(project.getConfigurations().getByName('compile').asList())
110
- // include '**/*.java'
111
- // }
112
-
113
- // task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
114
- // classifier = 'javadoc'
115
- // from androidJavadoc.destinationDir
116
- // }
109
+ task androidJavadoc(type: Javadoc) {
110
+ source = android.sourceSets.main.java.srcDirs
111
+ classpath += files(android.bootClasspath)
112
+ classpath += files(project.getConfigurations().getByName('compile').asList())
113
+ include '**/*.java'
114
+ }
115
+
116
+ task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
117
+ classifier = 'javadoc'
118
+ from androidJavadoc.destinationDir
119
+ }
117
120
 
118
121
  task androidSourcesJar(type: Jar) {
119
122
  classifier = 'sources'
@@ -132,13 +135,15 @@ afterEvaluate { project ->
132
135
 
133
136
  artifacts {
134
137
  archives androidSourcesJar
135
- // archives androidJavadocJar
138
+ archives androidJavadocJar
136
139
  }
137
140
 
138
141
  task installArchives(type: Upload) {
139
142
  configuration = configurations.archives
140
- repositories.maven {
141
- url = uri("file://${projectDir}/../android/maven")
143
+ repositories.mavenDeployer {
144
+ // Deploy to react-native-event-bridge/maven, ready to publish to npm
145
+ repository url: "file://${projectDir}/../android/maven"
146
+ configureReactNativePom pom
142
147
  }
143
148
  }
144
149
  }
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.4.40",
4
+ "version": "0.4.42",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -65,9 +65,7 @@
65
65
  "peerDependencies": {
66
66
  "@react-native-community/clipboard": "*",
67
67
  "react": "*",
68
- "react-native": "*",
69
- "react-native-modal": "*",
70
- "react-native-modal-datetime-picker": "*"
68
+ "react-native": "*"
71
69
  },
72
70
  "devDependencies": {
73
71
  "@babel/core": "^7.12.9",
@@ -102,8 +100,8 @@
102
100
  "dependencies": {
103
101
  "@ant-design/icons-react-native": "^2.2.1",
104
102
  "@ant-design/react-native": "^4.0.5",
105
- "@react-native-picker/picker": "^1.16.7",
106
103
  "@babel/helper-environment-visitor": "^7.16.7",
104
+ "@eohjsc/highcharts": "^1.0.9",
107
105
  "@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
108
106
  "@formatjs/intl-getcanonicallocales": "^1.4.5",
109
107
  "@formatjs/intl-numberformat": "^5.6.2",
@@ -113,14 +111,16 @@
113
111
  "@miblanchard/react-native-slider": "^2.2.0",
114
112
  "@react-native-clipboard/clipboard": "^1.11.1",
115
113
  "@react-native-community/async-storage": "^1.12.1",
116
- "@react-native-community/cameraroll": "4.1.2",
114
+ "@react-native-community/cameraroll": "^4.0.0",
117
115
  "@react-native-community/checkbox": "^0.5.5",
118
- "@react-native-community/datetimepicker": "^7.0.1",
116
+ "@react-native-community/datetimepicker": "https://github.com/hinh-eoh/datepicker",
119
117
  "@react-native-community/geolocation": "^2.0.2",
120
118
  "@react-native-community/masked-view": "^0.1.10",
121
119
  "@react-native-community/netinfo": "^9.3.4",
122
120
  "@react-native-community/segmented-control": "^2.1.1",
123
121
  "@react-native-community/slider": "^3.0.3",
122
+ "@react-native-community/toolbar-android": "^0.1.0-rc.2",
123
+ "@react-native-picker/picker": "^1.16.7",
124
124
  "@react-navigation/bottom-tabs": "^5.8.0",
125
125
  "@react-navigation/drawer": "^5.9.0",
126
126
  "@react-navigation/native": "^5.7.0",
@@ -130,7 +130,6 @@
130
130
  "apisauce": "^2.1.5",
131
131
  "axios": "^0.19.2",
132
132
  "base-64": "^1.0.0",
133
- "buffer": "^6.0.3",
134
133
  "deprecated-react-native-prop-types": "^2.3.0",
135
134
  "dotenv": "^8.2.0",
136
135
  "google-libphonenumber": "^3.2.10",
@@ -138,8 +137,7 @@
138
137
  "i18n-js": "^3.7.1",
139
138
  "i18next": "^20.1.0",
140
139
  "lodash": "^4.17.19",
141
- "lottie-ios": "3.4.1",
142
- "lottie-react-native": "5.1.4",
140
+ "lottie-react-native": "4.0.3",
143
141
  "moment": "^2.27.0",
144
142
  "moment-timezone": "^0.5.32",
145
143
  "numeral": "^2.0.6",
@@ -173,7 +171,7 @@
173
171
  "react-native-draggable-flatlist": "^2.6.2",
174
172
  "react-native-fast-image": "^8.3.2",
175
173
  "react-native-geocoder": "^0.5.0",
176
- "react-native-gesture-handler": "^2.10.0",
174
+ "react-native-gesture-handler": "^1.7.0",
177
175
  "react-native-get-location": "^2.0.0",
178
176
  "react-native-image-crop-picker": "^0.37.2",
179
177
  "react-native-image-resizer": "^1.4.5",
@@ -183,8 +181,8 @@
183
181
  "react-native-localize": "^1.4.1",
184
182
  "react-native-maps": "0.27.1",
185
183
  "react-native-maps-directions": "^1.8.0",
186
- "react-native-modal": "^13.0.1",
187
- "react-native-modal-datetime-picker": "15.0.0",
184
+ "react-native-modal": "^11.5.6",
185
+ "react-native-modal-datetime-picker": "^8.9.3",
188
186
  "react-native-new-snap-carousel": "^3.9.3",
189
187
  "react-native-onesignal": "^4.3.1",
190
188
  "react-native-pager-view": "^5.4.1",
@@ -203,7 +201,7 @@
203
201
  "react-native-udp": "^4.1.3",
204
202
  "react-native-version-check": "^3.4.2",
205
203
  "react-native-vlc-media-player": "^1.0.41",
206
- "react-native-webview": "^12.0.2",
204
+ "react-native-webview": "11.17.2",
207
205
  "react-native-wheel-color-picker": "^1.2.0",
208
206
  "react-native-wheel-scrollview-picker": "^1.2.2",
209
207
  "react-native-wifi-reborn": "^4.5.0",
@@ -115,7 +115,6 @@ describe('Test ColorPickerTemplate', () => {
115
115
  await act(async () => {
116
116
  await wheelpicker.props.onStart();
117
117
  });
118
- // NOTE: Hinh will fix it later
119
- expect(mockSetAction).not.toBeCalled();
118
+ expect(mockSetAction).toBeCalled();
120
119
  });
121
120
  });
@@ -1,9 +1,14 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
4
  import { DEVICE_TYPE } from '../../../configs/Constants';
5
5
  import TwoButtonTemplate from '../TwoButtonTemplate';
6
6
 
7
+ jest.mock('react', () => ({
8
+ ...jest.requireActual('react'),
9
+ useState: jest.fn(),
10
+ }));
11
+
7
12
  jest.mock('@react-navigation/native', () => {
8
13
  return {
9
14
  ...jest.requireActual('@react-navigation/native'),
@@ -68,7 +73,11 @@ describe('Test TwoButtonTemplate', () => {
68
73
  };
69
74
  let wrapper;
70
75
 
76
+ const setState = jest.fn();
77
+ useState.mockImplementation((init) => [init, setState]);
78
+
71
79
  const assertRender = async (state, text) => {
80
+ useState.mockImplementationOnce((init) => [state, setState]);
72
81
  const mockDoAction = jest.fn();
73
82
  await act(async () => {
74
83
  wrapper = create(
@@ -92,6 +101,7 @@ describe('Test TwoButtonTemplate', () => {
92
101
  });
93
102
 
94
103
  const assertActionCall = async (state, action_data) => {
104
+ useState.mockImplementationOnce((init) => [state, setState]);
95
105
  const mockDoAction = jest.fn();
96
106
  await act(async () => {
97
107
  wrapper = create(
@@ -12,6 +12,7 @@ import { API } from '../../../../configs';
12
12
  import { TouchableOpacity } from 'react-native';
13
13
  import api from '../../../../utils/Apis/axios';
14
14
  import SharedUnit from '../../../Unit/SharedUnit';
15
+ import { Action } from '../../../../context/actionType';
15
16
 
16
17
  const mock = new MockAdapter(api.axiosInstance);
17
18
 
@@ -74,6 +75,10 @@ describe('Test MyPinnedSharedUnit', () => {
74
75
  goToAllSharedUnits.props.onPress();
75
76
  });
76
77
  expect(mockedNavigate).toHaveBeenCalled();
78
+ expect(mockSetAction).toBeCalledWith(
79
+ Action.IS_CHECK_CLEAR_CACHE_UNITS,
80
+ false
81
+ );
77
82
  });
78
83
 
79
84
  it('render without item', async () => {
@@ -50,10 +50,10 @@ const MyUnit = ({ refreshing }) => {
50
50
  const [slideIndex, setSlideIndex] = useState(0);
51
51
  const { setAction } = useContext(SCContext);
52
52
  const isDeleteUnitSuccessFully = useSCContextSelector(
53
- (state) => state?.app?.isDeleteUnitSuccessFully
53
+ (state) => state.app.isDeleteUnitSuccessFully
54
54
  );
55
55
  const isNeedUpdateCache = useSCContextSelector(
56
- (state) => state?.app?.isNeedUpdateCache
56
+ (state) => state.app.isNeedUpdateCache
57
57
  );
58
58
 
59
59
  const {
@@ -119,7 +119,7 @@ const DateTimeRangeChange = memo(
119
119
  </View>
120
120
  <DateTimePickerModal
121
121
  isVisible={eventPicker.showModalStart}
122
- date={startDate._d}
122
+ date={startDate.valueOf()}
123
123
  mode={mode}
124
124
  onConfirm={onConfirmStart}
125
125
  onCancel={onCancel}
@@ -132,7 +132,7 @@ const DateTimeRangeChange = memo(
132
132
  />
133
133
  <DateTimePickerModal
134
134
  isVisible={eventPicker.showModalEnd}
135
- date={endDate._d}
135
+ date={endDate.valueOf()}
136
136
  mode={mode}
137
137
  onConfirm={onConfirmEnd}
138
138
  onCancel={onCancel}
@@ -142,7 +142,7 @@ const DateTimeRangeChange = memo(
142
142
  cancelTextIOS={t('cancel')}
143
143
  confirmTextIOS={t('confirm')}
144
144
  maximumDate={new Date()}
145
- minimumDate={startDate._d}
145
+ minimumDate={startDate.valueOf()}
146
146
  />
147
147
  </View>
148
148
  );
@@ -28,7 +28,7 @@ const HistoryChart = memo(
28
28
  setStartDate,
29
29
  groupBy,
30
30
  setGroupBy,
31
- configuration = {},
31
+ configuration,
32
32
  }) => {
33
33
  const t = useTranslations();
34
34
  const [price, setPrice] = useState(null);
@@ -1,10 +1,10 @@
1
1
  import React, { memo, useEffect, useMemo, useState } from 'react';
2
2
  import { View, StyleSheet } from 'react-native';
3
3
  import { isEmpty } from 'lodash';
4
+ import HighchartsReactNative from '@eohjsc/highcharts';
4
5
 
5
6
  import { Colors } from '../../configs';
6
7
  import { getMaxValueIndex } from '../../utils/chartHelper/getMaxValueIndex';
7
- import Highcharts from '../Highcharts';
8
8
 
9
9
  const HorizontalBarChart = memo(({ datas, config }) => {
10
10
  const [chartOptions, setChartOptions] = useState({
@@ -152,9 +152,10 @@ const HorizontalBarChart = memo(({ datas, config }) => {
152
152
 
153
153
  return (
154
154
  <View style={[styles.container, { height: heightChart }]}>
155
- <Highcharts
156
- styles={[styles.chartStyle, styles.webviewStyle]}
155
+ <HighchartsReactNative
156
+ styles={styles.chartStyle}
157
157
  options={chartOptions}
158
+ webviewStyles={styles.webviewStyle}
158
159
  />
159
160
  </View>
160
161
  );
@@ -1,8 +1,8 @@
1
1
  import React, { useState, useEffect, useCallback } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
+ import HighchartsReactNative from '@eohjsc/highcharts';
3
4
  import moment from 'moment';
4
5
  import { Colors } from '../../configs';
5
- import Highcharts from '../Highcharts';
6
6
 
7
7
  const convertData = (data = []) => {
8
8
  let arr = [];
@@ -108,8 +108,10 @@ function LinearChart({ datas }) {
108
108
 
109
109
  return (
110
110
  <View style={styles.container}>
111
- <Highcharts
112
- styles={[styles.chartStyle, styles.webviewStyle]}
111
+ {/* // TODO : Hinh will research to fix warning Highchart*/}
112
+ <HighchartsReactNative
113
+ styles={styles.chartStyle}
114
+ webviewStyles={styles.webviewStyle}
113
115
  options={options}
114
116
  />
115
117
  </View>
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  import React from 'react';
3
2
  import renderer, { act } from 'react-test-renderer';
4
3
  import DraggableFlatList from 'react-native-draggable-flatlist';
@@ -13,7 +12,6 @@ const wrapComponent = ({ ...rest }) => (
13
12
  </SCProvider>
14
13
  );
15
14
 
16
- // NOTE: Hinh will fix it later
17
15
  describe('Test FlatListDnD', () => {
18
16
  let tree;
19
17
  let setData = jest.fn();
@@ -21,31 +19,31 @@ describe('Test FlatListDnD', () => {
21
19
  let renderItem = () => <></>;
22
20
 
23
21
  it('render FlatListDnD onDragEndCT', async () => {
24
- // const onDragEndCT = jest.fn();
25
- // await act(async () => {
26
- // tree = renderer.create(
27
- // wrapComponent({ data, setData, onDragEndCT, renderItem })
28
- // );
29
- // });
30
- // const instance = tree.root;
31
- // const draggableFlatList = instance.findAllByType(DraggableFlatList);
32
- // expect(draggableFlatList.length).toBe(1);
33
- // await act(async () => {
34
- // draggableFlatList[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
35
- // });
36
- // expect(setData).toBeCalledWith([{ id: 2 }, { id: 1 }]);
22
+ const onDragEndCT = jest.fn();
23
+ await act(async () => {
24
+ tree = renderer.create(
25
+ wrapComponent({ data, setData, onDragEndCT, renderItem })
26
+ );
27
+ });
28
+ const instance = tree.root;
29
+ const draggableFlatList = instance.findAllByType(DraggableFlatList);
30
+ expect(draggableFlatList.length).toBe(1);
31
+ await act(async () => {
32
+ draggableFlatList[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
33
+ });
34
+ expect(setData).toBeCalledWith([{ id: 2 }, { id: 1 }]);
37
35
  });
38
36
 
39
- // it('render FlatListDnD onDragEnd', async () => {
40
- // await act(async () => {
41
- // tree = renderer.create(wrapComponent({ data, setData, renderItem }));
42
- // });
43
- // const instance = tree.root;
44
- // const draggableFlatList = instance.findAllByType(DraggableFlatList);
45
- // expect(draggableFlatList.length).toBe(1);
46
- // await act(async () => {
47
- // draggableFlatList[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
48
- // });
49
- // expect(setData).toBeCalledWith([{ id: 2 }, { id: 1 }]);
50
- // });
37
+ it('render FlatListDnD onDragEnd', async () => {
38
+ await act(async () => {
39
+ tree = renderer.create(wrapComponent({ data, setData, renderItem }));
40
+ });
41
+ const instance = tree.root;
42
+ const draggableFlatList = instance.findAllByType(DraggableFlatList);
43
+ expect(draggableFlatList.length).toBe(1);
44
+ await act(async () => {
45
+ draggableFlatList[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
46
+ });
47
+ expect(setData).toBeCalledWith([{ id: 2 }, { id: 1 }]);
48
+ });
51
49
  });
@@ -1,12 +1,22 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
3
  import { TouchableOpacity } from 'react-native';
4
4
 
5
5
  import { AccessibilityLabel } from '../../../configs/Constants';
6
6
  import GroupCheckBox from '..';
7
7
 
8
+ jest.mock('react', () => ({
9
+ ...jest.requireActual('react'),
10
+ useState: jest.fn(),
11
+ }));
12
+
8
13
  describe('Test Group CheckBox', () => {
9
14
  let tree;
15
+ const mockSetState = () => {
16
+ const setState = jest.fn();
17
+ useState.mockImplementation((init) => [init, setState]);
18
+ return setState;
19
+ };
10
20
 
11
21
  const findGroupCheckBoxItem = (instance) => {
12
22
  const item = instance.find(
@@ -24,6 +34,7 @@ describe('Test Group CheckBox', () => {
24
34
  description: 'description',
25
35
  },
26
36
  ];
37
+ mockSetState();
27
38
  await act(async () => {
28
39
  tree = await create(<GroupCheckBox data={data} />);
29
40
  });
@@ -40,6 +51,7 @@ describe('Test Group CheckBox', () => {
40
51
  },
41
52
  ];
42
53
  const mockFunc = jest.fn();
54
+ const setState = mockSetState();
43
55
  await act(async () => {
44
56
  tree = await create(
45
57
  <GroupCheckBox data={data} onSelect={mockFunc} multiple />
@@ -50,6 +62,9 @@ describe('Test Group CheckBox', () => {
50
62
  await act(async () => {
51
63
  item.props.onSelect(0);
52
64
  });
65
+ expect(setState).toHaveBeenCalledTimes(2);
66
+ expect(setState).toHaveBeenNthCalledWith(1, [0]);
67
+ expect(setState).toHaveBeenNthCalledWith(2, [0]);
53
68
  expect(mockFunc).toHaveBeenCalledWith([
54
69
  { description: 'description', source: 'source', title: 'testItem' },
55
70
  ]);
@@ -70,6 +85,7 @@ describe('Test Group CheckBox', () => {
70
85
  },
71
86
  ];
72
87
  const mockFunc = jest.fn();
88
+ const setState = mockSetState();
73
89
  await act(async () => {
74
90
  tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
75
91
  });
@@ -78,6 +94,8 @@ describe('Test Group CheckBox', () => {
78
94
  await act(async () => {
79
95
  item.props.onSelect(0);
80
96
  });
97
+ expect(setState).toHaveBeenNthCalledWith(1, [0]);
98
+ expect(setState).toHaveBeenNthCalledWith(2, [0]);
81
99
  expect(mockFunc).toHaveBeenCalledWith({
82
100
  description: 'description 1',
83
101
  title: 'title 1',
@@ -96,6 +114,8 @@ describe('Test Group CheckBox', () => {
96
114
  },
97
115
  ];
98
116
  const mockFunc = jest.fn();
117
+ const setState = jest.fn();
118
+ useState.mockImplementation((init) => [[0], setState]);
99
119
  await act(async () => {
100
120
  tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
101
121
  });
@@ -108,6 +128,7 @@ describe('Test Group CheckBox', () => {
108
128
  await act(async () => {
109
129
  items[1].props.onSelect(0);
110
130
  });
131
+ expect(setState).toHaveBeenCalledWith([]); // called 1 time
111
132
  expect(mockFunc).toHaveBeenCalledWith({
112
133
  description: 'description 1',
113
134
  title: 'title 1',
@@ -1,10 +1,18 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
4
  import { SCProvider } from '../../../context';
5
5
  import { mockSCStore } from '../../../context/mockStore';
6
6
  import MediaPlayerFull from '../MediaPlayerFull';
7
7
 
8
+ const mockSetState = jest.fn();
9
+ jest.mock('react', () => {
10
+ return {
11
+ ...jest.requireActual('react'),
12
+ useState: jest.fn((init) => [init, mockSetState]),
13
+ };
14
+ });
15
+
8
16
  const wrapComponent = (props) => (
9
17
  <SCProvider initState={mockSCStore({})}>
10
18
  <MediaPlayerFull {...props} />
@@ -14,7 +22,14 @@ const wrapComponent = (props) => (
14
22
  describe('Test MediaPlayerFull', () => {
15
23
  let tree;
16
24
 
25
+ afterEach(() => {
26
+ useState.mockClear();
27
+ });
28
+
17
29
  it('Test render', async () => {
30
+ useState.mockImplementationOnce((init) => [false, mockSetState]);
31
+ useState.mockImplementationOnce((init) => [false, mockSetState]);
32
+ useState.mockImplementationOnce((init) => [init, mockSetState]);
18
33
  await act(async () => {
19
34
  tree = await create(
20
35
  wrapComponent({
@@ -29,13 +44,18 @@ describe('Test MediaPlayerFull', () => {
29
44
  await act(async () => {
30
45
  TouchableOpacities[0].props.onPress();
31
46
  });
47
+ expect(mockSetState).toBeCalledWith(false);
32
48
  await act(async () => {
33
49
  TouchableOpacities[1].props.onPress();
34
50
  TouchableOpacities[2].props.onPress();
35
51
  });
52
+ expect(mockSetState).toBeCalledWith(true);
36
53
  });
37
54
 
38
55
  it('Test render 2', async () => {
56
+ useState.mockImplementationOnce((init) => [true, mockSetState]);
57
+ useState.mockImplementationOnce((init) => [true, mockSetState]);
58
+ useState.mockImplementationOnce((init) => [init, mockSetState]);
39
59
  await act(async () => {
40
60
  tree = await create(
41
61
  wrapComponent({
@@ -52,9 +72,11 @@ describe('Test MediaPlayerFull', () => {
52
72
  await act(async () => {
53
73
  TouchableOpacities[0].props.onPress();
54
74
  });
75
+ expect(mockSetState).toBeCalledWith(false);
55
76
  await act(async () => {
56
77
  TouchableOpacities[1].props.onPress();
57
78
  TouchableOpacities[2].props.onPress();
58
79
  });
80
+ expect(mockSetState).toBeCalledWith(true);
59
81
  });
60
82
  });
@@ -149,7 +149,6 @@ const Processing = ({
149
149
  onLeftClick={goBack}
150
150
  rightTitle={t('ok')}
151
151
  onRightClick={handleOk}
152
- wrapStyle={styles.wrapViewButton}
153
152
  />
154
153
  </View>
155
154
  </ModalCustom>
@@ -51,7 +51,4 @@ export default StyleSheet.create({
51
51
  txtCenter: {
52
52
  textAlign: 'center',
53
53
  },
54
- wrapViewButton: {
55
- position: 'relative',
56
- },
57
54
  });
@@ -4,11 +4,9 @@ import { Icon } from '@ant-design/react-native';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
  import { getStatusBarHeight } from 'react-native-iphone-x-helper';
6
6
 
7
- import { Colors, Device, Images } from '../../../configs';
7
+ import { Colors, Device } from '../../../configs';
8
8
  import Text from '../../Text';
9
9
  import { AccessibilityLabel } from '../../../configs/Constants';
10
- import { Image } from 'react-native';
11
- import { Platform } from 'react-native';
12
10
 
13
11
  const HeaderUnit = memo(
14
12
  ({
@@ -49,7 +47,11 @@ const HeaderUnit = memo(
49
47
  style={styles.btnLeft}
50
48
  onPress={onPressBack}
51
49
  >
52
- <Image source={Images.arrowLeft} style={styles.iconBack} />
50
+ <Icon
51
+ name={'left'}
52
+ size={27}
53
+ color={transparent ? Colors.White : Colors.Black}
54
+ />
53
55
  </TouchableOpacity>
54
56
  <View style={[styles.boxTitle, styleBoxTitle]}>
55
57
  {title && (
@@ -68,7 +70,7 @@ const HeaderUnit = memo(
68
70
  onPress={onPressAdd}
69
71
  >
70
72
  <Icon
71
- name={Platform.OS === 'android' ? 'plus-square' : 'plus'}
73
+ name={'plus'}
72
74
  size={27}
73
75
  color={transparent ? Colors.White : Colors.Black}
74
76
  />
@@ -81,10 +83,9 @@ const HeaderUnit = memo(
81
83
  accessibilityLabel={idButtonMore}
82
84
  >
83
85
  <Icon
84
- name={'ellipsis'}
86
+ name={'more'}
85
87
  size={27}
86
88
  color={transparent ? Colors.White : Colors.Black}
87
- style={styles.iconMore}
88
89
  />
89
90
  </TouchableOpacity>
90
91
  </View>
@@ -145,12 +146,4 @@ const styles = StyleSheet.create({
145
146
  borderBottomWidth: 1,
146
147
  borderBottomColor: Colors.Gray4,
147
148
  },
148
- iconMore: {
149
- transform: [{ rotate: '90deg' }],
150
- },
151
- iconBack: {
152
- tintColor: Colors.White,
153
- width: 16,
154
- height: 20,
155
- },
156
149
  });