BigW Consortium Gitlab

user_callout_spec.js 976 Bytes
Newer Older
1
import Cookies from 'js-cookie';
Mike Greiling committed
2
import UserCallout from '~/user_callout';
3

4
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
5

6
describe('UserCallout', function () {
7
  const fixtureName = 'dashboard/user-callout.html.raw';
8
  preloadFixtures(fixtureName);
9

10
  beforeEach(() => {
11
    loadFixtures(fixtureName);
12
    Cookies.remove(USER_CALLOUT_COOKIE);
13

14
    this.userCallout = new UserCallout();
15 16
    this.closeButton = $('.js-close-callout.close');
    this.userCalloutBtn = $('.js-close-callout:not(.close)');
17
  });
18

19
  it('hides when user clicks on the dismiss-icon', (done) => {
20
    this.closeButton.click();
21
    expect(Cookies.get(USER_CALLOUT_COOKIE)).toBe('true');
22 23 24 25 26 27 28 29

    setTimeout(() => {
      expect(
        document.querySelector('.user-callout'),
      ).toBeNull();

      done();
    });
30
  });
31

32
  it('hides when user clicks on the "check it out" button', () => {
33
    this.userCalloutBtn.click();
34
    expect(Cookies.get(USER_CALLOUT_COOKIE)).toBe('true');
35
  });
36
});