aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-02-05 06:15:50 +0100
committerache <ache@ache.one>2018-02-05 06:15:50 +0100
commit72bda7d7e370d639d61caa68a20e6b80e467074a (patch)
treeca7732025cda372864b0ce2461bd17d7aaed4fb1
parentAdd a gitignore file (diff)
Add test with AVA
-rw-r--r--__tests__/__snapshots__/index.js.md12
-rw-r--r--__tests__/__snapshots__/index.js.snapbin0 -> 177 bytes
-rw-r--r--__tests__/index.js38
-rw-r--r--package.json12
4 files changed, 60 insertions, 2 deletions
diff --git a/__tests__/__snapshots__/index.js.md b/__tests__/__snapshots__/index.js.md
new file mode 100644
index 0000000..f8a1110
--- /dev/null
+++ b/__tests__/__snapshots__/index.js.md
@@ -0,0 +1,12 @@
+# Snapshot report for `__tests__/index.js`
+
+The actual snapshot is saved in `index.js.snap`.
+
+Generated by [AVA](https://ava.li).
+
+## question
+
+> Snapshot 1
+
+ `<div class="special-box question"><div class="special-box-content"><p>␊
+ What does the 🦊 say ?</p></div></div>`
diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap
new file mode 100644
index 0000000..8728a37
--- /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..5d4c995
--- /dev/null
+++ b/__tests__/index.js
@@ -0,0 +1,38 @@
+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);
+});
diff --git a/package.json b/package.json
index ae516fe..fcc484a 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,8 @@
"description": "A remark plugin for Markdown that parse special blox",
"main": "app.js",
"scripts": {
+ "pretest": "eslint .",
+ "test": "ava",
"start": "node app.js"
},
"dependencies": {
@@ -16,10 +18,16 @@
"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",