2017-05-07 22:35:56 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Cookies from 'js-cookie';
|
2017-08-14 15:22:48 +00:00
|
|
|
import PipelineSchedulesCallout from '~/pipeline_schedules/components/pipeline_schedules_callout.vue';
|
2017-05-07 22:35:56 +00:00
|
|
|
|
|
|
|
const PipelineSchedulesCalloutComponent = Vue.extend(PipelineSchedulesCallout);
|
|
|
|
const cookieKey = 'pipeline_schedules_callout_dismissed';
|
2017-05-09 15:35:22 +00:00
|
|
|
const docsUrl = 'help/ci/scheduled_pipelines';
|
2017-05-07 22:35:56 +00:00
|
|
|
|
|
|
|
describe('Pipeline Schedule Callout', () => {
|
2017-05-09 15:35:22 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
setFixtures(`
|
|
|
|
<div id='pipeline-schedules-callout' data-docs-url=${docsUrl}></div>
|
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
2017-05-07 22:35:56 +00:00
|
|
|
describe('independent of cookies', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
this.calloutComponent = new PipelineSchedulesCalloutComponent().$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('the component can be initialized', () => {
|
|
|
|
expect(this.calloutComponent).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly sets illustrationSvg', () => {
|
|
|
|
expect(this.calloutComponent.illustrationSvg).toContain('<svg');
|
|
|
|
});
|
2017-05-09 15:35:22 +00:00
|
|
|
|
|
|
|
it('correctly sets docsUrl', () => {
|
|
|
|
expect(this.calloutComponent.docsUrl).toContain(docsUrl);
|
|
|
|
});
|
2017-05-07 22:35:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe(`when ${cookieKey} cookie is set`, () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
Cookies.set(cookieKey, true);
|
|
|
|
this.calloutComponent = new PipelineSchedulesCalloutComponent().$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly sets calloutDismissed to true', () => {
|
|
|
|
expect(this.calloutComponent.calloutDismissed).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render the callout', () => {
|
|
|
|
expect(this.calloutComponent.$el.childNodes.length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when cookie is not set', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
Cookies.remove(cookieKey);
|
|
|
|
this.calloutComponent = new PipelineSchedulesCalloutComponent().$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly sets calloutDismissed to false', () => {
|
|
|
|
expect(this.calloutComponent.calloutDismissed).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the callout container', () => {
|
|
|
|
expect(this.calloutComponent.$el.querySelector('.bordered-box')).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the callout svg', () => {
|
|
|
|
expect(this.calloutComponent.$el.outerHTML).toContain('<svg');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the callout title', () => {
|
|
|
|
expect(this.calloutComponent.$el.outerHTML).toContain('Scheduling Pipelines');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the callout text', () => {
|
|
|
|
expect(this.calloutComponent.$el.outerHTML).toContain('runs pipelines in the future');
|
|
|
|
});
|
|
|
|
|
2017-05-09 15:35:22 +00:00
|
|
|
it('renders the documentation url', () => {
|
|
|
|
expect(this.calloutComponent.$el.outerHTML).toContain(docsUrl);
|
|
|
|
});
|
|
|
|
|
2017-05-07 22:35:56 +00:00
|
|
|
it('updates calloutDismissed when close button is clicked', (done) => {
|
|
|
|
this.calloutComponent.$el.querySelector('#dismiss-callout-btn').click();
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(this.calloutComponent.calloutDismissed).toBe(true);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('#dismissCallout updates calloutDismissed', (done) => {
|
|
|
|
this.calloutComponent.dismissCallout();
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(this.calloutComponent.calloutDismissed).toBe(true);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is hidden when close button is clicked', (done) => {
|
|
|
|
this.calloutComponent.$el.querySelector('#dismiss-callout-btn').click();
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(this.calloutComponent.$el.childNodes.length).toBe(0);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|