From 72bda7d7e370d639d61caa68a20e6b80e467074a Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 5 Feb 2018 06:15:50 +0100 Subject: Add test with AVA --- __tests__/__snapshots__/index.js.md | 12 +++++++++++ __tests__/__snapshots__/index.js.snap | Bin 0 -> 177 bytes __tests__/index.js | 38 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 __tests__/__snapshots__/index.js.md create mode 100644 __tests__/__snapshots__/index.js.snap create mode 100644 __tests__/index.js (limited to '__tests__') diff --git a/__tests__/__snapshots__/index.js.md b/__tests__/__snapshots__/index.js.md new file mode 100644 index 0000000..f8a1110 --- /dev/null +++ b/__tests__/__snapshots__/index.js.md @@ -0,0 +1,12 @@ +# Snapshot report for `__tests__/index.js` + +The actual snapshot is saved in `index.js.snap`. + +Generated by [AVA](https://ava.li). + +## question + +> Snapshot 1 + + `

␊ + What does the 🦊 say ?

` diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap new file mode 100644 index 0000000..8728a37 Binary files /dev/null and b/__tests__/__snapshots__/index.js.snap differ diff --git a/__tests__/index.js b/__tests__/index.js new file mode 100644 index 0000000..5d4c995 --- /dev/null +++ b/__tests__/index.js @@ -0,0 +1,38 @@ +import test from 'ava'; +import unified from 'unified'; +import raw from 'rehype-raw'; +import reParse from 'remark-parse'; +import stringify from 'rehype-stringify'; +import remark2rehype from 'remark-rehype'; + +import plugin from '../app'; + +const render = text => unified() + .use(reParse) + .use(plugin) + .use(remark2rehype) + .use(stringify) + .processSync(text); + +const renderRaw = text => unified() + .use(reParse) + .use(plugin) + .use(remark2rehype, {allowDangerousHTML: true}) + .use(raw) + .use(stringify) + .processSync(text); + +test('simple citation', t => { + const {contents} = render('>This is a citation'); + t.is(contents, '
\n

This is a citation

\n
'); +}); + +test('simple citation raw', t => { + const {contents} = renderRaw('>This is a citation'); + t.is(contents, '
\n

This is a citation

\n
'); +}); + +test('question', t => { + const {contents} = renderRaw('>!question\nWhat does the 🦊 say ?'); + t.snapshot(contents); +}); -- cgit v1.2.3