Skip to content

require an "id" for a tutorial #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/schema/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export default {
...meta,
type: "object",
properties: {
id: {
type: "string",
description: "A unique identifier for your tutorial. Currently no system to create this, so create your own for now",
examples: ["fcc-learn-npm"]
},

version: {
$ref: "#/definitions/semantic_version",
description: "The tutorial version. Must be unique for the tutorial.",
Expand Down Expand Up @@ -253,5 +259,5 @@ export default {
},
},
additionalProperties: false,
required: ["version", "config", "levels"],
required: ["id", "version", "config", "levels"],
};
6 changes: 6 additions & 0 deletions src/schema/tutorial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export default {
...meta,
type: "object",
properties: {
id: {
type: "string",
description: "A unique identifier for your tutorial. Currently no system to create this, so create your own for now",
examples: ["fcc-learn-npm"]
},

version: {
$ref: "#/definitions/semantic_version",
description: "The tutorial version. Must be unique for the tutorial.",
Expand Down
8 changes: 8 additions & 0 deletions tests/skeleton.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import skeletonSchema from '../src/schema/skeleton'
const validateSkeleton = (json: any) => validateSchema(skeletonSchema, json)

const validJson = {
id: 'coderoad-test',
version: '0.1.0',
config: {
testRunner: {
Expand Down Expand Up @@ -95,6 +96,13 @@ describe('validate skeleton', () => {
const valid = validateSkeleton(json)
expect(valid).toBe(true)
})
it('should fail if id is missing', () => {
const json = { ...validJson, id: undefined }

const valid = validateSkeleton(json)
expect(valid).toBe(false)
})

it('should fail if version is invalid', () => {
const json = { ...validJson, version: 'NOT A VERSION' }

Expand Down
1 change: 1 addition & 0 deletions tests/tutorial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tutorialSchema from '../src/schema/tutorial'
import { validateSchema } from '../src/utils/validateSchema'

const validJson: Partial<T.Tutorial> = {
id: 'coderoad-test',
version: '0.1.0',
summary: { title: 'Title', description: 'Description' },
config: {
Expand Down