2019-07-31 22:56:46 +05:30
|
|
|
import Vuex from 'vuex';
|
2019-07-07 11:18:12 +05:30
|
|
|
import createStore from '~/import_projects/store';
|
2019-07-31 22:56:46 +05:30
|
|
|
import { createLocalVue, mount } from '@vue/test-utils';
|
2019-07-07 11:18:12 +05:30
|
|
|
import importedProjectTableRow from '~/import_projects/components/imported_project_table_row.vue';
|
|
|
|
import STATUS_MAP from '~/import_projects/constants';
|
|
|
|
|
|
|
|
describe('ImportedProjectTableRow', () => {
|
|
|
|
let vm;
|
|
|
|
const project = {
|
|
|
|
id: 1,
|
|
|
|
fullPath: 'fullPath',
|
|
|
|
importStatus: 'finished',
|
|
|
|
providerLink: 'providerLink',
|
|
|
|
importSource: 'importSource',
|
|
|
|
};
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
function mountComponent() {
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
const component = mount(importedProjectTableRow, {
|
|
|
|
localVue,
|
|
|
|
store: createStore(),
|
2019-07-07 11:18:12 +05:30
|
|
|
propsData: {
|
|
|
|
project: {
|
|
|
|
...project,
|
|
|
|
},
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
sync: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
return component.vm;
|
2019-07-07 11:18:12 +05:30
|
|
|
}
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponent();
|
|
|
|
});
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders an imported project table row', () => {
|
|
|
|
const providerLink = vm.$el.querySelector('.js-provider-link');
|
|
|
|
const statusObject = STATUS_MAP[project.importStatus];
|
|
|
|
|
|
|
|
expect(vm.$el.classList.contains('js-imported-project')).toBe(true);
|
|
|
|
expect(providerLink.href).toMatch(project.providerLink);
|
|
|
|
expect(providerLink.textContent).toMatch(project.importSource);
|
|
|
|
expect(vm.$el.querySelector('.js-full-path').textContent).toMatch(project.fullPath);
|
|
|
|
expect(vm.$el.querySelector(`.${statusObject.textClass}`).textContent).toMatch(
|
|
|
|
statusObject.text,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector(`.ic-status_${statusObject.icon}`)).not.toBeNull();
|
|
|
|
expect(vm.$el.querySelector('.js-go-to-project').href).toMatch(project.fullPath);
|
|
|
|
});
|
|
|
|
});
|