Skip to content

Commit 6627395

Browse files
committed
require an "id" for a tutorial
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent 336e9fe commit 6627395

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/schema/skeleton.ts

Lines changed: 7 additions & 1 deletion
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
};

src/schema/tutorial.ts

Lines changed: 6 additions & 0 deletions
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.",

tests/skeleton.test.ts

Lines changed: 8 additions & 0 deletions
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

tests/tutorial.test.ts

Lines changed: 1 addition & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy