diff options
author | ache <ache@ache.one> | 2018-05-23 11:19:12 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2018-05-23 11:22:48 +0200 |
commit | d7d9fe9ec6252bbbbf430cb95f8ea4d6ded1cc2a (patch) | |
tree | 6c5915f1046836a95bf72a0786c388ba8c98b6ae /__tests__ | |
parent | Refactoring coherence (diff) |
Add more tests
Diffstat (limited to '__tests__')
-rw-r--r-- | __tests__/index.js | 51 |
1 files changed, 50 insertions, 1 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'))); +}); + |