aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-02-05 06:15:50 +0100
committerache <ache@ache.one>2018-02-05 22:17:26 +0100
commitb307b0d3b539c4a88ac2504190a2d9267e20a882 (patch)
tree1e4315f6d06540b1906869713812e51853fc1027
parent8e3b045ff1a30907be3170f4b0bb77cf25f52dd8 (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.js39
-rw-r--r--package.json12
4 files changed, 61 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..d9fc7fa
--- /dev/null
+++ b/__tests__/index.js
@@ -0,0 +1,39 @@
+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..1b31927 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": "xo",
+ "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",