From 15cbdf10522ca0a40f58392aea6827365c0c1b4e Mon Sep 17 00:00:00 2001 From: MoOx Date: Wed, 11 Oct 2017 09:03:56 +0200 Subject: [PATCH] @phenomic/plugin-transform-asciidoc: minor tweaks to adjust lint/tests poke @ezralalonde :) --- .../plugin-transform-asciidoc/package.json | 2 +- .../src/__tests__/__snapshots__/index.js.snap | 2 +- .../__snapshots__/transformer.js.snap | 14 ++++++++-- .../src/__tests__/index.js | 2 +- .../src/__tests__/transformer.js | 26 +++++++++---------- .../src/transformer.js | 4 +-- 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/plugin-transform-asciidoc/package.json b/packages/plugin-transform-asciidoc/package.json index 73cd1eaf8..913374846 100644 --- a/packages/plugin-transform-asciidoc/package.json +++ b/packages/plugin-transform-asciidoc/package.json @@ -1,6 +1,6 @@ { "name": "@phenomic/plugin-transform-asciidoc", - "version": "1.0.0-alpha.10", + "version": "1.0.0-alpha.11", "publishConfig": { "access": "public" }, diff --git a/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/index.js.snap b/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/index.js.snap index e9fefc8f5..b2d29f8d4 100644 --- a/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/index.js.snap +++ b/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/index.js.snap @@ -39,7 +39,7 @@ Object {
const name = \\"Ezra\\"
-console.log(\`Hello, nodejs!\`)
+console.log(\`Hello, \${name}!\`)
diff --git a/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/transformer.js.snap b/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/transformer.js.snap index 66a324164..217043eb0 100644 --- a/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/transformer.js.snap +++ b/packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/transformer.js.snap @@ -39,7 +39,7 @@ Object {
const name = \\"Ezra\\"
-console.log(\`Hello, nodejs!\`)
+console.log(\`Hello, \${name}!\`)
@@ -272,7 +272,17 @@ Object { ".log(", Object { "c": Array [ - "\`Hello, nodejs!\`", + "\`Hello, ", + Object { + "c": Array [ + "\${name}", + ], + "p": Object { + "className": "hljs-subst", + }, + "t": "span", + }, + "!\`", ], "p": Object { "className": "hljs-string", diff --git a/packages/plugin-transform-asciidoc/src/__tests__/index.js b/packages/plugin-transform-asciidoc/src/__tests__/index.js index f19dfa51e..b60c2c3ed 100644 --- a/packages/plugin-transform-asciidoc/src/__tests__/index.js +++ b/packages/plugin-transform-asciidoc/src/__tests__/index.js @@ -27,7 +27,7 @@ Test of Asciidoc.js transformer for Phenomic. [source,javascript] const name = "Ezra" -console.log(\`Hello, ${name}!\`) +console.log(\`Hello, \${name}!\`) `) }) ).toMatchSnapshot(); diff --git a/packages/plugin-transform-asciidoc/src/__tests__/transformer.js b/packages/plugin-transform-asciidoc/src/__tests__/transformer.js index ac39bde33..98d1da747 100644 --- a/packages/plugin-transform-asciidoc/src/__tests__/transformer.js +++ b/packages/plugin-transform-asciidoc/src/__tests__/transformer.js @@ -2,7 +2,7 @@ import defaultConfig from "@phenomic/core/lib/defaultConfig.js"; import transformer from "../transformer.js"; -const input = ` +const input = new Buffer(` = Hello, AsciiDoc! Ezra Lalonde v1.0, 2017-10-05: First Draft @@ -18,8 +18,8 @@ Test of Asciidoc.js transformer for Phenomic. [source,javascript] const name = "Ezra" -console.log(\`Hello, ${name}!\`) -`; +console.log(\`Hello, \${name}!\`) +`); it("should render asciidoc as json (react component)", () => { const adoc = transformer( @@ -40,10 +40,10 @@ it("should render asciidoc as html", () => { it("should have tags", () => { const adoc = transformer( defaultConfig, - ` + new Buffer(` = Title :tags: phenomic, documentation, test, déjà vu - ` + `) ); expect(adoc.tags).toEqual(["phenomic", "documentation", "test", "deja-vu"]); }); @@ -51,9 +51,9 @@ it("should have tags", () => { it("should not have tags", () => { const adoc = transformer( defaultConfig, - ` + new Buffer(` = Title - ` + `) ); expect(adoc.tags).toEqual([]); }); @@ -61,12 +61,12 @@ it("should not have tags", () => { it("should use explicit date attribute for date", () => { const adoc = transformer( defaultConfig, - ` + new Buffer(` = Title Ezra Lalonde v1.0, 2017-10-05: First Draft :date: 2011-12-25 - ` + `) ); expect(adoc.date).toBe("2011-12-25"); }); @@ -74,11 +74,11 @@ v1.0, 2017-10-05: First Draft it("should use revdate for date", () => { const adoc = transformer( defaultConfig, - ` + new Buffer(` = Title Ezra Lalonde v1.0, 2017-10-05: First Draft - ` + `) ); expect(adoc.date).toBe("2017-10-05"); }); @@ -86,9 +86,9 @@ v1.0, 2017-10-05: First Draft it("should use have no date attribute", () => { const adoc = transformer( defaultConfig, - ` + new Buffer(` = Title - ` + `) ); expect(adoc.date).toBe(undefined); }); diff --git a/packages/plugin-transform-asciidoc/src/transformer.js b/packages/plugin-transform-asciidoc/src/transformer.js index 819612c84..072281515 100644 --- a/packages/plugin-transform-asciidoc/src/transformer.js +++ b/packages/plugin-transform-asciidoc/src/transformer.js @@ -54,7 +54,7 @@ const envAttributes = [ function processAsciidoc(text) { const ad = asciidoctor(); const doc = ad.load(text, defaultOptions); - let data = { + const data = { ...doc.attributes.$$smap, contents: ad.convert(text, defaultOptions) }; @@ -83,7 +83,7 @@ const createElement = (component, props, children) => { }; }; -export default (config?: PhenomicConfig, contents: string) => { +export default (config?: PhenomicConfig, contents: Buffer) => { const data = processAsciidoc(contents); const processor = unified()