diff --git a/package-lock.json b/package-lock.json index 2beb72e21..ce932ff8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,17 +13,17 @@ } }, "@babel/core": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.4.tgz", - "integrity": "sha512-lQgGX3FPRgbz2SKmhMtYgJvVzGZrmjaF4apZ2bLwofAKiSjxU0drPh4S/VasyYXwaTs+A1gvQ45BN8SQJzHsQQ==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.5.tgz", + "integrity": "sha512-OvjIh6aqXtlsA8ujtGKfC7LYWksYSX8yQcM8Ay3LuvVeQ63lcOKgoZWVqcpFwkd29aYU9rVx7jxhfhiEDV9MZA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "@babel/generator": "^7.4.4", "@babel/helpers": "^7.4.4", - "@babel/parser": "^7.4.4", + "@babel/parser": "^7.4.5", "@babel/template": "^7.4.4", - "@babel/traverse": "^7.4.4", + "@babel/traverse": "^7.4.5", "@babel/types": "^7.4.4", "convert-source-map": "^1.1.0", "debug": "^4.1.0", @@ -44,9 +44,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -121,9 +121,9 @@ } }, "@babel/parser": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.4.tgz", - "integrity": "sha512-5pCS4mOsL+ANsFZGdvNLybx4wtqAZJ0MJjMHxvzI3bvIsz6sQvzW8XX92EYIkiPtIvcfG3Aj+Ir5VNyjnZhP7w==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.5.tgz", + "integrity": "sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==", "dev": true }, "@babel/plugin-syntax-object-rest-spread": { @@ -155,16 +155,16 @@ } }, "@babel/traverse": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.4.tgz", - "integrity": "sha512-Gw6qqkw/e6AGzlyj9KnkabJX7VcubqPtkUQVAwkc0wUMldr3A/hezNB3Rc5eIvId95iSGkGIOe5hh1kMKf951A==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.5.tgz", + "integrity": "sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "@babel/generator": "^7.4.4", "@babel/helper-function-name": "^7.1.0", "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.4.4", + "@babel/parser": "^7.4.5", "@babel/types": "^7.4.4", "debug": "^4.1.0", "globals": "^11.1.0", @@ -181,9 +181,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -207,14 +207,6 @@ "requires": { "exec-sh": "^0.3.2", "minimist": "^1.2.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } } }, "@commitlint/config-conventional": { @@ -1394,9 +1386,9 @@ "integrity": "sha512-f11CfQatW7W1hFZnOh7xdnfRl76/0RyEJfKgH2Cwbfgz/QGVHbh585QWN3+ae2zJka8gES1DfvtxhmH5KOlEBQ==" }, "@stencila/typescript-boilerplate": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@stencila/typescript-boilerplate/-/typescript-boilerplate-1.1.1.tgz", - "integrity": "sha512-BuOqkGZ8RMWzSCr/Two9+BzuhUtIKuJ1zisSUbTyNG/Yp/AEPRMFkNzWkw+AhUH3bw0iNs2wWHpL52yTlDVO5g==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@stencila/typescript-boilerplate/-/typescript-boilerplate-1.1.2.tgz", + "integrity": "sha512-T8H45ySttsXDzXiLWwauax3hmomJRcQOn8+2PBdlYv6pYK/3l4BAZV0fbg5roSx1nnHzRkZYLooiG52eOw5Frg==", "dev": true, "requires": { "@types/jest": "^24.0.15", @@ -1417,25 +1409,6 @@ "requires": { "@types/jest-diff": "*" } - }, - "ts-node": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", - "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==", - "dev": true, - "requires": { - "arg": "^4.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "source-map-support": "^0.5.6", - "yn": "^3.0.0" - } - }, - "typescript": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", - "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", - "dev": true } } }, @@ -1446,9 +1419,9 @@ "dev": true }, "@types/babel__core": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.1.tgz", - "integrity": "sha512-+hjBtgcFPYyCTo0A15+nxrCVJL7aC6Acg87TXd5OW3QhHswdrOLoles+ldL2Uk8q++7yIfl4tURtztccdeeyOw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.2.tgz", + "integrity": "sha512-cfCCrFmiGY/yq0NuKNxIQvZFy9kY/1immpSpTngOnyIbD4+eJOG5mxphhHDv3CHL9GltO4GcKr54kGBg3RNdbg==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -1478,9 +1451,9 @@ } }, "@types/babel__traverse": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.6.tgz", - "integrity": "sha512-XYVgHF2sQ0YblLRMLNPB3CkFMewzFmlDsH/TneZFHUXDlABQgh88uOxuez7ZcXxayLFrqLwtDH1t+FmlFwNZxw==", + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.7.tgz", + "integrity": "sha512-CeBpmX1J8kWLcDEnI3Cl2Eo6RfbGvzUctA+CjZUhOKDFbLfcr7fc4usEqLNWetrlJd7RhAkyYe2czXop4fICpw==", "dev": true, "requires": { "@babel/types": "^7.3.0" @@ -2531,9 +2504,9 @@ } }, "bser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz", - "integrity": "sha1-mseNPtXZFYBP2HrLFYvHlxR6Fxk=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.0.tgz", + "integrity": "sha512-8zsjWrQkkBoLK6uxASk1nJ2SKv97ltiGDo6A3wA0/yRPz+CwmEyDo0hUrhIuukG2JHpAl3bvFIixw2/3Hi0DOg==", "dev": true, "requires": { "node-int64": "^0.4.0" @@ -6651,9 +6624,9 @@ }, "dependencies": { "semver": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", - "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", + "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==", "dev": true } } @@ -6723,9 +6696,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "source-map": { @@ -6737,9 +6710,9 @@ } }, "istanbul-reports": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.4.tgz", - "integrity": "sha512-QCHGyZEK0bfi9GR215QSm+NJwFKEShbtc7tfbUdLAEzn3kKhLDDZqvljn8rPZM9v8CEOhzL1nlYoO4r1ryl67w==", + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.6.tgz", + "integrity": "sha512-SKi4rnMyLBKe0Jy2uUdx28h8oG7ph2PPuQPvIAh31d+Ci+lSiEu4C+h3oBPuJ9+mPKhOyW0M8gY4U5NM1WLeXA==", "dev": true, "requires": { "handlebars": "^4.1.2" @@ -7011,9 +6984,9 @@ "dev": true }, "jest-haste-map": { - "version": "24.8.0", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.0.tgz", - "integrity": "sha512-ZBPRGHdPt1rHajWelXdqygIDpJx8u3xOoLyUBWRW28r3tagrgoepPrzAozW7kW9HrQfhvmiv1tncsxqHJO1onQ==", + "version": "24.8.1", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.1.tgz", + "integrity": "sha512-SwaxMGVdAZk3ernAx2Uv2sorA7jm3Kx+lR0grp6rMmnY06Kn/urtKx1LPN2mGTea4fCT38impYT28FfcLUhX0g==", "dev": true, "requires": { "@jest/types": "^24.8.0", @@ -8354,9 +8327,9 @@ } }, "nan": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", - "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", "dev": true, "optional": true }, @@ -13140,9 +13113,9 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, "prompts": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.0.4.tgz", - "integrity": "sha512-HTzM3UWp/99A0gk51gAegwo1QRYA7xjcZufMNe33rCclFszUYAuHe1fIN/3ZmiHeGPkUsNaRyQm1hHOfM0PKxA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", + "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", "dev": true, "requires": { "kleur": "^3.0.2", @@ -13850,9 +13823,9 @@ } }, "rsvp": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.4.tgz", - "integrity": "sha512-6FomvYPfs+Jy9TfXmBpBuMWNH94SgCsZmJKcanySzgNNP6LjWxBvyLTa9KaMfDDM5oxRfrKDB0r/qeRsLwnBfA==", + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, "run-async": { @@ -13912,14 +13885,6 @@ "micromatch": "^3.1.4", "minimist": "^1.1.1", "walker": "~1.0.5" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } } }, "sax": { @@ -14092,9 +14057,9 @@ } }, "sisteransi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.0.tgz", - "integrity": "sha512-N+z4pHB4AmUv0SjveWRd6q1Nj5w62m5jodv+GD8lvmbY/83T/rpbJGZOnK5T149OldDj4Db07BSv9xY4K6NTPQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.1.tgz", + "integrity": "sha512-Qs1o9b0ORUzmh04fZjVzqeQ0L9tmJCL1eyivJcDNCY16gOEvR299INgXwBdy2bq38bVgSpq4DDfhgQx515ToLQ==", "dev": true }, "slash": { @@ -15025,9 +14990,9 @@ } }, "ts-node": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.2.0.tgz", - "integrity": "sha512-m8XQwUurkbYqXrKqr3WHCW310utRNvV5OnRVeISeea7LoCWVcdfeB/Ntl8JYWFh+WRoUAdBgESrzKochQt7sMw==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", + "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==", "dev": true, "requires": { "arg": "^4.1.0", diff --git a/package.json b/package.json index 2291f69d5..5ebdff997 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "install": "npx ts-node ./install.ts", "test": "jest", "test:cover": "jest --collectCoverage", - "test:watch": "jest --watch", + "test:watch": "jest --watchAll", "check": "npm run build && npm run check:deps-used && npm run check:deps-unused", "check:deps-used": "dependency-check --missing .", "check:deps-unused": "dependency-check --unused --no-dev --ignore-module @stencila/schema --ignore-module @stencila/thema .", @@ -76,7 +76,7 @@ }, "devDependencies": { "@stencila/dev-config": "^1.0.5", - "@stencila/typescript-boilerplate": "^1.1.1", + "@stencila/typescript-boilerplate": "^1.1.2", "@types/async-lock": "^1.1.1", "@types/escape-html": "0.0.20", "@types/fs-extra": "^7.0.0", @@ -124,6 +124,7 @@ "preset": "ts-jest", "testEnvironment": "node", "setupFilesAfterEnv": [ + "/src/__tests__/logger.ts", "/src/__tests__/matchers.ts" ], "testMatch": [ @@ -136,6 +137,7 @@ "globalTeardown": "/src/__tests__/teardown.ts", "testPathIgnorePatterns": [ "/dist/", + "__tests__/logger.ts", "__tests__/matchers.ts", "__tests__/teardown.ts", "__tests__/helpers.ts" diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 73f024d56..2b69a9a7a 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -90,7 +90,7 @@ test('load', async () => { }) test('dump', async () => { - expect(await dump(simpleThing, { format: 'json' })).toEqual(simpleThingJson) + expect(await dump(simpleThing, 'json')).toEqual(simpleThingJson) }) describe('read', () => { diff --git a/src/__tests__/issues/58-list-unordered.test.ts b/src/__tests__/issues/58-list-unordered.test.ts index c9a99db4e..8a2056b4e 100644 --- a/src/__tests__/issues/58-list-unordered.test.ts +++ b/src/__tests__/issues/58-list-unordered.test.ts @@ -27,7 +27,7 @@ describe('issue 58', () => { test('that gdoc converts to the expected md', async () => { const article = (await read(file)) as stencila.Article - const md = await dump(article, { format: 'md' }) + const md = await dump(article, 'md') expect(md).toBe(`--- title: real converter test authors: [] diff --git a/src/__tests__/logger.ts b/src/__tests__/logger.ts new file mode 100644 index 000000000..aee2dfc12 --- /dev/null +++ b/src/__tests__/logger.ts @@ -0,0 +1,8 @@ +import { replaceHandlers, defaultHandler } from '@stencila/logga' + +/** + * Show all log entries except for DEBUG level during tests + */ +replaceHandlers(data => { + if (data.level < 3) defaultHandler(data) +}) diff --git a/src/codecs/dmagic/demo-magic.test.ts b/src/codecs/dmagic/demo-magic.test.ts index a034ec69f..688ad68ba 100644 --- a/src/codecs/dmagic/demo-magic.test.ts +++ b/src/codecs/dmagic/demo-magic.test.ts @@ -9,9 +9,7 @@ test('decode', async () => { }) test('encode', async () => { - expect( - await dump(await encode(node, { codecOptions: { embed: false } })) - ).toEqual(bash) + expect(await dump(await encode(node, { isBundle: false }))).toEqual(bash) expect(await encode(node)).toBeTruthy() }) diff --git a/src/codecs/dmagic/index.ts b/src/codecs/dmagic/index.ts index 63a4c57eb..b755fc2da 100644 --- a/src/codecs/dmagic/index.ts +++ b/src/codecs/dmagic/index.ts @@ -30,23 +30,19 @@ export async function decode(file: vfile.VFile): Promise { throw new Error('Decoding of Demo Magic scripts is not supported.') } -interface DemoMagicOptions { - embed?: boolean -} - /** * Encode a Stencila `Node` to a `VFile` with `demo-magic.sh` content. * * @param thing The Stencila `Node` to encode * @returns A promise that resolves to a `VFile` */ -export const encode: Encode = async ( +export const encode: Encode = async ( node: stencila.Node, - { codecOptions = {} }: EncodeOptions = {} + options: EncodeOptions = {} ): Promise => { - const { embed = true } = codecOptions + const { isBundle = true } = options let bash = await encodeNode(node) - if (embed) { + if (isBundle) { if (!demoMagicSh) { demoMagicSh = await fs.readFile( path.join(__dirname, 'demo-magic-template.sh'), @@ -102,6 +98,6 @@ async function encodeNode(node: stencila.Node): Promise { * Generate escaped Markdown suitable for inserting into Bash */ async function escapedMd(node: stencila.Node): Promise { - const markdown = await dump(node, { format: 'md' }) + const markdown = await dump(node, 'md') return markdown.replace(/`/g, '\\`') } diff --git a/src/codecs/html/__snapshots__/html.test.ts.snap b/src/codecs/html/__snapshots__/html.test.ts.snap deleted file mode 100644 index 2f6aa0448..000000000 --- a/src/codecs/html/__snapshots__/html.test.ts.snap +++ /dev/null @@ -1,1718 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`encode 1`] = ` -" - - - Our article - - - - - - - -
-

