2022-07-16 23:28:13 +05:30
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2017-09-10 17:25:29 +05:30
|
|
|
import projectImportGitlab from '~/projects/project_import_gitlab_project';
|
|
|
|
|
|
|
|
describe('Import Gitlab project', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
const pathName = 'my-project';
|
|
|
|
const projectName = 'My Project';
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const setTestFixtures = (url) => {
|
2020-03-13 15:44:24 +05:30
|
|
|
window.history.pushState({}, null, url);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
setHTMLFixture(`
|
2017-09-10 17:25:29 +05:30
|
|
|
<input class="js-path-name" />
|
2020-03-13 15:44:24 +05:30
|
|
|
<input class="js-project-name" />
|
2017-09-10 17:25:29 +05:30
|
|
|
`);
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
projectImportGitlab();
|
2020-03-13 15:44:24 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
setTestFixtures(`?name=${projectName}&path=${pathName}`);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
window.history.pushState({}, null, '');
|
2022-07-16 23:28:13 +05:30
|
|
|
resetHTMLFixture();
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('project name', () => {
|
2017-09-10 17:25:29 +05:30
|
|
|
it('should fill in the project name derived from the previously filled project name', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(document.querySelector('.js-project-name').value).toEqual(projectName);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('empty path name', () => {
|
|
|
|
it('derives the path name from the previously filled project name', () => {
|
|
|
|
const alternateProjectName = 'My Alt Project';
|
|
|
|
const alternatePathName = 'my-alt-project';
|
|
|
|
|
|
|
|
setTestFixtures(`?name=${alternateProjectName}`);
|
|
|
|
|
|
|
|
expect(document.querySelector('.js-path-name').value).toEqual(alternatePathName);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('path name', () => {
|
|
|
|
it('should fill in the path name derived from the previously filled path name', () => {
|
|
|
|
expect(document.querySelector('.js-path-name').value).toEqual(pathName);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('empty project name', () => {
|
|
|
|
it('derives the project name from the previously filled path name', () => {
|
|
|
|
const alternateProjectName = 'My Alt Project';
|
|
|
|
const alternatePathName = 'my-alt-project';
|
|
|
|
|
|
|
|
setTestFixtures(`?path=${alternatePathName}`);
|
|
|
|
|
|
|
|
expect(document.querySelector('.js-project-name').value).toEqual(alternateProjectName);
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|