2017-03-11 06:45:34 +00:00
|
|
|
import Cookies from 'js-cookie';
|
2017-03-22 08:26:12 +00:00
|
|
|
import UserCallout from '~/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';
|
2017-02-16 22:02:40 +00:00
|
|
|
|
2017-03-02 21:10:39 +00:00
|
|
|
describe('UserCallout', function () {
|
2017-03-24 12:41:42 +00:00
|
|
|
const fixtureName = 'dashboard/user-callout.html.raw';
|
2017-02-17 17:28:52 +00:00
|
|
|
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-11 06:45:34 +00:00
|
|
|
Cookies.remove(USER_CALLOUT_COOKIE);
|
2017-03-02 21:10:39 +00:00
|
|
|
|
2017-02-17 17:28:52 +00:00
|
|
|
this.userCallout = new UserCallout();
|
2017-03-24 12:41:42 +00:00
|
|
|
this.closeButton = $('.js-close-callout.close');
|
|
|
|
this.userCalloutBtn = $('.js-close-callout:not(.close)');
|
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-24 12:41:42 +00:00
|
|
|
it('hides when user clicks on the dismiss-icon', (done) => {
|
2017-02-20 15:39:23 +00:00
|
|
|
this.closeButton.click();
|
2017-03-11 06:45:34 +00:00
|
|
|
expect(Cookies.get(USER_CALLOUT_COOKIE)).toBe('true');
|
2017-03-24 12:41:42 +00:00
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(
|
|
|
|
document.querySelector('.user-callout'),
|
|
|
|
).toBeNull();
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
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-03-11 06:45:34 +00:00
|
|
|
expect(Cookies.get(USER_CALLOUT_COOKIE)).toBe('true');
|
2017-02-16 22:02:40 +00:00
|
|
|
});
|
2017-02-17 17:28:52 +00:00
|
|
|
});
|