Heading one

-

Heading two

-

Heading three

-

A paragraph with emphasis, strong, delete.

-

A paragraph with a rich link. -

-

A paragraph with quote.

-

A paragraph with # code.

-

A paragraph with an image \\"alt.

-

Paragraph with a true and a false - .

-

A paragraph with other data: a null, a 3.14 - , and a [1,2].

-

A paragraph with an {a:1,b:'two'} and a - {type:'Person'}.

-
A blockquote
-
# Some code
-x = c(1,2)
-
// Test for html character escaping. See note at https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
-const inc = (n) => n + 1
-
    -
  • One
  • -
  • Two
  • -
  • Three
  • -
-
    -
  1. First
  2. -
  3. Second
  4. -
  5. Third
  6. -
- - - - - - - - - - - - - - - - - - -
ABC
123
456
-
-
- - -" -`; - -exports[`encode 2`] = ` -"

A link and da code.

" -`; diff --git a/src/codecs/html/html.test.ts b/src/codecs/html/html.test.ts index 1fab08cb2..d87bd7e3c 100644 --- a/src/codecs/html/html.test.ts +++ b/src/codecs/html/html.test.ts @@ -1,14 +1,8 @@ import stencila from '@stencila/schema' import fs from 'fs' import { dump, load } from '../../util/vfile' -import { beautify, decode, encode } from './' - -const js = fs.readFileSync( - require.resolve('@stencila/thema/dist/themes/stencila') -) -const stylesheet = fs.readFileSync( - require.resolve('@stencila/thema/dist/themes/stencila/styles.css') -) +import { decode, encode } from './' +import { EncodeOptions } from '../..' test('decode', async () => { expect(await decode(load(kitchenSink.html))).toEqual(kitchenSink.node) @@ -17,98 +11,121 @@ test('decode', async () => { }) test('encode', async () => { - expect(await dump(await encode(kitchenSink.node))).toMatchSnapshot() - expect( - await dump(await encode(attrs.node, { isStandalone: false })) - ).toMatchSnapshot() - expect(await dump(await encode(dt.node, { isStandalone: false }))).toEqual( - dt.html + const e = async (node: stencila.Node, options: EncodeOptions = {}) => + await dump(await encode(node, options)) + + expect(await e(kitchenSink.node, { isStandalone: false })).toEqual( + kitchenSink.html ) + expect(await e(attrs.node, { isStandalone: false })).toEqual(attrs.html) + expect(await e(dt.node, { isStandalone: false })).toEqual(dt.html) }) -// An example intended for testing progressively added decoder/encoder pairs -const kitchenSink = { - html: ` +test('encode with different themes', async () => { + const e = async (options: EncodeOptions = {}) => + await dump(await encode(kitchenSink.node, options)) - - Our article - - - ${beautify(``)} - ${beautify(``)} - + let html = await e({ theme: 'stencila' }) + expect(html).toMatch( + /