2017-06-02 09:24:42 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import headerComponent from '~/pipelines/components/header_component.vue';
|
|
|
|
import eventHub from '~/pipelines/event_hub';
|
|
|
|
|
|
|
|
describe('Pipeline details header', () => {
|
|
|
|
let HeaderComponent;
|
|
|
|
let vm;
|
|
|
|
let props;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
HeaderComponent = Vue.extend(headerComponent);
|
|
|
|
|
2017-06-05 17:25:59 -04:00
|
|
|
const threeWeeksAgo = new Date();
|
|
|
|
threeWeeksAgo.setDate(threeWeeksAgo.getDate() - 21);
|
|
|
|
|
2017-06-02 09:24:42 -04:00
|
|
|
props = {
|
|
|
|
pipeline: {
|
|
|
|
details: {
|
|
|
|
status: {
|
|
|
|
group: 'failed',
|
2018-07-18 12:56:19 -04:00
|
|
|
icon: 'status_failed',
|
2017-06-02 09:24:42 -04:00
|
|
|
label: 'failed',
|
|
|
|
text: 'failed',
|
|
|
|
details_path: 'path',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
id: 123,
|
2017-06-05 17:25:59 -04:00
|
|
|
created_at: threeWeeksAgo.toISOString(),
|
2017-06-02 09:24:42 -04:00
|
|
|
user: {
|
|
|
|
web_url: 'path',
|
|
|
|
name: 'Foo',
|
|
|
|
username: 'foobar',
|
|
|
|
email: 'foo@bar.com',
|
|
|
|
avatar_url: 'link',
|
|
|
|
},
|
|
|
|
retry_path: 'path',
|
|
|
|
},
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
vm = new HeaderComponent({ propsData: props }).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided pipeline info', () => {
|
|
|
|
expect(
|
2018-10-17 03:13:26 -04:00
|
|
|
vm.$el
|
|
|
|
.querySelector('.header-main-content')
|
|
|
|
.textContent.replace(/\s+/g, ' ')
|
|
|
|
.trim(),
|
2018-11-07 12:20:17 -05:00
|
|
|
).toContain('failed Pipeline #123 triggered 3 weeks ago by Foo');
|
2017-06-02 09:24:42 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('action buttons', () => {
|
|
|
|
it('should call postAction when button action is clicked', () => {
|
2018-10-17 03:13:26 -04:00
|
|
|
eventHub.$on('headerPostAction', action => {
|
2017-06-02 09:24:42 -04:00
|
|
|
expect(action.path).toEqual('path');
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$el.querySelector('button').click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|