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