Skip to content

Feature/optional level description #54

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 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add optional level description tests
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Jul 1, 2020
commit 4afd1178dabf06f340f4c5dec2f35289e38ac4b9
13 changes: 13 additions & 0 deletions tests/markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ Some text that describes the level

### 1.1

First Step`;
expect(validateMarkdown(md)).toBe(true);
});

it("should allow for empty level content", () => {
const md = `# Title

Description.

## 1. Put Level's title here

### 1.1

First Step`;
expect(validateMarkdown(md)).toBe(true);
});
Expand Down
37 changes: 37 additions & 0 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,43 @@ But not including this line.
expect(result.levels[0]).toEqual(expected.levels[0]);
});

it("should allow for empty level content", () => {
const md = `# Title

Description.

## 1. Put Level's title here

### 1.1

A step
`;

const skeleton = { levels: [{ id: "1" }] };
const result = parse({
text: md,
skeleton,
commits: {},
});
const expected = {
levels: [
{
id: "1",
title: "Put Level's title here",
summary: "",
content: "",
steps: [
{
id: "1.1",
content: "A step",
},
],
},
],
};
expect(result.levels[0]).toEqual(expected.levels[0]);
});

it("should match line breaks with double line breaks for proper spacing", () => {
const md = `# Title

Expand Down
77 changes: 50 additions & 27 deletions tests/tutorial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,48 @@ import * as T from "../typings/tutorial";
import tutorialSchema from "../src/schema/tutorial";
import { validateSchema } from "../src/utils/validateSchema";

const validJson: Partial<T.Tutorial> = {
version: "0.1.0",
summary: { title: "Title", description: "Description" },
config: {
testRunner: {
command: "aCommand",
args: {
filter: "filter",
tap: "tap",
},
directory: "coderoad",
setup: {
commits: ["abcdef1"],
commands: ["npm install"],
},
},
repo: {
uri: "https://github.com/some-repo.git",
branch: "someBranch",
},
dependencies: [{ name: "name", version: ">=1" }],
appVersions: {
vscode: ">=0.7.0",
},
},
levels: [
{
id: "1",
title: "Level 1",
summary: "The first level",
content: "The first level",
steps: [
{
id: "1.1",
content: "The first step",
setup: { commits: [] },
},
],
},
],
};

const validateTutorial = (json: any) => validateSchema(tutorialSchema, json);

describe("validate tutorial", () => {
Expand All @@ -12,37 +54,18 @@ describe("validate tutorial", () => {
expect(valid).toBe(false);
});
it("should return true for a valid tutorial", () => {
const json: Partial<T.Tutorial> = {
version: "0.1.0",
summary: { title: "Title", description: "Description" },
config: {
testRunner: {
command: "aCommand",
args: {
filter: "filter",
tap: "tap",
},
directory: "coderoad",
setup: {
commits: ["abcdef1"],
commands: ["npm install"],
},
},
repo: {
uri: "https://github.com/some-repo.git",
branch: "someBranch",
},
dependencies: [{ name: "name", version: ">=1" }],
appVersions: {
vscode: ">=0.7.0",
},
},
const valid = validateTutorial({ ...validJson });
expect(valid).toBe(true);
});
it("should return true for a tutorial with no level content", () => {
const json = {
...validJson,
levels: [
{
id: "1",
title: "Level 1",
summary: "The first level",
content: "The first level",
summary: "",
content: "",
steps: [],
},
],
Expand Down