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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import InstalledCommand from 'components/integrations/components/installed_command.jsx';
describe('components/integrations/InstalledCommand', () => {
const emptyFunction = jest.fn();
const command = {
id: 'r5tpgt4iepf45jt768jz84djic',
display_name: 'test',
description: 'test',
trigger: 'trigger',
auto_complete: 'test',
auto_complete_hint: 'test',
token: 'testToken',
create_at: '1499722850203'
};
test('should match snapshot', () => {
const wrapper = shallow(
<InstalledCommand
team={{
name: 'test'
}}
command={command}
onRegenToken={emptyFunction}
onDelete={emptyFunction}
filter={'trigger'}
creator={{
username: 'test'
}}
canChange={true}
/>
);
expect(wrapper).toMatchSnapshot();
});
test('should call onRegenToken function', () => {
const onRegenToken = jest.fn();
const wrapper = shallow(
<InstalledCommand
team={{
name: 'test'
}}
command={command}
onRegenToken={onRegenToken}
onDelete={emptyFunction}
filter={''}
creator={{
username: 'test'
}}
canChange={true}
/>
);
wrapper.find('div.item-actions a').first().simulate('click', {preventDefault() {
return jest.fn();
}});
expect(onRegenToken).toBeCalled();
});
test('should filter out command', () => {
const wrapper = shallow(
<InstalledCommand
team={{
name: 'test'
}}
command={command}
onRegenToken={emptyFunction}
onDelete={emptyFunction}
filter={'filter'}
creator={{
username: 'test'
}}
canChange={true}
/>
);
expect(wrapper).toMatchSnapshot();
});
});
|