forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_url_context_menu.test.jsx
51 lines (43 loc) · 1.62 KB
/
copy_url_context_menu.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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import CopyUrlContextMenu from 'components/copy_url_context_menu/copy_url_context_menu.jsx';
describe('components/CopyUrlContextMenu', () => {
test('should copy relative url on click', () => {
const props = {
siteURL: 'http:https://example.com',
link: '/path/to/resource',
menuId: 'resource',
actions: {
copyToClipboard: jest.fn(),
},
};
const wrapper = shallow(
<CopyUrlContextMenu {...props}>
<span>{'Click'}</span>
</CopyUrlContextMenu>
);
expect(wrapper).toMatchSnapshot();
wrapper.find('MenuItem').simulate('click');
expect(props.actions.copyToClipboard).toBeCalledWith('http:https://example.com/path/to/resource');
});
test('should copy absolute url on click', () => {
const props = {
siteURL: 'http:https://example.com',
link: 'http:https://site.example.com/path/to/resource',
menuId: 'resource',
actions: {
copyToClipboard: jest.fn(),
},
};
const wrapper = shallow(
<CopyUrlContextMenu {...props}>
<span>{'Click'}</span>
</CopyUrlContextMenu>
);
expect(wrapper).toMatchSnapshot();
wrapper.find('MenuItem').simulate('click');
expect(props.actions.copyToClipboard).toBeCalledWith('http:https://site.example.com/path/to/resource');
});
});