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