diff options
author | ache <ache@ache.one> | 2018-02-05 06:15:50 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2018-02-05 22:17:26 +0100 |
commit | b307b0d3b539c4a88ac2504190a2d9267e20a882 (patch) | |
tree | 1e4315f6d06540b1906869713812e51853fc1027 /__tests__/index.js | |
parent | Add a gitignore file (diff) |
Add test with AVA
Diffstat (limited to '__tests__/index.js')
-rw-r--r-- | __tests__/index.js | 39 |
1 files changed, 39 insertions, 0 deletions
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, '<blockquote>\n<p>This is a citation</p>\n</blockquote>'); +}); + +test('simple citation raw', t => { + const {contents} = renderRaw('>This is a citation'); + t.is(contents, '<blockquote>\n<p>This is a citation</p>\n</blockquote>'); +}); + +test('question', t => { + const {contents} = renderRaw('>!question\nWhat does the 🦊 say ?'); + t.snapshot(contents); +}); + |