From b307b0d3b539c4a88ac2504190a2d9267e20a882 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 5 Feb 2018 06:15:50 +0100 Subject: Add test with AVA --- __tests__/index.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 __tests__/index.js (limited to '__tests__/index.js') diff --git a/__tests__/index.js b/__tests__/index.js new file mode 100644 index 0000000..d9fc7fa --- /dev/null +++ b/__tests__/index.js @@ -0,0 +1,39 @@ +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