@eohjsc/react-native-smart-city 0.6.0-rc4 → 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 +2 -2
- 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/navigations/SharedStack.js +1 -1
- package/src/screens/Automate/__test__/MultiUnits.test.js +2 -2
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -11
- package/src/screens/Device/detail.js +2 -2
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +2 -2
- package/src/screens/SelectUnit/__test__/index.test.js +8 -8
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +5 -4
- 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/src/utils/Monitor.js +5 -6
|
@@ -1,107 +1,106 @@
|
|
|
1
1
|
import React, { memo, useCallback, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { StatusBar, StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
4
4
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
5
|
-
import { useNavigation } from '@react-navigation/native';
|
|
5
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
6
6
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
7
7
|
|
|
8
8
|
import { Colors, Device } from '../../../configs';
|
|
9
|
-
import Text from '../../Text';
|
|
10
9
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
10
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
11
|
+
import {
|
|
12
|
+
useBoolean,
|
|
13
|
+
useIsOwnerOfUnit,
|
|
14
|
+
usePopover,
|
|
15
|
+
} from '../../../hooks/Common';
|
|
16
|
+
import AddMenu from '../../../screens/Unit/AddMenu';
|
|
17
|
+
import MoreMenu from '../../../screens/Unit/MoreMenu';
|
|
18
|
+
import Text from '../../Text';
|
|
19
|
+
|
|
20
|
+
const HeaderUnit = memo(({ unit, unitData }) => {
|
|
21
|
+
const { goBack, navigate } = useNavigation();
|
|
22
|
+
const { routeName } = useRoute().params || {};
|
|
23
|
+
const buttonMoreRef = useRef(null);
|
|
24
|
+
const t = useTranslations();
|
|
11
25
|
|
|
12
|
-
const
|
|
13
|
-
(
|
|
14
|
-
transparent,
|
|
15
|
-
onBack,
|
|
16
|
-
title,
|
|
17
|
-
onAdd,
|
|
18
|
-
onMore,
|
|
19
|
-
hideRight,
|
|
20
|
-
hideRightPlus,
|
|
21
|
-
styleBoxTitle,
|
|
22
|
-
bottomBorder,
|
|
23
|
-
idButtonMore = AccessibilityLabel.HEADER_UNIT_BUTTON_MORE,
|
|
24
|
-
}) => {
|
|
25
|
-
const { goBack } = useNavigation();
|
|
26
|
-
const buttonMoreRef = useRef(null);
|
|
26
|
+
const [showAdd, setShowAdd, setHideAdd] = useBoolean();
|
|
27
|
+
const { isOwner } = useIsOwnerOfUnit(unit?.user_id);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onBack();
|
|
31
|
-
} else {
|
|
32
|
-
goBack();
|
|
33
|
-
}
|
|
34
|
-
}, [goBack, onBack]);
|
|
29
|
+
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
30
|
+
usePopover();
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const onPressMore = useCallback(() => {
|
|
33
|
+
showPopoverWithRef(buttonMoreRef);
|
|
34
|
+
}, [showPopoverWithRef]);
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
return (
|
|
37
|
+
<View style={styles.container}>
|
|
38
|
+
<TouchableOpacity
|
|
39
|
+
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_BACK}
|
|
40
|
+
onPress={() => {
|
|
41
|
+
if (routeName) {
|
|
42
|
+
navigate(routeName);
|
|
43
|
+
} else {
|
|
44
|
+
goBack();
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<View style={styles.btnLeft}>
|
|
49
|
+
<AntDesign name={'left'} size={27} color={Colors.White} />
|
|
50
|
+
</View>
|
|
51
|
+
</TouchableOpacity>
|
|
52
|
+
<View style={styles.boxTitle}>
|
|
53
|
+
<Text semibold style={styles.txtHeader} numberOfLines={1}>
|
|
54
|
+
{t('Welcome {name}', {
|
|
55
|
+
name: unit?.name ? unit.name : '',
|
|
56
|
+
})}
|
|
57
|
+
</Text>
|
|
58
|
+
</View>
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
<View style={styles.boxRight}>
|
|
61
|
+
{!!isOwner && (
|
|
62
|
+
<TouchableOpacity
|
|
63
|
+
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_ADD}
|
|
64
|
+
onPress={setShowAdd}
|
|
65
|
+
>
|
|
66
|
+
<View style={styles.btnAdd}>
|
|
67
|
+
<AntDesign name={'plus'} size={27} color={Colors.White} />
|
|
68
|
+
</View>
|
|
69
|
+
</TouchableOpacity>
|
|
70
|
+
)}
|
|
46
71
|
<TouchableOpacity
|
|
47
|
-
|
|
48
|
-
|
|
72
|
+
onPress={onPressMore}
|
|
73
|
+
ref={buttonMoreRef}
|
|
74
|
+
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_MORE}
|
|
49
75
|
>
|
|
50
|
-
<View style={styles.
|
|
51
|
-
<
|
|
52
|
-
name={'left'}
|
|
53
|
-
size={27}
|
|
54
|
-
color={transparent ? Colors.White : Colors.Black}
|
|
55
|
-
/>
|
|
76
|
+
<View style={styles.btnMore}>
|
|
77
|
+
<MaterialIcons name={'more-vert'} size={27} color={Colors.White} />
|
|
56
78
|
</View>
|
|
57
79
|
</TouchableOpacity>
|
|
58
|
-
<View style={[styles.boxTitle, styleBoxTitle]}>
|
|
59
|
-
{title && (
|
|
60
|
-
<Text semibold style={styles.txtHeader} numberOfLines={1}>
|
|
61
|
-
{title}
|
|
62
|
-
</Text>
|
|
63
|
-
)}
|
|
64
|
-
</View>
|
|
65
|
-
|
|
66
|
-
{!hideRight && (
|
|
67
|
-
<View style={styles.boxRight}>
|
|
68
|
-
{!hideRightPlus && (
|
|
69
|
-
<TouchableOpacity
|
|
70
|
-
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_ADD}
|
|
71
|
-
onPress={onPressAdd}
|
|
72
|
-
>
|
|
73
|
-
<View style={styles.btnAdd}>
|
|
74
|
-
<AntDesign
|
|
75
|
-
name={'plus'}
|
|
76
|
-
size={27}
|
|
77
|
-
color={transparent ? Colors.White : Colors.Black}
|
|
78
|
-
/>
|
|
79
|
-
</View>
|
|
80
|
-
</TouchableOpacity>
|
|
81
|
-
)}
|
|
82
|
-
<TouchableOpacity
|
|
83
|
-
onPress={onPressMore}
|
|
84
|
-
ref={buttonMoreRef}
|
|
85
|
-
accessibilityLabel={idButtonMore}
|
|
86
|
-
>
|
|
87
|
-
<View style={styles.btnMore}>
|
|
88
|
-
<MaterialIcons
|
|
89
|
-
name={'more-vert'}
|
|
90
|
-
size={27}
|
|
91
|
-
color={transparent ? Colors.White : Colors.Black}
|
|
92
|
-
/>
|
|
93
|
-
</View>
|
|
94
|
-
</TouchableOpacity>
|
|
95
|
-
</View>
|
|
96
|
-
)}
|
|
97
80
|
</View>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
81
|
+
<AddMenu
|
|
82
|
+
unit={unit}
|
|
83
|
+
afterItemClick={hidePopover}
|
|
84
|
+
showAdd={showAdd}
|
|
85
|
+
setHideAdd={setHideAdd}
|
|
86
|
+
/>
|
|
87
|
+
<MoreMenu
|
|
88
|
+
unit={unit}
|
|
89
|
+
hidePopover={hidePopover}
|
|
90
|
+
isOwner={isOwner}
|
|
91
|
+
childRef={childRef}
|
|
92
|
+
showingPopover={showingPopover}
|
|
93
|
+
idLabelPopover={AccessibilityLabel.UNIT_DETAIL_POPUP_MORE}
|
|
94
|
+
idLabelItem={AccessibilityLabel.UNIT_DETAIL_POPUP_MORE_ITEM}
|
|
95
|
+
/>
|
|
96
|
+
</View>
|
|
97
|
+
);
|
|
98
|
+
});
|
|
101
99
|
|
|
102
100
|
export default HeaderUnit;
|
|
103
101
|
const stickyHeaderHeight =
|
|
104
102
|
Device.TopbarHeight + (Device.isIOS ? 0 : StatusBar.currentHeight);
|
|
103
|
+
|
|
105
104
|
const styles = StyleSheet.create({
|
|
106
105
|
container: {
|
|
107
106
|
flexDirection: 'row',
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
4
4
|
import HeaderUnit from '../HeaderUnit/index';
|
|
5
5
|
import { useNavigation } from '@react-navigation/native';
|
|
6
|
+
import MoreMenu from '../../../screens/Unit/MoreMenu';
|
|
7
|
+
import AddMenu from '../../../screens/Unit/AddMenu';
|
|
6
8
|
|
|
7
9
|
describe('Test HeaderUnit', () => {
|
|
8
10
|
let tree;
|
|
11
|
+
const unit = { id: 1 };
|
|
9
12
|
const { goBack } = useNavigation();
|
|
10
|
-
|
|
11
|
-
const mockedOnBack = jest.fn();
|
|
13
|
+
|
|
12
14
|
it('HeaderUnit onPress', async () => {
|
|
13
|
-
let title = 'title';
|
|
14
15
|
await act(async () => {
|
|
15
|
-
tree = await create(
|
|
16
|
-
<HeaderUnit
|
|
17
|
-
title={title}
|
|
18
|
-
onBack={mockedOnBack}
|
|
19
|
-
onAdd={mockedFunc}
|
|
20
|
-
onMore={mockedFunc}
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
16
|
+
tree = await create(<HeaderUnit unit={unit} />);
|
|
23
17
|
});
|
|
24
18
|
const instance = tree.root;
|
|
25
19
|
const item = instance.find(
|
|
@@ -27,22 +21,16 @@ describe('Test HeaderUnit', () => {
|
|
|
27
21
|
el.props.accessibilityLabel ===
|
|
28
22
|
AccessibilityLabel.HEADER_UNIT_BUTTON_BACK
|
|
29
23
|
);
|
|
24
|
+
|
|
30
25
|
await act(async () => {
|
|
31
26
|
item.props.onPress();
|
|
32
27
|
});
|
|
33
|
-
expect(
|
|
28
|
+
expect(global.mockedGoBack).toHaveBeenCalled();
|
|
34
29
|
});
|
|
35
30
|
|
|
36
31
|
it('HeaderUnit onPress goBack', async () => {
|
|
37
32
|
await act(async () => {
|
|
38
|
-
tree = await create(
|
|
39
|
-
<HeaderUnit
|
|
40
|
-
title="title"
|
|
41
|
-
onBack={false}
|
|
42
|
-
onAdd={mockedFunc}
|
|
43
|
-
onMore={mockedFunc}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
33
|
+
tree = await create(<HeaderUnit unit={unit} />);
|
|
46
34
|
});
|
|
47
35
|
const instance = tree.root;
|
|
48
36
|
const item = instance.find(
|
|
@@ -57,33 +45,34 @@ describe('Test HeaderUnit', () => {
|
|
|
57
45
|
});
|
|
58
46
|
|
|
59
47
|
it('HeaderUnit onPressAdd onPressMore', async () => {
|
|
48
|
+
useContext.mockReturnValue({
|
|
49
|
+
stateData: { auth: { account: { user: { id: 1 } } } },
|
|
50
|
+
setAction: jest.fn(),
|
|
51
|
+
});
|
|
60
52
|
await act(async () => {
|
|
61
|
-
tree = await create(
|
|
62
|
-
<HeaderUnit
|
|
63
|
-
title="title"
|
|
64
|
-
onBack={false}
|
|
65
|
-
hideRight={false}
|
|
66
|
-
hideRightPlus={false}
|
|
67
|
-
onAdd={mockedFunc}
|
|
68
|
-
onMore={mockedFunc}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
53
|
+
tree = await create(<HeaderUnit unit={{ ...unit, user_id: 1 }} />);
|
|
71
54
|
});
|
|
72
55
|
const instance = tree.root;
|
|
73
|
-
const
|
|
56
|
+
const buttonMore = instance.find(
|
|
74
57
|
(el) =>
|
|
75
58
|
el.props.accessibilityLabel ===
|
|
76
|
-
AccessibilityLabel.
|
|
59
|
+
AccessibilityLabel.HEADER_UNIT_BUTTON_MORE
|
|
77
60
|
);
|
|
78
|
-
|
|
61
|
+
expect(instance.findByType(MoreMenu).props.showingPopover).toBeFalsy();
|
|
62
|
+
await act(async () => {
|
|
63
|
+
buttonMore.props.onPress();
|
|
64
|
+
});
|
|
65
|
+
expect(instance.findByType(MoreMenu).props.showingPopover).toBeTruthy();
|
|
66
|
+
|
|
67
|
+
const buttonAdd = instance.find(
|
|
79
68
|
(el) =>
|
|
80
69
|
el.props.accessibilityLabel ===
|
|
81
|
-
AccessibilityLabel.
|
|
70
|
+
AccessibilityLabel.HEADER_UNIT_BUTTON_ADD
|
|
82
71
|
);
|
|
72
|
+
expect(instance.findByType(AddMenu).props.showAdd).toBeFalsy();
|
|
83
73
|
await act(async () => {
|
|
84
74
|
buttonAdd.props.onPress();
|
|
85
|
-
buttonMore.props.onPress();
|
|
86
75
|
});
|
|
87
|
-
expect(
|
|
76
|
+
expect(instance.findByType(AddMenu).props.showAdd).toBeTruthy();
|
|
88
77
|
});
|
|
89
78
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import { StatusBar, View, StyleSheet } from 'react-native';
|
|
2
|
+
import { StatusBar, View, StyleSheet, RefreshControl } from 'react-native';
|
|
3
3
|
import LinearGradient from 'react-native-linear-gradient';
|
|
4
4
|
|
|
5
5
|
import { Colors, Device, Images, SCConfig } from '../../configs';
|
|
@@ -7,65 +7,42 @@ import Text from '../Text';
|
|
|
7
7
|
import HeaderUnit from '../Unit/HeaderUnit';
|
|
8
8
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
9
9
|
import FImage from '../FImage';
|
|
10
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
10
11
|
import ParallaxScrollView from '../../libs/react-native-parallax-scroll-view';
|
|
11
12
|
|
|
12
13
|
const stickyHeaderHeight =
|
|
13
14
|
Device.TopbarHeight + (Device.isIOS ? 0 : StatusBar.currentHeight);
|
|
14
15
|
|
|
15
|
-
const WrapParallaxScrollView = ({
|
|
16
|
-
|
|
17
|
-
refreshControl,
|
|
18
|
-
title,
|
|
19
|
-
uriImg,
|
|
20
|
-
onBack,
|
|
21
|
-
onAdd,
|
|
22
|
-
onMore,
|
|
23
|
-
hideRight,
|
|
24
|
-
hideRightPlus,
|
|
25
|
-
contentBackground,
|
|
26
|
-
accessibilityLabel,
|
|
27
|
-
idButtonMore = AccessibilityLabel.HEADER_UNIT_BUTTON_MORE,
|
|
28
|
-
}) => {
|
|
16
|
+
const WrapParallaxScrollView = ({ children, unit, unitData, onRefresh }) => {
|
|
17
|
+
const t = useTranslations();
|
|
29
18
|
const renderForeground = useCallback(
|
|
30
19
|
() => (
|
|
31
20
|
<View style={styles.wrap}>
|
|
32
|
-
<HeaderUnit
|
|
33
|
-
transparent
|
|
34
|
-
onBack={onBack}
|
|
35
|
-
onAdd={onAdd}
|
|
36
|
-
onMore={onMore}
|
|
37
|
-
hideRight={hideRight}
|
|
38
|
-
hideRightPlus={hideRightPlus}
|
|
39
|
-
idButtonMore={idButtonMore}
|
|
40
|
-
/>
|
|
21
|
+
<HeaderUnit unit={unit} unitData={unitData} />
|
|
41
22
|
<Text
|
|
42
23
|
numberOfLines={1}
|
|
43
24
|
semibold
|
|
44
25
|
style={styles.nameUnit}
|
|
45
26
|
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_TEXT}
|
|
46
27
|
>
|
|
47
|
-
{
|
|
28
|
+
{t('Welcome {name}', {
|
|
29
|
+
name: unit?.name ? unit.name : '',
|
|
30
|
+
})}
|
|
48
31
|
</Text>
|
|
49
|
-
{contentBackground}
|
|
50
32
|
</View>
|
|
51
33
|
),
|
|
52
|
-
[
|
|
53
|
-
onBack,
|
|
54
|
-
onAdd,
|
|
55
|
-
onMore,
|
|
56
|
-
hideRight,
|
|
57
|
-
hideRightPlus,
|
|
58
|
-
idButtonMore,
|
|
59
|
-
title,
|
|
60
|
-
contentBackground,
|
|
61
|
-
]
|
|
34
|
+
[unit, unitData, t]
|
|
62
35
|
);
|
|
63
36
|
const renderBackground = useCallback(
|
|
64
37
|
() => (
|
|
65
38
|
<View style={styles.image}>
|
|
66
39
|
<FImage
|
|
67
40
|
style={styles.image}
|
|
68
|
-
source={
|
|
41
|
+
source={
|
|
42
|
+
unit?.background
|
|
43
|
+
? { uri: unit.background }
|
|
44
|
+
: SCConfig.appUnitDefaultBackground
|
|
45
|
+
}
|
|
69
46
|
defaultSource={Images.BgUnit}
|
|
70
47
|
resizeMode="cover"
|
|
71
48
|
/>
|
|
@@ -75,23 +52,15 @@ const WrapParallaxScrollView = ({
|
|
|
75
52
|
/>
|
|
76
53
|
</View>
|
|
77
54
|
),
|
|
78
|
-
[
|
|
55
|
+
[unit]
|
|
79
56
|
);
|
|
80
57
|
const renderStickyHeader = useCallback(
|
|
81
58
|
() => (
|
|
82
59
|
<View style={styles.stickyHeader}>
|
|
83
|
-
<HeaderUnit
|
|
84
|
-
title={title}
|
|
85
|
-
onBack={onBack}
|
|
86
|
-
onAdd={onAdd}
|
|
87
|
-
onMore={onMore}
|
|
88
|
-
hideRight={hideRight}
|
|
89
|
-
hideRightPlus={hideRightPlus}
|
|
90
|
-
idButtonMore={idButtonMore}
|
|
91
|
-
/>
|
|
60
|
+
<HeaderUnit unit={unit} unitData={unitData} />
|
|
92
61
|
</View>
|
|
93
62
|
),
|
|
94
|
-
[
|
|
63
|
+
[unit, unitData]
|
|
95
64
|
);
|
|
96
65
|
return (
|
|
97
66
|
<ParallaxScrollView
|
|
@@ -101,9 +70,11 @@ const WrapParallaxScrollView = ({
|
|
|
101
70
|
stickyHeaderHeight={stickyHeaderHeight}
|
|
102
71
|
renderStickyHeader={renderStickyHeader}
|
|
103
72
|
backgroundColor={Colors.White}
|
|
104
|
-
refreshControl={
|
|
73
|
+
refreshControl={
|
|
74
|
+
<RefreshControl refreshing={false} onRefresh={onRefresh} />
|
|
75
|
+
}
|
|
105
76
|
showsVerticalScrollIndicator={false}
|
|
106
|
-
accessibilityLabel={
|
|
77
|
+
accessibilityLabel={AccessibilityLabel.UNIT_DETAIL_PARALLAX_SCROLLVIEW}
|
|
107
78
|
>
|
|
108
79
|
{children}
|
|
109
80
|
</ParallaxScrollView>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { renderHook } from '@testing-library/react-hooks';
|
|
3
3
|
import { SCProvider } from '../../../context';
|
|
4
4
|
import { mockSCStore } from '../../../context/mockStore';
|
|
@@ -9,17 +9,6 @@ const mockedSetAction = jest.fn();
|
|
|
9
9
|
|
|
10
10
|
const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
|
|
11
11
|
|
|
12
|
-
jest.mock('react', () => {
|
|
13
|
-
return {
|
|
14
|
-
...jest.requireActual('react'),
|
|
15
|
-
useCallback: (func) => func(),
|
|
16
|
-
useContext: () => ({
|
|
17
|
-
stateData: mockSCStore({}),
|
|
18
|
-
setAction: mockedSetAction,
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
|
|
23
12
|
jest.mock('../../../iot/Monitor');
|
|
24
13
|
|
|
25
14
|
describe('Test useWatchConfigs', () => {
|
|
@@ -27,14 +16,17 @@ describe('Test useWatchConfigs', () => {
|
|
|
27
16
|
jest.useFakeTimers();
|
|
28
17
|
watchMultiConfigs.mockClear();
|
|
29
18
|
unwatchMultiConfigs.mockClear();
|
|
19
|
+
useContext.mockReturnValue({
|
|
20
|
+
stateData: mockSCStore({}),
|
|
21
|
+
setAction: mockedSetAction,
|
|
22
|
+
});
|
|
30
23
|
});
|
|
31
24
|
|
|
32
25
|
it('test unitId null', async () => {
|
|
33
26
|
renderHook(() => useWatchConfigs([1]), {
|
|
34
27
|
wrapper,
|
|
35
28
|
});
|
|
36
|
-
jest.
|
|
29
|
+
jest.runOnlyPendingTimers();
|
|
37
30
|
expect(watchMultiConfigs).toBeCalledWith([1]);
|
|
38
|
-
expect(unwatchMultiConfigs).toBeCalledWith([1]);
|
|
39
31
|
});
|
|
40
32
|
});
|
|
@@ -15,7 +15,7 @@ const SharedStack = memo(() => {
|
|
|
15
15
|
const t = useTranslations();
|
|
16
16
|
const { toggleDrawer, goBack } = useNavigation();
|
|
17
17
|
const { params } = useRoute();
|
|
18
|
-
const { isMainSource } = params;
|
|
18
|
+
const { isMainSource } = params || {};
|
|
19
19
|
return (
|
|
20
20
|
<Stack.Navigator>
|
|
21
21
|
<Stack.Screen
|
|
@@ -99,9 +99,9 @@ describe('Test MultiUnits', () => {
|
|
|
99
99
|
expect(WrapHeaderScrollables[0].props.title).toEqual(
|
|
100
100
|
getTranslate('en', 'multi_units_automate')
|
|
101
101
|
);
|
|
102
|
-
const
|
|
102
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
103
103
|
await act(async () => {
|
|
104
|
-
|
|
104
|
+
touchableOpacities[2].props.onPress();
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
const ItemOneTaps = instance.findAllByType(ItemOneTap);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
|
|
4
4
|
import { SCProvider } from '../../../context';
|
|
@@ -18,14 +18,6 @@ const wrapComponent = (route, navigation) => (
|
|
|
18
18
|
</SCProvider>
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
const mockSetState = jest.fn();
|
|
22
|
-
jest.mock('react', () => {
|
|
23
|
-
return {
|
|
24
|
-
...jest.requireActual('react'),
|
|
25
|
-
useState: jest.fn((init) => [init, mockSetState]),
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
|
|
29
21
|
describe('Test ConfirmUnitDeletion', () => {
|
|
30
22
|
let tree;
|
|
31
23
|
let route;
|
|
@@ -41,7 +33,6 @@ describe('Test ConfirmUnitDeletion', () => {
|
|
|
41
33
|
});
|
|
42
34
|
|
|
43
35
|
it('test render ConfirmUnitDeletion', async () => {
|
|
44
|
-
useState.mockImplementationOnce((init) => ['new_name', mockSetState]);
|
|
45
36
|
await act(async () => {
|
|
46
37
|
tree = await renderer.create(wrapComponent(route));
|
|
47
38
|
});
|
|
@@ -53,7 +44,6 @@ describe('Test ConfirmUnitDeletion', () => {
|
|
|
53
44
|
});
|
|
54
45
|
});
|
|
55
46
|
it('Onpress button ConfirmUnitDeletion ', async () => {
|
|
56
|
-
useState.mockImplementationOnce((init) => ['YES', mockSetState]);
|
|
57
47
|
await act(async () => {
|
|
58
48
|
tree = await renderer.create(wrapComponent(route));
|
|
59
49
|
});
|
|
@@ -755,7 +755,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
755
755
|
>
|
|
756
756
|
{display.items.map((item, index) => {
|
|
757
757
|
return (
|
|
758
|
-
|
|
758
|
+
<View key={item?.id?.toString()}>
|
|
759
759
|
{!item.is_configuration_ready && (
|
|
760
760
|
<Text center>{t('bellow_widget_is_not_configured')}</Text>
|
|
761
761
|
)}
|
|
@@ -779,7 +779,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
779
779
|
setShowWindDirection={setShowWindDirection}
|
|
780
780
|
background={station?.background}
|
|
781
781
|
/>
|
|
782
|
-
|
|
782
|
+
</View>
|
|
783
783
|
);
|
|
784
784
|
})}
|
|
785
785
|
</SensorConnectStatusViewHeader>
|
|
@@ -129,9 +129,9 @@ describe('Test Render ListSubUnit', () => {
|
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
expect(global.mockedNavigate).toBeCalled();
|
|
132
|
-
const
|
|
132
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
133
133
|
await act(async () => {
|
|
134
|
-
await
|
|
134
|
+
await touchableOpacities[2].props.onPress();
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
mockedNavigate.mockClear();
|
|
@@ -51,14 +51,14 @@ describe('Test Select unit screen', () => {
|
|
|
51
51
|
tree = await create(wrapComponent());
|
|
52
52
|
});
|
|
53
53
|
const instance = tree.root;
|
|
54
|
-
const
|
|
54
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
55
55
|
const bottomButtonView = instance.findByType(BottomButtonView);
|
|
56
56
|
|
|
57
57
|
expect(bottomButtonView.props.typeMain).toEqual('disabled');
|
|
58
|
-
expect(
|
|
58
|
+
expect(touchableOpacities).toHaveLength(4);
|
|
59
59
|
await act(async () => {
|
|
60
|
-
await
|
|
61
|
-
await
|
|
60
|
+
await touchableOpacities[1].props.onPress();
|
|
61
|
+
await touchableOpacities[2].props.onPress(response.data[0]);
|
|
62
62
|
});
|
|
63
63
|
expect(bottomButtonView.props.typeMain).toEqual('primary');
|
|
64
64
|
});
|
|
@@ -80,11 +80,11 @@ describe('Test Select unit screen', () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const instance = tree.root;
|
|
83
|
-
const
|
|
84
|
-
expect(
|
|
83
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
84
|
+
expect(touchableOpacities).toHaveLength(3);
|
|
85
85
|
await act(async () => {
|
|
86
|
-
await
|
|
87
|
-
await
|
|
86
|
+
await touchableOpacities[1].props.onPress();
|
|
87
|
+
await touchableOpacities[2].props.onPress();
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -10,6 +10,7 @@ import TextInput from '../../../commons/Form/TextInput';
|
|
|
10
10
|
import { ModalCustom } from '../../../commons/Modal';
|
|
11
11
|
import { TouchableOpacity } from 'react-native';
|
|
12
12
|
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
13
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
13
14
|
|
|
14
15
|
const wrapComponent = (route) => (
|
|
15
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -137,7 +138,7 @@ describe('Test GroupButtonByType', () => {
|
|
|
137
138
|
await act(async () => {
|
|
138
139
|
await touch.props.onPress();
|
|
139
140
|
});
|
|
140
|
-
expect(icon.props.name).toEqual('
|
|
141
|
+
expect(icon.props.name).toEqual('reload1');
|
|
141
142
|
|
|
142
143
|
const touch2 = instance.find(
|
|
143
144
|
(el) =>
|
|
@@ -145,14 +146,14 @@ describe('Test GroupButtonByType', () => {
|
|
|
145
146
|
AccessibilityLabel.HEADER_BUTTON_TYPE_MORE &&
|
|
146
147
|
el.type === TouchableOpacity
|
|
147
148
|
);
|
|
148
|
-
const
|
|
149
|
+
const moreIcon = instance.find(
|
|
149
150
|
(el) =>
|
|
150
151
|
el.props.accessibilityLabel ===
|
|
151
|
-
AccessibilityLabel.ICON_OUTLINE_TYPE_MORE && el.type ===
|
|
152
|
+
AccessibilityLabel.ICON_OUTLINE_TYPE_MORE && el.type === MaterialIcons
|
|
152
153
|
);
|
|
153
154
|
await act(async () => {
|
|
154
155
|
await touch2.props.onPress();
|
|
155
156
|
});
|
|
156
|
-
expect(
|
|
157
|
+
expect(moreIcon.props.name).toEqual('more-vert');
|
|
157
158
|
});
|
|
158
159
|
});
|
|
@@ -57,10 +57,10 @@ describe('Test EditTemplate', () => {
|
|
|
57
57
|
const DraggableFlatLists = instance.findAllByType(DraggableFlatList);
|
|
58
58
|
expect(DraggableFlatLists).toHaveLength(1);
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
61
61
|
|
|
62
62
|
await act(async () => {
|
|
63
|
-
await
|
|
63
|
+
await touchableOpacities[0].props.onPress();
|
|
64
64
|
});
|
|
65
65
|
await act(async () => {
|
|
66
66
|
const firstItem = instance.findByProps({ accessibilityLabel: 'item-0' });
|
|
@@ -57,8 +57,8 @@ describe('Test Detail', () => {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
const instance = tree.root;
|
|
60
|
-
const
|
|
61
|
-
await
|
|
60
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
61
|
+
await touchableOpacities[0].props.onPress();
|
|
62
62
|
expect(global.mockedGoBack).toBeCalled();
|
|
63
63
|
});
|
|
64
64
|
|
|
@@ -82,9 +82,9 @@ describe('Test Detail', () => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
const instance = tree.root;
|
|
85
|
-
const
|
|
85
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
86
86
|
await act(async () => {
|
|
87
|
-
await
|
|
87
|
+
await touchableOpacities[1].props.onPress();
|
|
88
88
|
});
|
|
89
89
|
const menuActionMore = instance.findByType(MenuActionMore);
|
|
90
90
|
const mockDoAction = jest.fn();
|