Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-03 21:10:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-03 21:10:10 +0300
commitc2a6cc86754adb3c5e064cebc58d206a52cb412e (patch)
tree3960c9ae2590e89e25193a0006e84d06f900e378 /spec/frontend/whats_new
parentbbd9e2c915c46920ceb51376db19599cbf9ba836 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/whats_new')
-rw-r--r--spec/frontend/whats_new/utils/notification_spec.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/frontend/whats_new/utils/notification_spec.js b/spec/frontend/whats_new/utils/notification_spec.js
new file mode 100644
index 00000000000..e3e390f4394
--- /dev/null
+++ b/spec/frontend/whats_new/utils/notification_spec.js
@@ -0,0 +1,55 @@
+import { useLocalStorageSpy } from 'helpers/local_storage_helper';
+import { setNotification, getStorageKey } from '~/whats_new/utils/notification';
+
+describe('~/whats_new/utils/notification', () => {
+ useLocalStorageSpy();
+
+ let wrapper;
+
+ const findNotificationEl = () => wrapper.querySelector('.header-help');
+ const findNotificationCountEl = () => wrapper.querySelector('.js-whats-new-notification-count');
+ const getAppEl = () => wrapper.querySelector('.app');
+
+ beforeEach(() => {
+ loadFixtures('static/whats_new_notification.html');
+ wrapper = document.querySelector('.whats-new-notification-fixture-root');
+ });
+
+ afterEach(() => {
+ wrapper.remove();
+ });
+
+ describe('setNotification', () => {
+ const subject = () => setNotification(getAppEl());
+
+ it("when storage key doesn't exist it adds notifications class", () => {
+ const notificationEl = findNotificationEl();
+
+ expect(notificationEl.classList).not.toContain('with-notifications');
+
+ subject();
+
+ expect(findNotificationCountEl()).toExist();
+ expect(notificationEl.classList).toContain('with-notifications');
+ });
+
+ it('removes class and count element when storage key is true', () => {
+ const notificationEl = findNotificationEl();
+ notificationEl.classList.add('with-notifications');
+ localStorage.setItem('storage-key', 'false');
+
+ expect(findNotificationCountEl()).toExist();
+
+ subject();
+
+ expect(findNotificationCountEl()).not.toExist();
+ expect(notificationEl.classList).not.toContain('with-notifications');
+ });
+ });
+
+ describe('getStorageKey', () => {
+ it('retrieves the storage key data attribute from the el', () => {
+ expect(getStorageKey(getAppEl())).toBe('storage-key');
+ });
+ });
+});