Skip to content

Feature/hints #31

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 5 commits into from
Jun 7, 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
setup hint tests
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jun 7, 2020
commit 5eed9564d91aab681043c08747e0501a156ac92b
6 changes: 6 additions & 0 deletions src/templates/TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ Short description of the step's purpose. Should be short and fit in one line
### L1S2 Another step

Step's short description.

#### Hints

- If a hint exists, the user can request a hint
- Hints will show up in the order they are written
- When all hints are added, the hint option will become disabled
225 changes: 225 additions & 0 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,4 +812,229 @@ Description.
};
expect(result.config).toEqual(expected.config);
});

// hints
it("should parse hints for a step", () => {
const md = `# Title

Description.

## L1 Title 1

First level content.

### L1S1

The first step

#### Hints

* First Hint
* Second Hint

`;
const skeleton = {
levels: [
{
id: "L1",
steps: [
{
id: "L1S1",
},
],
},
],
};
const result = parse({
text: md,
skeleton,
commits: {
L1S1Q: ["abcdef1", "123456789"],
},
});
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: ["abcdef1", "123456789"],
},
hints: ["First Hint", "Second Hint"],
},
],
},
],
};
expect(result.levels).toEqual(expected.levels);
});

it("should parse hints for a step", () => {
const md = `# Title

Description.

## L1 Title 1

First level content.

### L1S1

The first step

#### Hints

* First Hint with \`markdown\`. See **bold**
* Second Hint has a codeblock

\`\`\`js
var a = 1;
\`\`\`

And spans multiple lines.
`;
const skeleton = {
levels: [
{
id: "L1",
steps: [
{
id: "L1S1",
},
],
},
],
};
const result = parse({
text: md,
skeleton,
commits: {
L1S1Q: ["abcdef1", "123456789"],
},
});
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: ["abcdef1", "123456789"],
},
hints: [
"First Hint with `markdown`. See **bold**",
"Second Hint has a codeblock\n\n```js\nvar a = 1;\n```\n\nAnd spans multiple lines.",
],
},
],
},
],
};
expect(result.levels).toEqual(expected.levels);
});

it("should parse hints and not interrupt next step", () => {
const md = `# Title

Description.

## L1 Title 1

First level content.

### L1S1

The first step

#### Hints

* First Hint with \`markdown\`. See **bold**
* Second Hint has a codeblock

\`\`\`js
var a = 1;
\`\`\`

And spans multiple lines.

### L1S2A

The second uninterrupted step
`;
const skeleton = {
levels: [
{
id: "L1",
steps: [
{
id: "L1S1",
},
{
id: "L1S2",
},
],
},
],
};
const result = parse({
text: md,
skeleton,
commits: {
L1S1Q: ["abcdef1", "123456789"],
L1S2Q: ["fedcba1"],
},
});
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: ["abcdef1", "123456789"],
},
hints: [
"First Hint with `markdown`. See **bold**",
"Second Hint has a codeblock\n\n```js\nvar a = 1;\n```\n\nAnd spans multiple lines.",
],
},
{
id: "L1S2",
content: "The second uninterrupted step",
setup: {
commits: ["fedcba1"],
},
},
],
},
{},
],
};
expect(result.levels).toEqual(expected.levels);
});
});