aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-02-05 22:38:18 +0100
committerache <ache@ache.one>2018-02-05 22:38:18 +0100
commit677bdafdeb541eb31502cd3419cf7e2f646fd860 (patch)
treeffe2a324cb845871f3258ed45b01557dfc0ead88
parentAdd a gitignore file (diff)
Add test with AVA
-rw-r--r--__tests__/__snapshots__/index.js.md29
-rw-r--r--__tests__/__snapshots__/index.js.snapbin0 -> 549 bytes
-rw-r--r--__tests__/index.js65
-rw-r--r--__tests__/mchoice-raw.md12
-rw-r--r--__tests__/mchoice.md8
-rw-r--r--package.json22
6 files changed, 129 insertions, 7 deletions
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
+
+ `<p>That is a multiple choice test :</p>␊
+ <fieldset class="mc check" id="mc_1"><ul style="list-style-type: none"><li style="list-style-type: none"><input type="checkbox" id="mc_1_0" class="!"><label for="mc_1_0"> The answer D␍
+ </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_1_1" class="="><label for="mc_1_1"> That doesn't work ␍
+ <em>at the moment</em></label></li><li style="list-style-type: none"><input type="checkbox" id="mc_1_2" class="!"><label for="mc_1_2"> It's still work !␍
+ </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_1_3"><label for="mc_1_3"> It will work␍
+ </label></li></ul><input onclick="check(&#x27;mc_1&#x27;,[0,1,0,0.5])" value="Validate" type="button"></fieldset>`
+
+## mchoide-raw
+
+> Snapshot 1
+
+ `<p>That is a multiple choice test :</p>␊
+ <fieldset class="mc check" id="mc_2"><ul style="list-style-type: none"><li style="list-style-type: none"><input type="checkbox" id="mc_2_0" class="!"><label for="mc_2_0"> The answer D␍
+ </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_2_1" class="="><label for="mc_2_1"> That doesn't work ␍
+ <em>at the moment</em></label></li><li style="list-style-type: none"><input type="checkbox" id="mc_2_2" class="!"><label for="mc_2_2"> It's still work !␍
+ </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_2_3"><label for="mc_2_3"> It will work␍
+ </label></li></ul><input onclick="check(&#x27;mc_2&#x27;,[0,1,0,0.5])" value="Validate" type="button"></fieldset>␊
+ <p><span>This is a HTML injected in a markdown file</span></p>␊
+ <div>The plugin should not modify the HTML injected part</div>`
diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap
new file mode 100644
index 0000000..0464d51
--- /dev/null
+++ b/__tests__/__snapshots__/index.js.snap
Binary files 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
+
+<span>This is a HTML injected in a markdown file</span>
+
+
+<div>The plugin should not modify the HTML injected part</div>
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
+
diff --git a/package.json b/package.json
index 82e4f0b..4f77902 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,11 @@
{
"name": "remark-multiple-choice",
"version": "0.1.0",
- "description": "A remark plugin for Markdown that parse list of answers to multiple choise",
+ "description": "A remark plugin for Markdown that parse list of answers to multiple choice",
"main": "app.js",
"scripts": {
+ "pretest": "xo",
+ "test": "ava",
"start": "node app.js"
},
"dependencies": {
@@ -14,16 +16,22 @@
"author": "ache",
"license": "MIT",
"keywords": [
- "mermaid",
- "graphs",
+ "multiple choice",
+ "test",
+ "answer",
"remark"
],
"devDependencies": {
+ "ava": "^0.25.0",
+ "rehype-raw": "^2.0.0",
+ "rehype-stringify": "^3.0.0",
+ "remark-parse": "^5.0.0",
+ "remark-rehype": "^3.0.0",
+ "unified": "^6.1.6",
"xo": "^0.18.2"
- }
- ,
- "xo" : {
- "space" : true,
+ },
+ "xo": {
+ "space": true,
"rules": {
"comma-dangle": [
"error",