Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature/test output #11

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 3 commits into from
May 31, 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
Prev Previous commit
Next Next commit
large smoke test
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed May 31, 2020
commit 53cf62ca70fceda0d024e758d5253531ddc2d8e4
4 changes: 2 additions & 2 deletions src/utils/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ export function parseMdContent(md: string): TutorialFrame | never {
// @ts-ignore
mdContent.levels[levelId] = {
id: levelId,
title: levelTitle,
title: levelTitle.trim(),
summary: levelSummary
? levelSummary.trim()
: _.truncate(levelContent, { length: 80, omission: "..." }),
: _.truncate(levelContent.trim(), { length: 80, omission: "..." }),
content: levelContent.trim(),
};
} else {
Expand Down
172 changes: 172 additions & 0 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,178 @@ The first step
expect(result.levels[0].steps[0]).toEqual(expected.levels[0].steps[0]);
});

it("should load the full config for a step", () => {
const md = `# Title

Description.

## L1 Title 1

First level content.

### L1S1

The first step

### L1S2

The second step

## L2 Title 2

Second level content.

### L2S1

The third step
`;
const config = {
levels: [
{
id: "L1",
steps: [
{
id: "L1S1",
setup: {
commands: ["npm install"],
files: ["someFile.js"],
watchers: ["someFile.js"],
filter: "someFilter",
subtasks: true,
},
solution: {
commands: ["npm install"],
files: ["someFile.js"],
},
},
{
id: "L1S2",
setup: {
commands: ["npm install"],
files: ["someFile.js"],
watchers: ["someFile.js"],
filter: "someFilter",
subtasks: true,
},
solution: {
commands: ["npm install"],
files: ["someFile.js"],
},
},
],
},
{
id: "L2",
summary: "Second level content.",
content: "First level content.",
steps: [
{
id: "L2S1",
setup: {
commands: ["npm install"],
files: ["someFile.js"],
watchers: ["someFile.js"],
filter: "someFilter",
subtasks: true,
},
solution: {
commands: ["npm install"],
files: ["someFile.js"],
},
},
],
},
],
};
const result = parse({
text: md,
config,
commits: {
L1S1Q: ["abcdefg1", "123456789"],
L1S1A: ["1gfedcba", "987654321"],
L1S2Q: ["2abcdefg"],
L1S2A: ["3abcdefg"],
L2S1Q: ["4abcdefg"],
L2S1A: ["5abcdefg"],
},
});
const expected = {
summary: {
description: "Description.",
},
levels: [
{
id: "L1",
title: "Title 1",
summary: "First level content.",
content: "First level content.",
steps: [
{
id: "L1S1",
content: "The first step",
setup: {
commits: ["abcdefg1", "123456789"],
commands: ["npm install"],
files: ["someFile.js"],
watchers: ["someFile.js"],
filter: "someFilter",
subtasks: true,
},
solution: {
commits: ["1gfedcba", "987654321"],
commands: ["npm install"],
files: ["someFile.js"],
},
},
{
id: "L1S2",
content: "The second step",
setup: {
commits: ["2abcdefg"],
commands: ["npm install"],
files: ["someFile.js"],
watchers: ["someFile.js"],
filter: "someFilter",
subtasks: true,
},
solution: {
commits: ["3abcdefg"],
commands: ["npm install"],
files: ["someFile.js"],
},
},
],
},
{
id: "L2",
title: "Title 2",
summary: "Second level content.",
content: "Second level content.",
steps: [
{
id: "L2S1",
content: "The third step",
setup: {
commits: ["4abcdefg"],
commands: ["npm install"],
files: ["someFile.js"],
watchers: ["someFile.js"],
filter: "someFilter",
subtasks: true,
},
solution: {
commits: ["5abcdefg"],
commands: ["npm install"],
files: ["someFile.js"],
},
},
],
},
],
};
expect(result.levels).toEqual(expected.levels);
});

// config
it("should parse the tutorial config", () => {
const md = `# Title
Expand Down