From d7d9fe9ec6252bbbbf430cb95f8ea4d6ded1cc2a Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 23 May 2018 11:19:12 +0200 Subject: Add more tests --- __tests__/index.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to '__tests__') 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, '

'); }); @@ -104,3 +107,49 @@ test('line-input-password', t => { t.is(contents, '

'); }); +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'))); +}); + -- cgit v1.2.3