From 641d4c11ee157864c4434edd574977ef7fd8d095 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Tue, 14 Aug 2018 13:58:19 -0700 Subject: [PATCH 1/2] failing fm-loader test --- package.json | 6 +++--- test/mdx-fm-loader.js | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 test/mdx-fm-loader.js diff --git a/package.json b/package.json index 3f519ec..1f530a4 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "license": "MIT", "dependencies": { "@compositor/log": "^1.0.0-0", - "@mdx-js/loader": "^0.11.0", - "@mdx-js/mdx": "^0.10.1", - "@mdx-js/tag": "^0.11.0", + "@mdx-js/loader": "^0.15.0", + "@mdx-js/mdx": "^0.15.0", + "@mdx-js/tag": "^0.15.0", "@rebass/markdown": "^1.0.0-1", "babel-core": "^6.26.3", "babel-loader": "^7.1.4", diff --git a/test/mdx-fm-loader.js b/test/mdx-fm-loader.js new file mode 100644 index 0000000..29e8b2a --- /dev/null +++ b/test/mdx-fm-loader.js @@ -0,0 +1,27 @@ +import test from "ava"; +import mdx from "@mdx-js/mdx"; +import { transform } from "babel-core"; +import env from "babel-preset-env"; +import react from "babel-preset-react"; +import stage0 from "babel-preset-stage-0"; + +import fmLoader from "../lib/mdx-fm-loader"; + +const content = `# A Heading + +some other content`; + +test("mdx-fm-loader", async t => { + const loader = fmLoader.bind({ + async() { + return (err, result) => { + t.is(err, null, "mdx-fm-loader should not error"); + t.throws(() => { + transform(mdx.sync(result), { presets: [env, react, stage0] }); + }, SyntaxError); + }; + } + }); + + const cb = await loader(content); +}); From f948c285fa27d6ab99f65547e4a7b34fc30c25b3 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Tue, 14 Aug 2018 23:45:19 -0700 Subject: [PATCH 2/2] adding a newline no longer throws --- lib/mdx-fm-loader.js | 1 + test/mdx-fm-loader.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mdx-fm-loader.js b/lib/mdx-fm-loader.js index 28a04c6..336c797 100644 --- a/lib/mdx-fm-loader.js +++ b/lib/mdx-fm-loader.js @@ -7,6 +7,7 @@ module.exports = async function (src) { const { content, data } = matter(src) const code = `export const frontMatter = ${stringifyObject(data)} + ${content} ` return callback(null, code) diff --git a/test/mdx-fm-loader.js b/test/mdx-fm-loader.js index 29e8b2a..222fb43 100644 --- a/test/mdx-fm-loader.js +++ b/test/mdx-fm-loader.js @@ -16,7 +16,7 @@ test("mdx-fm-loader", async t => { async() { return (err, result) => { t.is(err, null, "mdx-fm-loader should not error"); - t.throws(() => { + t.notThrows(() => { transform(mdx.sync(result), { presets: [env, react, stage0] }); }, SyntaxError); };