@eohjsc/react-native-smart-city 0.6.0-rc5 → 0.6.0-rc6
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 +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +2 -2
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +4 -9
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -11
- package/src/commons/Calendar/__test__/Calendar.test.js +0 -7
- package/src/commons/CircleButton/__test__/CircleButton.test.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +10 -13
- package/src/commons/DateTimeRangeChange/__test__/DateTimeButton.test.js +4 -4
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +5 -5
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +9 -9
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +1 -22
- package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +12 -48
- package/src/commons/Sharing/__test__/ButtonRemoveMember.test.js +2 -2
- package/src/commons/Unit/HeaderUnit/index.js +82 -83
- package/src/commons/Unit/__test__/HeaderUnit.test.js +26 -37
- package/src/commons/WrapParallaxScrollView/index.js +21 -50
- package/src/hooks/Common/useIsOwnerOfUnit.js +1 -1
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +6 -14
- package/src/screens/Automate/__test__/MultiUnits.test.js +2 -2
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -11
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +2 -2
- package/src/screens/SelectUnit/__test__/index.test.js +8 -8
- package/src/screens/Template/__test__/EditTemplate.test.js +2 -2
- package/src/screens/Template/__test__/detail.test.js +4 -4
- package/src/screens/Template/__test__/index.test.js +2 -2
- package/src/screens/Unit/Detail.js +12 -53
- package/src/screens/Unit/Station/__test__/index.test.js +2 -2
- package/src/screens/Unit/__test__/Detail.test.js +10 -8
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +8 -13
- package/src/screens/UnitSummary/components/__test__/UnitSummary.test.js +8 -8
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ describe('Test ItemPasscode', () => {
|
|
|
18
18
|
tree = await create(wrapComponent());
|
|
19
19
|
});
|
|
20
20
|
const instance = tree.root;
|
|
21
|
-
const
|
|
22
|
-
expect(
|
|
21
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
22
|
+
expect(touchableOpacities).toHaveLength(2);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import ColorPickerTemplate from '../ColorPickerTemplate';
|
|
5
5
|
import { WheelColorPicker } from '../ColorPickerTemplate';
|
|
@@ -10,14 +10,6 @@ import ColorPicker from 'react-native-wheel-color-picker';
|
|
|
10
10
|
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
11
11
|
|
|
12
12
|
const mockSetAction = jest.fn();
|
|
13
|
-
jest.mock('react', () => {
|
|
14
|
-
return {
|
|
15
|
-
...jest.requireActual('react'),
|
|
16
|
-
useContext: () => ({
|
|
17
|
-
setAction: mockSetAction,
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
13
|
|
|
22
14
|
jest.mock('../../../iot/Monitor');
|
|
23
15
|
const mockDoAction = jest.fn();
|
|
@@ -55,6 +47,9 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
55
47
|
title: '',
|
|
56
48
|
};
|
|
57
49
|
mockSetAction.mockClear();
|
|
50
|
+
useContext.mockReturnValue({
|
|
51
|
+
setAction: mockSetAction,
|
|
52
|
+
});
|
|
58
53
|
});
|
|
59
54
|
|
|
60
55
|
it('render template ColorPickerTemplate', async () => {
|
|
@@ -83,9 +83,9 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
83
83
|
});
|
|
84
84
|
expect(mockDoAction).toBeCalled();
|
|
85
85
|
|
|
86
|
-
const
|
|
86
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
87
87
|
await act(async () => {
|
|
88
|
-
await
|
|
88
|
+
await touchableOpacities[0].props.onPress();
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
const dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
@@ -120,13 +120,13 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
120
120
|
await act(async () => {
|
|
121
121
|
await dateTimePicker.props.onConfirm();
|
|
122
122
|
});
|
|
123
|
-
const
|
|
124
|
-
expect(
|
|
123
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
124
|
+
expect(touchableOpacities).toHaveLength(3);
|
|
125
125
|
await act(async () => {
|
|
126
|
-
await
|
|
126
|
+
await touchableOpacities[0].props.onPress();
|
|
127
127
|
});
|
|
128
128
|
await act(async () => {
|
|
129
|
-
await
|
|
129
|
+
await touchableOpacities[2].props.onPress(3);
|
|
130
130
|
});
|
|
131
131
|
expect(mockDoAction).toBeCalled();
|
|
132
132
|
});
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React 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
|
-
|
|
12
7
|
describe('Test TwoButtonTemplate', () => {
|
|
13
8
|
const actionOnData = {
|
|
14
9
|
color: '#00979D',
|
|
@@ -66,11 +61,7 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
66
61
|
};
|
|
67
62
|
let wrapper;
|
|
68
63
|
|
|
69
|
-
const setState = jest.fn();
|
|
70
|
-
useState.mockImplementation((init) => [init, setState]);
|
|
71
|
-
|
|
72
64
|
const assertRender = async (state, text) => {
|
|
73
|
-
useState.mockImplementationOnce((init) => [state, setState]);
|
|
74
65
|
const mockDoAction = jest.fn();
|
|
75
66
|
await act(async () => {
|
|
76
67
|
wrapper = create(
|
|
@@ -94,7 +85,6 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
94
85
|
});
|
|
95
86
|
|
|
96
87
|
const assertActionCall = async (state, action_data) => {
|
|
97
|
-
useState.mockImplementationOnce((init) => [state, setState]);
|
|
98
88
|
const mockDoAction = jest.fn();
|
|
99
89
|
await act(async () => {
|
|
100
90
|
wrapper = create(
|
|
@@ -5,13 +5,6 @@ import { Calendar } from 'react-native-calendars';
|
|
|
5
5
|
import { SCProvider } from '../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
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
|
const wrapComponent = ({ route, isVisible, navigation }) => (
|
|
16
9
|
<SCProvider initState={mockSCStore({})}>
|
|
17
10
|
<CalendarComponent route={route} isVisible={isVisible} />
|
|
@@ -10,7 +10,7 @@ describe('Test circle button', () => {
|
|
|
10
10
|
tree = await renderer.create(<CircleButton size={5} />);
|
|
11
11
|
});
|
|
12
12
|
const instance = tree.root;
|
|
13
|
-
const
|
|
14
|
-
expect(
|
|
13
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
14
|
+
expect(touchableOpacities).toHaveLength(1);
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import MockAdapter from 'axios-mock-adapter';
|
|
4
4
|
|
|
@@ -18,18 +18,6 @@ const mock = new MockAdapter(api.axiosInstance);
|
|
|
18
18
|
|
|
19
19
|
const mockSetAction = jest.fn();
|
|
20
20
|
|
|
21
|
-
jest.mock('react', () => {
|
|
22
|
-
return {
|
|
23
|
-
...jest.requireActual('react'),
|
|
24
|
-
useContext: () => ({
|
|
25
|
-
stateData: mockSCStore({
|
|
26
|
-
app: { isNeedUpdateCache: true },
|
|
27
|
-
}),
|
|
28
|
-
setAction: mockSetAction,
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
21
|
const wrapComponent = (route) => (
|
|
34
22
|
<SCProvider initState={mockSCStore({})}>
|
|
35
23
|
<MyPinnedSharedUnit />
|
|
@@ -39,6 +27,15 @@ const wrapComponent = (route) => (
|
|
|
39
27
|
describe('Test MyPinnedSharedUnit', () => {
|
|
40
28
|
let tree;
|
|
41
29
|
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
useContext.mockReturnValue({
|
|
32
|
+
stateData: mockSCStore({
|
|
33
|
+
app: { isNeedUpdateCache: true },
|
|
34
|
+
}),
|
|
35
|
+
setAction: mockSetAction,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
42
39
|
it('create', async () => {
|
|
43
40
|
mock.onGet(API.UNIT.SHARED_UNITS()).reply(200, [{ id: 1 }]);
|
|
44
41
|
|
|
@@ -15,8 +15,8 @@ describe('Test DateTimeButton', () => {
|
|
|
15
15
|
);
|
|
16
16
|
});
|
|
17
17
|
const instance = tree.root;
|
|
18
|
-
const
|
|
19
|
-
expect(
|
|
18
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
19
|
+
expect(touchableOpacities).toHaveLength(1);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('render DateTimeButton formatType is undefined', async () => {
|
|
@@ -26,7 +26,7 @@ describe('Test DateTimeButton', () => {
|
|
|
26
26
|
);
|
|
27
27
|
});
|
|
28
28
|
const instance = tree.root;
|
|
29
|
-
const
|
|
30
|
-
expect(
|
|
29
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
30
|
+
expect(touchableOpacities).toHaveLength(1);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -5,7 +5,7 @@ import { mockSCStore } from '../../../../context/mockStore';
|
|
|
5
5
|
import { SCProvider } from '../../../../context';
|
|
6
6
|
import PasscodeField from '../index';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const mockSetDataForm = jest.fn();
|
|
9
9
|
|
|
10
10
|
const wrapComponent = (
|
|
11
11
|
dataItem = {
|
|
@@ -32,7 +32,7 @@ const wrapComponent = (
|
|
|
32
32
|
<PasscodeField
|
|
33
33
|
dataItem={dataItem}
|
|
34
34
|
index={index}
|
|
35
|
-
setDataForm={
|
|
35
|
+
setDataForm={mockSetDataForm}
|
|
36
36
|
dataForm={dataForm}
|
|
37
37
|
/>
|
|
38
38
|
</SCProvider>
|
|
@@ -42,7 +42,7 @@ describe('Test PasscodeField', () => {
|
|
|
42
42
|
let tree;
|
|
43
43
|
|
|
44
44
|
afterEach(() => {
|
|
45
|
-
|
|
45
|
+
mockSetDataForm.mockClear();
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('render PasscodeField', async () => {
|
|
@@ -59,7 +59,7 @@ describe('Test PasscodeField', () => {
|
|
|
59
59
|
await act(async () => {
|
|
60
60
|
await inputPasscode.props.onChangeText('123');
|
|
61
61
|
});
|
|
62
|
-
expect(
|
|
62
|
+
expect(mockSetDataForm).toBeCalledWith([
|
|
63
63
|
{
|
|
64
64
|
key: 'passcode',
|
|
65
65
|
type: 'passcode',
|
|
@@ -74,7 +74,7 @@ describe('Test PasscodeField', () => {
|
|
|
74
74
|
await act(async () => {
|
|
75
75
|
await inputPasscode.props.onChangeText('123456');
|
|
76
76
|
});
|
|
77
|
-
expect(
|
|
77
|
+
expect(mockSetDataForm).toBeCalledWith([
|
|
78
78
|
{
|
|
79
79
|
key: 'passcode',
|
|
80
80
|
type: 'passcode',
|
|
@@ -6,7 +6,7 @@ import ScheduleField from '../index';
|
|
|
6
6
|
import { AccessibilityLabel } from '../../../../configs/Constants';
|
|
7
7
|
import { TouchableOpacity } from 'react-native';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const mockSetDataForm = jest.fn();
|
|
10
10
|
|
|
11
11
|
const wrapComponent = (
|
|
12
12
|
dataItem = {
|
|
@@ -41,7 +41,7 @@ const wrapComponent = (
|
|
|
41
41
|
<ScheduleField
|
|
42
42
|
dataItem={dataItem}
|
|
43
43
|
index={index}
|
|
44
|
-
setDataForm={
|
|
44
|
+
setDataForm={mockSetDataForm}
|
|
45
45
|
dataForm={dataForm}
|
|
46
46
|
/>
|
|
47
47
|
</SCProvider>
|
|
@@ -53,7 +53,7 @@ describe('Test ScheduleField', () => {
|
|
|
53
53
|
Date.now = jest.fn(() => new Date('2022-05-30T15:50:36+01:00'));
|
|
54
54
|
});
|
|
55
55
|
afterEach(() => {
|
|
56
|
-
|
|
56
|
+
mockSetDataForm.mockClear();
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
const onPressRecurring = async (instance, schedule) => {
|
|
@@ -69,7 +69,7 @@ describe('Test ScheduleField', () => {
|
|
|
69
69
|
await act(async () => {
|
|
70
70
|
await recurring.props.onPress();
|
|
71
71
|
});
|
|
72
|
-
expect(
|
|
72
|
+
expect(mockSetDataForm).toBeCalledWith([
|
|
73
73
|
{
|
|
74
74
|
key: 'schedule',
|
|
75
75
|
type: 'schedule',
|
|
@@ -91,7 +91,7 @@ describe('Test ScheduleField', () => {
|
|
|
91
91
|
action_zigbee: 4,
|
|
92
92
|
},
|
|
93
93
|
]);
|
|
94
|
-
|
|
94
|
+
mockSetDataForm.mockClear();
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
const onPressTemporary = async (instance, schedule) => {
|
|
@@ -99,7 +99,7 @@ describe('Test ScheduleField', () => {
|
|
|
99
99
|
await schedule.props.onPress();
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
expect(
|
|
102
|
+
expect(mockSetDataForm).toBeCalledWith([
|
|
103
103
|
{
|
|
104
104
|
key: 'schedule',
|
|
105
105
|
type: 'schedule',
|
|
@@ -145,14 +145,14 @@ describe('Test ScheduleField', () => {
|
|
|
145
145
|
await popupDateTimePickerDone.props.onPress();
|
|
146
146
|
});
|
|
147
147
|
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
148
|
-
|
|
148
|
+
mockSetDataForm.mockClear();
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
it('render ScheduleField choose schedule', async () => {
|
|
152
152
|
await act(async () => {
|
|
153
153
|
tree = await create(wrapComponent());
|
|
154
154
|
});
|
|
155
|
-
expect(
|
|
155
|
+
expect(mockSetDataForm).toBeCalledWith([
|
|
156
156
|
{
|
|
157
157
|
key: 'schedule',
|
|
158
158
|
type: 'schedule',
|
|
@@ -169,7 +169,7 @@ describe('Test ScheduleField', () => {
|
|
|
169
169
|
action_zigbee: 2,
|
|
170
170
|
},
|
|
171
171
|
]);
|
|
172
|
-
|
|
172
|
+
mockSetDataForm.mockClear();
|
|
173
173
|
const instance = tree.root;
|
|
174
174
|
const schedule = instance.findAll(
|
|
175
175
|
(el) =>
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React 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
|
-
|
|
13
8
|
describe('Test Group CheckBox', () => {
|
|
14
9
|
let tree;
|
|
15
|
-
const mockSetState = () => {
|
|
16
|
-
const setState = jest.fn();
|
|
17
|
-
useState.mockImplementation((init) => [init, setState]);
|
|
18
|
-
return setState;
|
|
19
|
-
};
|
|
20
10
|
|
|
21
11
|
const findGroupCheckBoxItem = (instance) => {
|
|
22
12
|
const item = instance.find(
|
|
@@ -34,7 +24,6 @@ describe('Test Group CheckBox', () => {
|
|
|
34
24
|
description: 'description',
|
|
35
25
|
},
|
|
36
26
|
];
|
|
37
|
-
mockSetState();
|
|
38
27
|
await act(async () => {
|
|
39
28
|
tree = await create(<GroupCheckBox data={data} />);
|
|
40
29
|
});
|
|
@@ -51,7 +40,6 @@ describe('Test Group CheckBox', () => {
|
|
|
51
40
|
},
|
|
52
41
|
];
|
|
53
42
|
const mockFunc = jest.fn();
|
|
54
|
-
const setState = mockSetState();
|
|
55
43
|
await act(async () => {
|
|
56
44
|
tree = await create(
|
|
57
45
|
<GroupCheckBox data={data} onSelect={mockFunc} multiple />
|
|
@@ -62,9 +50,6 @@ describe('Test Group CheckBox', () => {
|
|
|
62
50
|
await act(async () => {
|
|
63
51
|
item.props.onSelect(0);
|
|
64
52
|
});
|
|
65
|
-
expect(setState).toHaveBeenCalledTimes(2);
|
|
66
|
-
expect(setState).toHaveBeenNthCalledWith(1, [0]);
|
|
67
|
-
expect(setState).toHaveBeenNthCalledWith(2, [0]);
|
|
68
53
|
expect(mockFunc).toHaveBeenCalledWith([
|
|
69
54
|
{ description: 'description', source: 'source', title: 'testItem' },
|
|
70
55
|
]);
|
|
@@ -85,7 +70,6 @@ describe('Test Group CheckBox', () => {
|
|
|
85
70
|
},
|
|
86
71
|
];
|
|
87
72
|
const mockFunc = jest.fn();
|
|
88
|
-
const setState = mockSetState();
|
|
89
73
|
await act(async () => {
|
|
90
74
|
tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
|
|
91
75
|
});
|
|
@@ -94,8 +78,6 @@ describe('Test Group CheckBox', () => {
|
|
|
94
78
|
await act(async () => {
|
|
95
79
|
item.props.onSelect(0);
|
|
96
80
|
});
|
|
97
|
-
expect(setState).toHaveBeenNthCalledWith(1, [0]);
|
|
98
|
-
expect(setState).toHaveBeenNthCalledWith(2, [0]);
|
|
99
81
|
expect(mockFunc).toHaveBeenCalledWith({
|
|
100
82
|
description: 'description 1',
|
|
101
83
|
title: 'title 1',
|
|
@@ -114,8 +96,6 @@ describe('Test Group CheckBox', () => {
|
|
|
114
96
|
},
|
|
115
97
|
];
|
|
116
98
|
const mockFunc = jest.fn();
|
|
117
|
-
const setState = jest.fn();
|
|
118
|
-
useState.mockImplementation((init) => [[0], setState]);
|
|
119
99
|
await act(async () => {
|
|
120
100
|
tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
|
|
121
101
|
});
|
|
@@ -128,7 +108,6 @@ describe('Test Group CheckBox', () => {
|
|
|
128
108
|
await act(async () => {
|
|
129
109
|
items[1].props.onSelect(0);
|
|
130
110
|
});
|
|
131
|
-
expect(setState).toHaveBeenCalledWith([]); // called 1 time
|
|
132
111
|
expect(mockFunc).toHaveBeenCalledWith({
|
|
133
112
|
description: 'description 1',
|
|
134
113
|
title: 'title 1',
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React 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
|
-
|
|
8
|
-
const mockSetState = jest.fn();
|
|
9
|
-
jest.mock('react', () => {
|
|
10
|
-
return {
|
|
11
|
-
...jest.requireActual('react'),
|
|
12
|
-
useState: jest.fn((init) => [init, mockSetState]),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
7
|
+
import FImage from '../../FImage';
|
|
15
8
|
|
|
16
9
|
const wrapComponent = (props) => (
|
|
17
10
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -22,14 +15,7 @@ const wrapComponent = (props) => (
|
|
|
22
15
|
describe('Test MediaPlayerFull', () => {
|
|
23
16
|
let tree;
|
|
24
17
|
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
useState.mockClear();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
18
|
it('Test render', async () => {
|
|
30
|
-
useState.mockImplementationOnce((init) => [false, mockSetState]);
|
|
31
|
-
useState.mockImplementationOnce((init) => [false, mockSetState]);
|
|
32
|
-
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
33
19
|
await act(async () => {
|
|
34
20
|
tree = await create(
|
|
35
21
|
wrapComponent({
|
|
@@ -39,44 +25,22 @@ describe('Test MediaPlayerFull', () => {
|
|
|
39
25
|
);
|
|
40
26
|
});
|
|
41
27
|
const instance = tree.root;
|
|
42
|
-
const
|
|
43
|
-
expect(
|
|
28
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
29
|
+
expect(touchableOpacities).toHaveLength(3);
|
|
30
|
+
expect(instance.findAllByType(FImage)).toHaveLength(1);
|
|
44
31
|
await act(async () => {
|
|
45
|
-
|
|
32
|
+
touchableOpacities[0].props.onPress();
|
|
46
33
|
});
|
|
47
|
-
expect(
|
|
34
|
+
expect(instance.findAllByType(FImage)).toHaveLength(2); // paused
|
|
48
35
|
await act(async () => {
|
|
49
|
-
|
|
50
|
-
TouchableOpacities[2].props.onPress();
|
|
36
|
+
touchableOpacities[1].props.onPress();
|
|
51
37
|
});
|
|
52
|
-
expect(
|
|
53
|
-
});
|
|
38
|
+
expect(instance.findAllByType(FImage)).toHaveLength(1); // unpaused
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
57
|
-
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
58
|
-
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
59
|
-
await act(async () => {
|
|
60
|
-
tree = await create(
|
|
61
|
-
wrapComponent({
|
|
62
|
-
isShowFullScreenIcon: true,
|
|
63
|
-
cameraName: 'test',
|
|
64
|
-
isPaused: true,
|
|
65
|
-
amount: 1,
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
const instance = tree.root;
|
|
70
|
-
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
71
|
-
expect(TouchableOpacities).toHaveLength(3);
|
|
72
|
-
await act(async () => {
|
|
73
|
-
TouchableOpacities[0].props.onPress();
|
|
74
|
-
});
|
|
75
|
-
expect(mockSetState).toBeCalledWith(false);
|
|
40
|
+
// full screen
|
|
76
41
|
await act(async () => {
|
|
77
|
-
|
|
78
|
-
TouchableOpacities[2].props.onPress();
|
|
42
|
+
touchableOpacities[2].props.onPress();
|
|
79
43
|
});
|
|
80
|
-
expect(
|
|
44
|
+
expect(touchableOpacities[0].props.style?.position).toEqual('absolute');
|
|
81
45
|
});
|
|
82
46
|
});
|
|
@@ -12,7 +12,7 @@ describe('BtnRemoveMember', () => {
|
|
|
12
12
|
tree = await renderer.create(component);
|
|
13
13
|
});
|
|
14
14
|
const instance = tree.root;
|
|
15
|
-
const
|
|
16
|
-
expect(
|
|
15
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
16
|
+
expect(touchableOpacities).toHaveLength(1);
|
|
17
17
|
});
|
|
18
18
|
});
|