All files / app/assets/javascripts/whats_new/utils notification.js

100% Statements 13/13
75% Branches 3/4
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 202x   3x   2x 2x 2x 2x   2x 1x 1x 1x 1x     1x      
export const STORAGE_KEY = 'display-whats-new-notification';
 
export const getVersionDigest = (appEl) => appEl.getAttribute('data-version-digest');
 
export const setNotification = (appEl) => {
  const versionDigest = getVersionDigest(appEl);
  const notificationEl = document.querySelector('.header-help');
  let notificationCountEl = notificationEl.querySelector('.js-whats-new-notification-count');
 
  if (localStorage.getItem(STORAGE_KEY) === versionDigest) {
    notificationEl.classList.remove('with-notifications');
    Eif (notificationCountEl) {
      notificationCountEl.parentElement.removeChild(notificationCountEl);
      notificationCountEl = null;
    }
  } else {
    notificationEl.classList.add('with-notifications');
  }
};