2021-09-30 23:02:18 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import IDEProjectHeader from '~/ide/components/ide_project_header.vue';
|
|
|
|
import ProjectAvatar from '~/vue_shared/components/project_avatar.vue';
|
|
|
|
|
|
|
|
const mockProject = {
|
2022-08-27 11:52:29 +05:30
|
|
|
id: 1,
|
2021-09-30 23:02:18 +05:30
|
|
|
name: 'test proj',
|
|
|
|
avatar_url: 'https://gitlab.com',
|
|
|
|
path_with_namespace: 'path/with-namespace',
|
|
|
|
web_url: 'https://gitlab.com/project',
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('IDE project header', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const findProjectAvatar = () => wrapper.findComponent(ProjectAvatar);
|
|
|
|
const findProjectLink = () => wrapper.find('[data-testid="go-to-project-link"');
|
|
|
|
|
|
|
|
const createComponent = () => {
|
|
|
|
wrapper = shallowMount(IDEProjectHeader, { propsData: { project: mockProject } });
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('template', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders ProjectAvatar with correct props', () => {
|
|
|
|
expect(findProjectAvatar().props()).toMatchObject({
|
2022-08-27 11:52:29 +05:30
|
|
|
projectId: mockProject.id,
|
2021-09-30 23:02:18 +05:30
|
|
|
projectName: mockProject.name,
|
|
|
|
projectAvatarUrl: mockProject.avatar_url,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders a link to the project URL', () => {
|
|
|
|
const link = findProjectLink();
|
|
|
|
expect(link.exists()).toBe(true);
|
|
|
|
expect(link.attributes('href')).toBe(mockProject.web_url);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|