fix blank space on link preview when no site name (#2193)
This commit is contained in:
parent
1fbfe33a22
commit
2cf3ac18f5
3 changed files with 76 additions and 2 deletions
|
|
@ -76,6 +76,59 @@ exports[`PostAttachmentOpenGraph should match snapshot, without image and descri
|
|||
</Component>
|
||||
`;
|
||||
|
||||
exports[`PostAttachmentOpenGraph should match snapshot, without site_name 1`] = `
|
||||
<Component
|
||||
style={
|
||||
Object {
|
||||
"borderColor": "rgba(61,60,64,0.2)",
|
||||
"borderRadius": 3,
|
||||
"borderWidth": 1,
|
||||
"flex": 1,
|
||||
"marginTop": 10,
|
||||
"padding": 10,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Component
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.2}
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Component
|
||||
ellipsizeMode="tail"
|
||||
numberOfLines={3}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"color": "#2389d7",
|
||||
"fontSize": 14,
|
||||
"marginBottom": 10,
|
||||
},
|
||||
Object {
|
||||
"marginRight": 0,
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
Title
|
||||
</Component>
|
||||
</TouchableOpacity>
|
||||
</Component>
|
||||
</Component>
|
||||
`;
|
||||
|
||||
exports[`PostAttachmentOpenGraph should match state and snapshot, on renderDescription 1`] = `null`;
|
||||
|
||||
exports[`PostAttachmentOpenGraph should match state and snapshot, on renderDescription 2`] = `
|
||||
|
|
|
|||
|
|
@ -234,8 +234,9 @@ export default class PostAttachmentOpenGraph extends PureComponent {
|
|||
|
||||
const style = getStyleSheet(theme);
|
||||
|
||||
return (
|
||||
<View style={style.container}>
|
||||
let siteTitle;
|
||||
if (openGraphData.site_name) {
|
||||
siteTitle = (
|
||||
<View style={style.flex}>
|
||||
<Text
|
||||
style={style.siteTitle}
|
||||
|
|
@ -245,6 +246,12 @@ export default class PostAttachmentOpenGraph extends PureComponent {
|
|||
{openGraphData.site_name}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style.container}>
|
||||
{siteTitle}
|
||||
<View style={style.wrapper}>
|
||||
<TouchableOpacity
|
||||
style={style.flex}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,20 @@ describe('PostAttachmentOpenGraph', () => {
|
|||
expect(wrapper.find(TouchableOpacity).exists()).toEqual(true);
|
||||
});
|
||||
|
||||
test('should match snapshot, without site_name', () => {
|
||||
const newOpenGraphData = {
|
||||
title: 'Title',
|
||||
url: 'https://mattermost.com/',
|
||||
};
|
||||
const wrapper = shallow(
|
||||
<PostAttachmentOpenGraph
|
||||
{...baseProps}
|
||||
openGraphData={newOpenGraphData}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.getElement()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match state and snapshot, on renderImage', () => {
|
||||
const wrapper = shallow(
|
||||
<PostAttachmentOpenGraph {...baseProps}/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue