From 9dd5edb18f8c23f3f43e253fb5c4c04ac98f173a Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 5 Feb 2018 22:21:49 +0100 Subject: add tests with AVA --- __tests__/index.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 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..b359cd9 --- /dev/null +++ b/__tests__/index.js @@ -0,0 +1,57 @@ +import {readFileSync as file} from 'fs'; +import {join} from 'path'; +import unified from 'unified'; + +import test from 'ava'; +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('line-input', t => { + const {contents} = render(file(join(__dirname, 'input-simple.md'))); + t.snapshot(contents); +}); + +test('line-input-simple', t => { + const {contents} = render('[__here__]'); + t.is(contents, '

'); +}); + +test('line-input-empty', t => { + const {contents} = render('[____]'); + t.is(contents, '

'); +}); + +test.todo('id text'); +test.todo('class'); +test.todo('classes'); +test.todo('key-value'); +test.todo('classes key-value id'); +test.todo('overwrite type'); +test.todo('overwrite placeholder'); +test.todo('overwrite class'); +test.todo('overwrite id'); +test.todo('multiple id'); + +test('line-input-raw', t => { + const {contents} = renderRaw(file(join(__dirname, 'input-raw.md'))); + t.snapshot(contents); +}); -- cgit v1.2.3-54-g00ecf