2017-02-16 22:02:40 +00:00
|
|
|
/* esint-disable space-before-function-paren, arrow-body-style */
|
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-02-17 17:28:52 +00:00
|
|
|
describe('UserCallout', function () {
|
|
|
|
const fixtureName = 'static/user_callout.html.raw';
|
|
|
|
preloadFixtures(fixtureName);
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
loadFixtures(fixtureName);
|
|
|
|
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.userCalloutContainer = $('.user-callout');
|
|
|
|
this.userCalloutBtn = $('.user-callout-btn');
|
|
|
|
Cookie.set(USER_CALLOUT_COOKIE, 0);
|
|
|
|
});
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
it('shows when cookie is set to false', () => {
|
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBeDefined();
|
|
|
|
expect(this.userCalloutContainer.is(':visible')).toBe(true);
|
|
|
|
});
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
it('hides when user clicks on the dismiss-icon', () => {
|
2017-02-20 15:39:23 +00:00
|
|
|
this.closeButton.click();
|
2017-02-17 17:28:52 +00:00
|
|
|
expect(this.userCalloutContainer.is(':visible')).toBe(false);
|
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBe('1');
|
|
|
|
});
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
it('hides when user clicks on the "check it out" button', () => {
|
|
|
|
this.userCalloutBtn.click();
|
|
|
|
expect(this.userCalloutContainer.is(':visible')).toBe(false);
|
|
|
|
expect(Cookie.get(USER_CALLOUT_COOKIE)).toBe('1');
|
2017-02-16 22:02:40 +00:00
|
|
|
});
|
2017-02-17 17:28:52 +00:00
|
|
|
});
|