aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-05-23 11:19:12 +0200
committerache <ache@ache.one>2018-05-23 11:22:48 +0200
commitd7d9fe9ec6252bbbbf430cb95f8ea4d6ded1cc2a (patch)
tree6c5915f1046836a95bf72a0786c388ba8c98b6ae
parentRefactoring coherence (diff)
Add more tests
-rw-r--r--__tests__/index.js51
-rw-r--r--package.json6
2 files changed, 54 insertions, 3 deletions
diff --git a/__tests__/index.js b/__tests__/index.js
index 498b393..7deab30 100644
--- a/__tests__/index.js
+++ b/__tests__/index.js
@@ -7,9 +7,12 @@ import raw from 'rehype-raw';
import reParse from 'remark-parse';
import stringify from 'rehype-stringify';
import remark2rehype from 'remark-rehype';
+import parse5 from 'parse5';
import plugin from '../app';
+const dom5 = require('dom5');
+
const render = text => unified()
.use(reParse)
.use(plugin)
@@ -55,7 +58,7 @@ test('line-input-id', t => {
});
test('line-input-class', t => {
- const {contents} = render('[__panda__]{.unicorn}');
+ const {contents} = render('[_______panda__]{.unicorn}');
t.is(contents, '<p><input class="unicorn" type="text" placeholder="panda"></p>');
});
@@ -104,3 +107,49 @@ test('line-input-password', t => {
t.is(contents, '<p><input id="passwd" type="password" placeholder="Password"></p>');
});
+test('not a line-input', t => {
+ const {contents} = renderRaw(`
+[_ text line_______]`);
+
+ t.is(null, dom5.query(parse5.parse(contents),
+ dom5.predicates.hasTagName('input')));
+});
+
+test('not a line-input 2', t => {
+ const {contents} = renderRaw(`
+[___]`);
+
+ t.is(null, dom5.query(parse5.parse(contents),
+ dom5.predicates.hasTagName('input')));
+});
+
+test('not a line-input 3', t => {
+ const {contents} = renderRaw(`
+[______ Not a line input
+_______] some text`);
+ t.is(null, dom5.query(parse5.parse(contents),
+ dom5.predicates.hasTagName('input')));
+});
+
+test('not a line-input 4', t => {
+ const {contents} = renderRaw(`
+[___ Not a line input ]`);
+
+ t.is(null, dom5.query(parse5.parse(contents),
+ dom5.predicates.hasTagName('input')));
+});
+
+test('is a line-input', t => {
+ const {contents} = renderRaw(`a[___This is a text___]qsd`);
+
+ t.not(null, dom5.query(parse5.parse(contents),
+ dom5.predicates.hasTagName('input')));
+});
+test('is line-input 2', t => {
+ const {contents} = renderRaw(`
+[____]`);
+
+ t.not(null, dom5.query(parse5.parse(contents),
+ dom5.predicates.hasTagName('input')));
+});
+
diff --git a/package.json b/package.json
index 1ab002f..7199794 100644
--- a/package.json
+++ b/package.json
@@ -9,8 +9,8 @@
"start": "node app.js"
},
"dependencies": {
- "unist-util-visit": "^1.1.3",
- "md-attr-parser": "^1.0.0"
+ "md-attr-parser": "^1.0.0",
+ "unist-util-visit": "^1.1.3"
},
"author": "ache",
"license": "MIT",
@@ -21,6 +21,8 @@
],
"devDependencies": {
"ava": "^0.25.0",
+ "dom5": "^3.0.0",
+ "parse5": "^4.0.0",
"rehype-raw": "^2.0.0",
"rehype-stringify": "^3.0.0",
"remark-parse": "^5.0.0",