Skip to content

Commit

Permalink
Update the test fixture to reproduce #166
Browse files Browse the repository at this point in the history
  • Loading branch information
hmsk committed Jun 2, 2020
1 parent e414c7c commit 9deec94
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
14 changes: 14 additions & 0 deletions test/__snapshots__/frontmatter-markdown-loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ exports[`frontmatter-markdown-loader react mode returns renderable React compone
</code>
FRIEND CHEERS
</p>
<pre>
<code
class="language-js"
>
const multipleLine = true; console.warn(multipleLine)
</code>
</pre>
</div>
`;

Expand Down Expand Up @@ -58,5 +65,12 @@ exports[`frontmatter-markdown-loader react mode returns renderable React compone
</code>
FRIEND CHEERS
</p>
<pre>
<code
class="language-js"
>
const multipleLine = true; console.warn(multipleLine)
</code>
</pre>
</div>
`;
16 changes: 12 additions & 4 deletions test/frontmatter-markdown-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe("frontmatter-markdown-loader", () => {
});

it("returns compiled HTML for 'html' property", () => {
expect(loaded.html).toBe("<h1>Title</h1>\n<p>GOOD <code>BYE</code> FRIEND\nCHEERS</p>\n");
expect(loaded.html).toBe(
"<h1>Title</h1>\n<p>GOOD <code>BYE</code> FRIEND\nCHEERS</p>\n<pre><code class=\"language-js\">const multipleLine = true;\nconsole.warn(multipleLine)\n</code></pre>\n"
);
});

it("returns frontmatter object for 'attributes' property", () => {
Expand Down Expand Up @@ -82,7 +84,9 @@ describe("frontmatter-markdown-loader", () => {
describe("markdownId option", () => {
it("returns HTML with configured markdownIt: breaks option is enabled as configuration", () => {
load(markdownWithFrontmatter, { ...defaultContext, query: { markdownIt: { breaks: true } } });
expect(loaded.html).toBe("<h1>Title</h1>\n<p>GOOD <code>BYE</code> FRIEND<br>\nCHEERS</p>\n");
expect(loaded.html).toBe(
"<h1>Title</h1>\n<p>GOOD <code>BYE</code> FRIEND<br>\nCHEERS</p>\n<pre><code class=\"language-js\">const multipleLine = true;\nconsole.warn(multipleLine)\n</code></pre>\n"
)
});

it("returns HTML with configured markdownIt instance: breaks option is enabled by .enable", () => {
Expand All @@ -96,14 +100,18 @@ describe("frontmatter-markdown-loader", () => {
};

load(markdownWithFrontmatter, { ...defaultContext, query: { markdownIt: markdownItInstance } });
expect(loaded.html).toBe("<h1>Title</h1>\n<p data-paragraph=\"hello\">GOOD <code>BYE</code> FRIEND\nCHEERS</p>\n");
expect(loaded.html).toBe(
"<h1>Title</h1>\n<p data-paragraph=\"hello\">GOOD <code>BYE</code> FRIEND\nCHEERS</p>\n<pre><code class=\"language-js\">const multipleLine = true;\nconsole.warn(multipleLine)\n</code></pre>\n"
);
});
});

describe("body mode is enabled", () => {
it("returns raw markdown body for 'body' property", () => {
load(markdownWithFrontmatter, { ...defaultContext, query: { mode: [Mode.BODY] } });
expect(loaded.body).toBe("# Title\n\nGOOD `BYE` FRIEND\nCHEERS\n");
expect(loaded.body).toBe(
"# Title\n\nGOOD `BYE` FRIEND\nCHEERS\n\n```js\nconst multipleLine = true;\nconsole.warn(multipleLine)\n```\n"
);
});
});

Expand Down
5 changes: 5 additions & 0 deletions test/with-frontmatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ tags:

GOOD `BYE` FRIEND
CHEERS

```js
const multipleLine = true;
console.warn(multipleLine)
```

0 comments on commit 9deec94

Please sign in to comment.