blob: 8d43394663216c764c65aaccd7323563176f53cf (
plain)
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
|
import Cookies from 'js-cookie';
import initBroadcastNotifications from '~/broadcast_notification';
describe('broadcast message on dismiss', () => {
const dismiss = () => {
const button = document.querySelector('.js-dismiss-current-broadcast-notification');
button.click();
};
const endsAt = '2020-01-01T00:00:00Z';
beforeEach(() => {
setFixtures(`
<div class="js-broadcast-notification-1">
<button class="js-dismiss-current-broadcast-notification" data-id="1" data-expire-date="${endsAt}"></button>
</div>
`);
initBroadcastNotifications();
});
it('removes broadcast message', () => {
dismiss();
expect(document.querySelector('.js-broadcast-notification-1')).toBeNull();
});
it('calls Cookies.set', () => {
jest.spyOn(Cookies, 'set');
dismiss();
expect(Cookies.set).toHaveBeenCalledWith('hide_broadcast_message_1', true, {
expires: new Date(endsAt),
});
});
});
|