2017-05-10 10:05:58 -04:00
|
|
|
import Vue from 'vue';
|
2017-05-12 07:54:10 -04:00
|
|
|
import Store from '~/issue_show/stores';
|
2017-05-10 10:05:58 -04:00
|
|
|
import titleComponent from '~/issue_show/components/title.vue';
|
|
|
|
|
|
|
|
describe('Title component', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(titleComponent);
|
2017-05-15 10:34:01 -04:00
|
|
|
const store = new Store({
|
|
|
|
titleHtml: '',
|
|
|
|
descriptionHtml: '',
|
|
|
|
issuableRef: '',
|
|
|
|
});
|
2017-05-10 10:05:58 -04:00
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
issuableRef: '#1',
|
|
|
|
titleHtml: 'Testing <img />',
|
|
|
|
titleText: 'Testing',
|
2017-05-12 07:54:10 -04:00
|
|
|
showForm: false,
|
2017-05-15 10:34:01 -04:00
|
|
|
formState: store.formState,
|
2017-05-10 10:05:58 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders title HTML', () => {
|
|
|
|
expect(
|
2017-05-24 07:42:23 -04:00
|
|
|
vm.$el.innerHTML.trim(),
|
2017-05-10 10:05:58 -04:00
|
|
|
).toBe('Testing <img>');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('updates page title when changing titleHtml', (done) => {
|
|
|
|
spyOn(vm, 'setPageTitle');
|
|
|
|
vm.titleHtml = 'test';
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(
|
|
|
|
vm.setPageTitle,
|
|
|
|
).toHaveBeenCalled();
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('animates title changes', (done) => {
|
|
|
|
vm.titleHtml = 'test';
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(
|
2017-05-24 07:42:23 -04:00
|
|
|
vm.$el.classList.contains('issue-realtime-pre-pulse'),
|
2017-05-10 10:05:58 -04:00
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(
|
2017-05-24 07:42:23 -04:00
|
|
|
vm.$el.classList.contains('issue-realtime-trigger-pulse'),
|
2017-05-10 10:05:58 -04:00
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('updates page title after changing title', (done) => {
|
|
|
|
vm.titleHtml = 'changed';
|
|
|
|
vm.titleText = 'changed';
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(
|
|
|
|
document.querySelector('title').textContent.trim(),
|
|
|
|
).toContain('changed');
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|