41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { Project, ProjectRunner, ScmInfo } from '../project'
|
|
|
|
describe('ProjectLoader', () => {
|
|
const newProjectOptions = (override?: Partial<Project>): Project => {
|
|
return {
|
|
name: 'my_project',
|
|
scm: {
|
|
url: 'https://some-git.com',
|
|
type: 'git',
|
|
},
|
|
publisher: {},
|
|
resolver: {},
|
|
...override,
|
|
}
|
|
}
|
|
|
|
describe('validateProject()', () => {
|
|
it('throws error for missing name', () => {
|
|
expect(() => ProjectRunner.validateProject(newProjectOptions({ name: undefined })))
|
|
.toThrow(/Missing project name/)
|
|
})
|
|
it('throws error for missing scm info', () => {
|
|
expect(() => ProjectRunner.validateProject(newProjectOptions({ scm: undefined })))
|
|
.toThrow(/Missing scm/)
|
|
})
|
|
it('throws error for invalid scm', () => {
|
|
expect(() => ProjectRunner.validateProject(newProjectOptions({ scm: { type: 'git' } as ScmInfo })))
|
|
.toThrow(/Missing scm url/)
|
|
})
|
|
it('does not throw error for missing scm type', () => {
|
|
expect(() => ProjectRunner.validateProject(newProjectOptions({ scm: { url: 'https://some-git.com' } })))
|
|
.not.toThrow()
|
|
})
|
|
})
|
|
describe('loadProject()', () => {
|
|
it('loads project from js file', () => {
|
|
ProjectRunner.loadProject(__dirname + '/depresolver.config.js')
|
|
})
|
|
})
|
|
})
|