react-native-ui-lib 8.4.2-snapshot.7918 → 8.4.3-snapshot.7923
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
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ComponentProps } from '../../testkit/new/Component.driver';
|
|
2
|
+
export declare const BadgeDriver: (props: ComponentProps) => {
|
|
3
|
+
getLabel: () => {
|
|
4
|
+
getText: () => string | (string | import("react-test-renderer").ReactTestInstance)[];
|
|
5
|
+
getStyle: () => import("react-native").TextStyle;
|
|
6
|
+
press: () => void;
|
|
7
|
+
hasOnPress: () => boolean;
|
|
8
|
+
onPressIn: () => void;
|
|
9
|
+
hasOnPressIn: () => boolean;
|
|
10
|
+
onPressOut: () => void;
|
|
11
|
+
hasOnPressOut: () => boolean;
|
|
12
|
+
onLongPress: () => void;
|
|
13
|
+
hasOnLongPress: () => boolean;
|
|
14
|
+
getElement: () => import("react-test-renderer").ReactTestInstance;
|
|
15
|
+
queryElement: () => import("react-test-renderer").ReactTestInstance | undefined;
|
|
16
|
+
exists: () => boolean;
|
|
17
|
+
};
|
|
18
|
+
getIcon: () => {
|
|
19
|
+
exists: () => boolean;
|
|
20
|
+
getStyle: () => any;
|
|
21
|
+
getElement: () => import("react-test-renderer").ReactTestInstance;
|
|
22
|
+
queryElement: () => import("react-test-renderer").ReactTestInstance | undefined;
|
|
23
|
+
};
|
|
24
|
+
getStyle: () => any;
|
|
25
|
+
getSize: () => number;
|
|
26
|
+
press: () => void;
|
|
27
|
+
hasOnPress: () => boolean;
|
|
28
|
+
onPressIn: () => void;
|
|
29
|
+
hasOnPressIn: () => boolean;
|
|
30
|
+
onPressOut: () => void;
|
|
31
|
+
hasOnPressOut: () => boolean;
|
|
32
|
+
onLongPress: () => void;
|
|
33
|
+
hasOnLongPress: () => boolean;
|
|
34
|
+
getElement: () => import("react-test-renderer").ReactTestInstance;
|
|
35
|
+
queryElement: () => import("react-test-renderer").ReactTestInstance | undefined;
|
|
36
|
+
exists: () => boolean;
|
|
37
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useComponentDriver } from "../../testkit/new/Component.driver";
|
|
3
|
+
import { usePressableDriver } from "../../testkit/new/usePressable.driver";
|
|
4
|
+
import { TextDriver } from "../text/Text.driver.new";
|
|
5
|
+
import { ImageDriver } from "../image/Image.driver.new";
|
|
6
|
+
export const BadgeDriver = props => {
|
|
7
|
+
const driver = usePressableDriver(useComponentDriver(props));
|
|
8
|
+
const labelDriver = TextDriver({
|
|
9
|
+
renderTree: props.renderTree,
|
|
10
|
+
testID: `${props.testID}.label`
|
|
11
|
+
});
|
|
12
|
+
const iconDriver = ImageDriver({
|
|
13
|
+
renderTree: props.renderTree,
|
|
14
|
+
testID: `${props.testID}.icon`
|
|
15
|
+
});
|
|
16
|
+
const getLabel = () => {
|
|
17
|
+
return {
|
|
18
|
+
...labelDriver
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const getIcon = () => {
|
|
22
|
+
const exists = () => {
|
|
23
|
+
return iconDriver.exists();
|
|
24
|
+
};
|
|
25
|
+
const getStyle = () => {
|
|
26
|
+
return StyleSheet.flatten(iconDriver.getElement().props.style);
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
...iconDriver,
|
|
30
|
+
exists,
|
|
31
|
+
getStyle
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const getStyle = () => {
|
|
35
|
+
return StyleSheet.flatten(driver.getElement().props.style);
|
|
36
|
+
};
|
|
37
|
+
const getSize = () => {
|
|
38
|
+
return getStyle().height;
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
...driver,
|
|
42
|
+
getLabel,
|
|
43
|
+
getIcon,
|
|
44
|
+
getStyle,
|
|
45
|
+
getSize
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -130,10 +130,11 @@ class Badge extends PureComponent {
|
|
|
130
130
|
renderLabel() {
|
|
131
131
|
const {
|
|
132
132
|
labelStyle,
|
|
133
|
-
label
|
|
133
|
+
label,
|
|
134
|
+
testID
|
|
134
135
|
} = this.props;
|
|
135
136
|
if (label) {
|
|
136
|
-
return <Text style={[this.styles.label, this.isSmallBadge() && this.styles.labelSmall, labelStyle]} allowFontScaling={false} numberOfLines={1} testID=
|
|
137
|
+
return <Text style={[this.styles.label, this.isSmallBadge() && this.styles.labelSmall, labelStyle]} allowFontScaling={false} numberOfLines={1} testID={testID ? `${testID}.label` : 'badge'} recorderTag={'unmask'}>
|
|
137
138
|
{this.getFormattedLabel()}
|
|
138
139
|
</Text>;
|
|
139
140
|
}
|
|
@@ -150,12 +151,13 @@ class Badge extends PureComponent {
|
|
|
150
151
|
iconStyle,
|
|
151
152
|
iconProps,
|
|
152
153
|
borderColor,
|
|
153
|
-
label
|
|
154
|
+
label,
|
|
155
|
+
testID
|
|
154
156
|
} = this.props;
|
|
155
157
|
const flex = label ? 0 : 1;
|
|
156
158
|
return icon && <Image source={icon} resizeMode="contain" tintColor={Colors.$iconDefaultLight}
|
|
157
159
|
//@ts-ignore
|
|
158
|
-
borderColor={borderColor} {...iconProps} style={{
|
|
160
|
+
borderColor={borderColor} testID={testID ? `${testID}.icon` : undefined} {...iconProps} style={{
|
|
159
161
|
flex,
|
|
160
162
|
...iconStyle
|
|
161
163
|
}} />;
|
package/src/testkit/index.d.ts
CHANGED
|
@@ -23,3 +23,4 @@ export { ToastDriver } from '../incubator/toast/Toast.driver.new';
|
|
|
23
23
|
export { DateTimePickerDriver } from '../components/dateTimePicker/DateTimePicker.driver';
|
|
24
24
|
export { TimelineDriver } from '../components/timeline/timeline.driver';
|
|
25
25
|
export { ChipDriver } from '../components/chip/chip.driver';
|
|
26
|
+
export { BadgeDriver } from '../components/badge/badge.driver';
|
package/src/testkit/index.js
CHANGED
|
@@ -22,4 +22,5 @@ export { ExpandableOverlayDriver } from "../incubator/expandableOverlay/Expandab
|
|
|
22
22
|
export { ToastDriver } from "../incubator/toast/Toast.driver.new";
|
|
23
23
|
export { DateTimePickerDriver } from "../components/dateTimePicker/DateTimePicker.driver";
|
|
24
24
|
export { TimelineDriver } from "../components/timeline/timeline.driver";
|
|
25
|
-
export { ChipDriver } from "../components/chip/chip.driver";
|
|
25
|
+
export { ChipDriver } from "../components/chip/chip.driver";
|
|
26
|
+
export { BadgeDriver } from "../components/badge/badge.driver";
|