2017-03-20 11:36:02 -04:00
|
|
|
import Vue from 'vue';
|
2017-06-14 09:04:50 -04:00
|
|
|
import pipelinesComp from '~/pipelines/components/pipelines.vue';
|
2017-04-19 07:44:37 -04:00
|
|
|
import Store from '~/pipelines/stores/pipelines_store';
|
2017-03-20 11:36:02 -04:00
|
|
|
|
|
|
|
describe('Pipelines', () => {
|
2017-05-05 06:34:42 -04:00
|
|
|
const jsonFixtureName = 'pipelines/pipelines.json';
|
|
|
|
|
2017-03-20 11:36:02 -04:00
|
|
|
preloadFixtures('static/pipelines.html.raw');
|
2017-05-05 06:34:42 -04:00
|
|
|
preloadFixtures(jsonFixtureName);
|
2017-03-20 11:36:02 -04:00
|
|
|
|
|
|
|
let PipelinesComponent;
|
2017-05-05 06:34:42 -04:00
|
|
|
let pipeline;
|
2017-03-20 11:36:02 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
loadFixtures('static/pipelines.html.raw');
|
2017-05-05 06:34:42 -04:00
|
|
|
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
|
|
|
|
pipeline = pipelines.find(p => p.id === 1);
|
2017-03-20 11:36:02 -04:00
|
|
|
|
|
|
|
PipelinesComponent = Vue.extend(pipelinesComp);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('successfull request', () => {
|
|
|
|
describe('with pipelines', () => {
|
|
|
|
const pipelinesInterceptor = (request, next) => {
|
2017-05-05 06:34:42 -04:00
|
|
|
next(request.respondWith(JSON.stringify(pipeline), {
|
2017-03-20 11:36:02 -04:00
|
|
|
status: 200,
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(pipelinesInterceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(
|
|
|
|
Vue.http.interceptors, pipelinesInterceptor,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render table', (done) => {
|
|
|
|
const component = new PipelinesComponent({
|
|
|
|
propsData: {
|
|
|
|
store: new Store(),
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(component.$el.querySelector('.table-holder')).toBeDefined();
|
2017-03-21 12:09:09 -04:00
|
|
|
expect(component.$el.querySelector('.realtime-loading')).toBe(null);
|
2017-03-20 11:36:02 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without pipelines', () => {
|
|
|
|
const emptyInterceptor = (request, next) => {
|
|
|
|
next(request.respondWith(JSON.stringify([]), {
|
|
|
|
status: 200,
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(emptyInterceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(
|
|
|
|
Vue.http.interceptors, emptyInterceptor,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render empty state', (done) => {
|
|
|
|
const component = new PipelinesComponent({
|
|
|
|
propsData: {
|
|
|
|
store: new Store(),
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2017-03-21 07:38:45 -04:00
|
|
|
expect(component.$el.querySelector('.empty-state')).toBeDefined();
|
2017-03-21 12:09:09 -04:00
|
|
|
expect(component.$el.querySelector('.realtime-loading')).toBe(null);
|
2017-03-20 11:36:02 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('unsuccessfull request', () => {
|
|
|
|
const errorInterceptor = (request, next) => {
|
|
|
|
next(request.respondWith(JSON.stringify([]), {
|
|
|
|
status: 500,
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Vue.http.interceptors.push(errorInterceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(
|
|
|
|
Vue.http.interceptors, errorInterceptor,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render error state', (done) => {
|
|
|
|
const component = new PipelinesComponent({
|
|
|
|
propsData: {
|
|
|
|
store: new Store(),
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(component.$el.querySelector('.js-pipelines-error-state')).toBeDefined();
|
2017-03-21 12:09:09 -04:00
|
|
|
expect(component.$el.querySelector('.realtime-loading')).toBe(null);
|
2017-03-20 11:36:02 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|