From 3007a24ec37aff2338ea5645ff33abff42ba6b7f Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 5 Feb 2018 22:39:25 +0100 Subject: add tests with AVA --- __tests__/__snapshots__/index.js.md | 18 +++++++++++ __tests__/__snapshots__/index.js.snap | Bin 0 -> 155 bytes __tests__/index.js | 59 ++++++++++++++++++++++++++++++++++ __tests__/text-raw.md | 8 +++++ __tests__/text.md | 6 ++++ 5 files changed, 91 insertions(+) create mode 100644 __tests__/__snapshots__/index.js.md create mode 100644 __tests__/__snapshots__/index.js.snap create mode 100644 __tests__/index.js create mode 100644 __tests__/text-raw.md create mode 100644 __tests__/text.md (limited to '__tests__') diff --git a/__tests__/__snapshots__/index.js.md b/__tests__/__snapshots__/index.js.md new file mode 100644 index 0000000..7c17a23 --- /dev/null +++ b/__tests__/__snapshots__/index.js.md @@ -0,0 +1,18 @@ +# Snapshot report for `__tests__/index.js` + +The actual snapshot is saved in `index.js.snap`. + +Generated by [AVA](https://ava.li). + +## text raw + +> Snapshot 1 + + `

This is a text :

␊ + ` + +## text simple + +> Snapshot 1 + + '

This is a text :

' diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap new file mode 100644 index 0000000..f072c32 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..27150a5 --- /dev/null +++ b/__tests__/index.js @@ -0,0 +1,59 @@ +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('text simple', t => { + const {contents} = render(file(join(__dirname, 'text.md'))); + t.snapshot(contents); +}); + +test('text raw', t => { + const {contents} = renderRaw(file(join(__dirname, 'text.md'))); + t.snapshot(contents); +}); + +test.todo('empty'); +test.todo('empty raw'); + +test.todo('simple'); +test.todo('simple raw'); + +test.todo('long'); +test.todo('long raw'); + +test.todo('id text'); +test.todo('class'); +test.todo('classes'); +test.todo('key-value'); +test.todo('classes key-value id'); +test.todo('overwrite class'); +test.todo('overwrite id'); +test.todo('multiple id'); + +test.todo('real1'); +test.todo('real2'); +test.todo('real3'); + diff --git a/__tests__/text-raw.md b/__tests__/text-raw.md new file mode 100644 index 0000000..21b5833 --- /dev/null +++ b/__tests__/text-raw.md @@ -0,0 +1,8 @@ +This is some text. + +[_____ +This is a textarea +_____] + + +And this is dangerous HTML 🐯 diff --git a/__tests__/text.md b/__tests__/text.md new file mode 100644 index 0000000..317346a --- /dev/null +++ b/__tests__/text.md @@ -0,0 +1,6 @@ + +This is a text : + +[_____ + +_____] -- cgit v1.2.3