forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
announcement_bar.test.jsx
103 lines (85 loc) · 3.03 KB
/
announcement_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import 'tests/helpers/localstorage.jsx';
import AnnouncementBar from 'components/announcement_bar/default_announcement_bar/announcement_bar.jsx';
describe('components/AnnouncementBar', () => {
const baseProps = {
isLoggedIn: true,
canViewSystemErrors: false,
canViewAPIv3Banner: false,
license: {
id: '',
},
siteURL: '',
sendEmailNotifications: true,
enablePreviewMode: false,
bannerText: 'Banner text',
allowBannerDismissal: true,
enableBanner: true,
bannerColor: 'green',
bannerTextColor: 'black',
enableSignUpWithGitLab: false,
message: 'text',
announcementBarCount: 0,
actions: {
sendVerificationEmail: jest.fn(),
incrementAnnouncementBarCount: jest.fn(),
decrementAnnouncementBarCount: jest.fn()
},
};
test('should match snapshot, bar showing', () => {
const props = baseProps;
const wrapper = shallow(
<AnnouncementBar {...props}/>
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, bar not showing', () => {
const props = {...baseProps, enableBanner: false};
const wrapper = shallow(
<AnnouncementBar {...props}/>
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, bar showing, no dismissal', () => {
const props = {...baseProps, allowBannerDismissal: false};
const wrapper = shallow(
<AnnouncementBar {...props}/>
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, props change', () => {
const props = baseProps;
const wrapper = shallow(
<AnnouncementBar {...props}/>
);
expect(wrapper).toMatchSnapshot();
const newProps = {...baseProps, bannerColor: 'yellow', bannerTextColor: 'red'};
wrapper.setProps(newProps);
expect(wrapper).toMatchSnapshot();
newProps.allowBannerDismissal = false;
wrapper.setProps(newProps);
expect(wrapper).toMatchSnapshot();
newProps.enableBanner = false;
wrapper.setProps(newProps);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, dismissal', () => {
const props = baseProps;
const wrapper = shallow(
<AnnouncementBar {...props}/>
);
// Banner should show
expect(wrapper).toMatchSnapshot();
// Banner should remain hidden
const newProps = {...baseProps, bannerColor: 'yellow', bannerTextColor: 'red'};
wrapper.setProps(newProps);
expect(wrapper).toMatchSnapshot();
// Banner should return
newProps.bannerText = 'Some new text';
wrapper.setProps(newProps);
expect(wrapper).toMatchSnapshot();
});
});