chore(scaffolder): making the templater field mandatory

This commit is contained in:
blam
2020-07-13 10:53:30 +02:00
parent 240b183a01
commit 87698e2fe6
2 changed files with 10 additions and 2 deletions
@@ -32,7 +32,8 @@ describe('TemplateEntityV1alpah1', () => {
name: 'test',
},
spec: {
type: 'cookiecutter',
type: 'website',
templater: 'cookiecutter',
schema: {
$schema: 'http://json-schema.org/draft-07/schema#',
required: ['storePath', 'owner'],
@@ -78,7 +79,7 @@ describe('TemplateEntityV1alpah1', () => {
await expect(policy.enforce(entity)).rejects.toThrow(/type/);
});
it('acceptps any other type', async () => {
it('accepts any other type', async () => {
(entity as any).spec.type = 'hallo';
await expect(policy.enforce(entity)).resolves.toBe(entity);
});
@@ -87,4 +88,9 @@ describe('TemplateEntityV1alpah1', () => {
(entity as any).spec.type = '';
await expect(policy.enforce(entity)).rejects.toThrow(/type/);
});
it('rejects missing templater', async () => {
(entity as any).spec.templater = '';
await expect(policy.enforce(entity)).rejects.toThrow(/templater/);
});
});
@@ -26,6 +26,7 @@ export interface TemplateEntityV1alpha1 extends Entity {
kind: typeof KIND;
spec: {
type: string;
templater: string;
path?: string;
schema: JSONSchema;
};
@@ -43,6 +44,7 @@ export class TemplateEntityV1alpha1Policy implements EntityPolicy {
type: yup.string().required().min(1),
path: yup.string(),
schema: yup.object().required(),
templater: yup.string().required(),
})
.required(),
});