diff options
Diffstat (limited to '__tests__/index.js')
-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'))); +}); + |