This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
text_dismissable_bar.test.jsx
61 lines (48 loc) · 2.08 KB
/
text_dismissable_bar.test.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import TextDismissableBar from 'components/announcement_bar/text_dismissable_bar.jsx';
describe('components/TextDismissableBar', () => {
const baseProps = {
allowDismissal: true,
text: 'sample text',
onDismissal: jest.fn(),
extraProp: 'test',
};
test('should match snapshot', () => {
const props = baseProps;
const wrapper = shallow(
<TextDismissableBar {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, with link but without siteURL', () => {
const props = {...baseProps, text: 'A [link](http:https://testurl.com/admin_console/)'};
const wrapper = shallow(
<TextDismissableBar {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, with an internal url', () => {
const props = {...baseProps, text: 'A [link](http:https://testurl.com/admin_console/) with an internal url', siteURL: 'http:https://testurl.com'};
const wrapper = shallow(
<TextDismissableBar {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, with ean external url', () => {
const props = {...baseProps, text: 'A [link](http:https://otherurl.com/admin_console/) with an external url', siteURL: 'http:https://testurl.com'};
const wrapper = shallow(
<TextDismissableBar {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, with an internal and an external link', () => {
const props = {...baseProps, text: 'A [link](http:https://testurl.com/admin_console/) with an internal url and a [link](http:https://other-url.com/admin_console/) with an external url', siteURL: 'http:https://testurl.com'};
const wrapper = shallow(
<TextDismissableBar {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
});