2017-02-17 17:28:52 +00:00
|
|
|
const UserCallout = require('~/user_callout');
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
|
|
|
|
const Cookie = window.Cookies;
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
describe('UserCallout', function () {
|
2017-02-17 17:28:52 +00:00
|
|
|
const fixtureName = 'static/user_callout.html.raw';
|
|
|
|
preloadFixtures(fixtureName);
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
beforeEach(() => {
|
2017-02-17 17:28:52 +00:00
|
|
|
loadFixtures(fixtureName);
|
2017-03-02 21:10:39 +00:00
|
|
|
Cookie.remove(USER_CALLOUT_COOKIE);
|
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
this.userCallout = new UserCallout();
|
2017-02-20 15:39:23 +00:00
|
|
|
this.closeButton = $('.close-user-callout');
|
2017-02-17 17:28:52 +00:00
|
|
|
this.userCalloutBtn = $('.user-callout-btn');
|
2017-02-23 21:23:33 +00:00
|
|
|
this.userCalloutContainer = $('.user-callout');
|
2017-02-17 17:28:52 +00:00
|
|
|
});
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
it('does not show when cookie is set not defined', () => {
|
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBeUndefined();
|
|
|
|
expect(this.userCalloutContainer.is(':visible')).toBe(true);
|
2017-02-24 00:22:26 +00:00
|
|
|
});
|
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
it('shows when cookie is set to false', () => {
|
|
|
|
Cookie.set(USER_CALLOUT_COOKIE, 'false');
|
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBeDefined();
|
|
|
|
expect(this.userCalloutContainer.is(':visible')).toBe(true);
|
|
|
|
});
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
it('hides when user clicks on the dismiss-icon', () => {
|
2017-02-20 15:39:23 +00:00
|
|
|
this.closeButton.click();
|
2017-02-22 00:32:51 +00:00
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBe('true');
|
2017-02-17 17:28:52 +00:00
|
|
|
});
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
it('hides when user clicks on the "check it out" button', () => {
|
2017-02-17 17:28:52 +00:00
|
|
|
this.userCalloutBtn.click();
|
2017-02-22 00:32:51 +00:00
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBe('true');
|
2017-02-16 22:02:40 +00:00
|
|
|
});
|
2017-02-17 17:28:52 +00:00
|
|
|
});
|
2017-03-02 21:10:39 +00:00
|
|
|
|
|
|
|
describe('UserCallout when cookie is present', function () {
|
|
|
|
const fixtureName = 'static/user_callout.html.raw';
|
|
|
|
preloadFixtures(fixtureName);
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
loadFixtures(fixtureName);
|
|
|
|
Cookie.set(USER_CALLOUT_COOKIE, 'true');
|
|
|
|
this.userCallout = new UserCallout();
|
|
|
|
this.userCalloutContainer = $('.user-callout');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('removes the DOM element', () => {
|
|
|
|
expect(this.userCalloutContainer.length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|