Skip to content

Commit 346959f

Browse files
authored
Merge pull request #93 from coderoad/feature/add-id-requirement
require an "id" for a tutorial
2 parents 336e9fe + 6627395 commit 346959f

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

Diff for: src/schema/skeleton.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export default {
77
...meta,
88
type: "object",
99
properties: {
10+
id: {
11+
type: "string",
12+
description: "A unique identifier for your tutorial. Currently no system to create this, so create your own for now",
13+
examples: ["fcc-learn-npm"]
14+
},
15+
1016
version: {
1117
$ref: "#/definitions/semantic_version",
1218
description: "The tutorial version. Must be unique for the tutorial.",
@@ -253,5 +259,5 @@ export default {
253259
},
254260
},
255261
additionalProperties: false,
256-
required: ["version", "config", "levels"],
262+
required: ["id", "version", "config", "levels"],
257263
};

Diff for: src/schema/tutorial.ts

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export default {
77
...meta,
88
type: "object",
99
properties: {
10+
id: {
11+
type: "string",
12+
description: "A unique identifier for your tutorial. Currently no system to create this, so create your own for now",
13+
examples: ["fcc-learn-npm"]
14+
},
15+
1016
version: {
1117
$ref: "#/definitions/semantic_version",
1218
description: "The tutorial version. Must be unique for the tutorial.",

Diff for: tests/skeleton.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import skeletonSchema from '../src/schema/skeleton'
44
const validateSkeleton = (json: any) => validateSchema(skeletonSchema, json)
55

66
const validJson = {
7+
id: 'coderoad-test',
78
version: '0.1.0',
89
config: {
910
testRunner: {
@@ -95,6 +96,13 @@ describe('validate skeleton', () => {
9596
const valid = validateSkeleton(json)
9697
expect(valid).toBe(true)
9798
})
99+
it('should fail if id is missing', () => {
100+
const json = { ...validJson, id: undefined }
101+
102+
const valid = validateSkeleton(json)
103+
expect(valid).toBe(false)
104+
})
105+
98106
it('should fail if version is invalid', () => {
99107
const json = { ...validJson, version: 'NOT A VERSION' }
100108

Diff for: tests/tutorial.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import tutorialSchema from '../src/schema/tutorial'
33
import { validateSchema } from '../src/utils/validateSchema'
44

55
const validJson: Partial<T.Tutorial> = {
6+
id: 'coderoad-test',
67
version: '0.1.0',
78
summary: { title: 'Title', description: 'Description' },
89
config: {

0 commit comments

Comments
 (0)