diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/frontend/broadcast_notification_spec.js | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/frontend/broadcast_notification_spec.js')
-rw-r--r-- | spec/frontend/broadcast_notification_spec.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/frontend/broadcast_notification_spec.js b/spec/frontend/broadcast_notification_spec.js new file mode 100644 index 00000000000..8d433946632 --- /dev/null +++ b/spec/frontend/broadcast_notification_spec.js @@ -0,0 +1,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), + }); + }); +}); |