From 677bdafdeb541eb31502cd3419cf7e2f646fd860 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 5 Feb 2018 22:38:18 +0100 Subject: Add test with AVA --- __tests__/__snapshots__/index.js.md | 29 +++++++++++++++ __tests__/__snapshots__/index.js.snap | Bin 0 -> 549 bytes __tests__/index.js | 65 ++++++++++++++++++++++++++++++++++ __tests__/mchoice-raw.md | 12 +++++++ __tests__/mchoice.md | 8 +++++ 5 files changed, 114 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__/mchoice-raw.md create mode 100644 __tests__/mchoice.md (limited to '__tests__') diff --git a/__tests__/__snapshots__/index.js.md b/__tests__/__snapshots__/index.js.md new file mode 100644 index 0000000..3063a53 --- /dev/null +++ b/__tests__/__snapshots__/index.js.md @@ -0,0 +1,29 @@ +# Snapshot report for `__tests__/index.js` + +The actual snapshot is saved in `index.js.snap`. + +Generated by [AVA](https://ava.li). + +## mchoide + +> Snapshot 1 + + `

That is a multiple choice test :

␊ +
` + +## mchoide-raw + +> Snapshot 1 + + `

That is a multiple choice test :

␊ +
␊ +

This is a HTML injected in a markdown file

␊ +
The plugin should not modify the HTML injected part
` diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap new file mode 100644 index 0000000..0464d51 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..df1e62f --- /dev/null +++ b/__tests__/index.js @@ -0,0 +1,65 @@ +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('simple', t => { + const {contents} = render(` + - [x] ! False + - [ ] ~ None + - [x] = True`); + t.is(contents, ''); +}); + +test('mchoide', t => { + const {contents} = render(file(join(__dirname, 'mchoice.md'))); + t.snapshot(contents); +}); + +test('mchoide-raw', t => { + const {contents} = renderRaw(file(join(__dirname, 'mchoice-raw.md'))); + t.snapshot(contents); +}); + +test.todo('all checked'); +test.todo('none checked'); +test.todo('caps checked'); +test.todo('enpty square brackets'); +test.todo('every kind of checked'); + +test.todo('Citation in a multiple-choice'); +test.todo('Feedback feature test'); + +test.todo('raw render'); + +test.todo('Error about check'); +test.todo('Error about list'); +test.todo('Error about space'); + +test.todo('with brackets for single choice'); + +test.todo('real test 1'); +test.todo('real test 2'); +test.todo('real test 3'); diff --git a/__tests__/mchoice-raw.md b/__tests__/mchoice-raw.md new file mode 100644 index 0000000..98d9718 --- /dev/null +++ b/__tests__/mchoice-raw.md @@ -0,0 +1,12 @@ + +That is a multiple choice test : + + - [ ] ! The answer D + - [ ] = That doesn't work *at the moment* + - [ ] ! It's still work ! + - [ ] ~ It will work + +This is a HTML injected in a markdown file + + +
The plugin should not modify the HTML injected part
diff --git a/__tests__/mchoice.md b/__tests__/mchoice.md new file mode 100644 index 0000000..8a4d65d --- /dev/null +++ b/__tests__/mchoice.md @@ -0,0 +1,8 @@ + +That is a multiple choice test : + + - [ ] ! The answer D + - [ ] = That doesn't work *at the moment* + - [ ] ! It's still work ! + - [ ] ~ It will work + -- cgit v1.2.3