aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-05-27 21:36:18 +0200
committerache <ache@ache.one>2018-05-27 21:36:18 +0200
commit4d45d80c792ead4d4d9206304b2515f07cc07a7d (patch)
tree76358a5b2aeba70a7d241ab14e1c4d000e740c2b
parentxo recommendations (diff)
Add more tests with parse5
-rw-r--r--__tests__/index.js59
-rw-r--r--__tests__/input-simple.md4
2 files changed, 24 insertions, 39 deletions
diff --git a/__tests__/index.js b/__tests__/index.js
index 7deab30..03176a2 100644
--- a/__tests__/index.js
+++ b/__tests__/index.js
@@ -1,5 +1,3 @@
-import {readFileSync as file} from 'fs';
-import {join} from 'path';
import unified from 'unified';
import test from 'ava';
@@ -28,128 +26,115 @@ const renderRaw = text => unified()
.use(stringify)
.processSync(text);
-test('line-input', t => {
- const {contents} = render(file(join(__dirname, 'input-simple.md')));
- t.snapshot(contents);
-});
+const parse = cont => parse5.parse(cont);
test('line-input-simple', t => {
const {contents} = render('[__here__]');
- t.is(contents, '<p><input type="text" placeholder="here"></p>');
+ t.deepEqual(parse(contents), parse('<p><input type="text" placeholder="here"></p>'));
});
test('line-input-empty', t => {
const {contents} = render('[____]');
- t.is(contents, '<p><input type="text"></p>');
+ t.deepEqual(parse(contents), parse('<p><input type="text"></p>'));
});
test('line-input-simple-raw', t => {
const {contents} = renderRaw('[__here__]');
- t.is(contents, '<p><input type="text" placeholder="here"></p>');
+ t.deepEqual(parse(contents), parse('<p><input type="text" placeholder="here"></p>'));
});
test('line-input-empty-raw', t => {
const {contents} = renderRaw('[____]');
- t.is(contents, '<p><input type="text"></p>');
+ t.deepEqual(parse(contents), parse('<p><input type="text"></p>'));
});
test('line-input-id', t => {
const {contents} = render('[__Some text__]{#unicorn}');
- t.is(contents, '<p><input id="unicorn" type="text" placeholder="Some text"></p>');
+ t.deepEqual(parse(contents), parse('<p><input id="unicorn" type="text" placeholder="Some text"></p>'));
});
test('line-input-class', t => {
const {contents} = render('[_______panda__]{.unicorn}');
- t.is(contents, '<p><input class="unicorn" type="text" placeholder="panda"></p>');
+ t.deepEqual(parse(contents), parse('<p><input class="unicorn" type="text" placeholder="panda"></p>'));
});
test('line-input-classes', t => {
const {contents} = render('[__strong unicorn__]{.unicorn .fox}');
- t.is(contents, '<p><input class="unicorn fox" type="text" placeholder="strong unicorn"></p>');
+ t.deepEqual(parse(contents), parse('<p><input class="unicorn fox" type="text" placeholder="strong unicorn"></p>'));
});
test('line-input-key-value', t => {
const {contents} = render('[__math exercice__]{unicorn="horse + horn"}');
- t.is(contents, '<p><input unicorn="horse + horn" type="text" placeholder="math exercice"></p>');
+ t.deepEqual(parse(contents), parse('<p><input unicorn="horse + horn" type="text" placeholder="math exercice"></p>'));
});
test('line-input-overwrite-type', t => {
const {contents} = render('[__Good answer__]{type=buttom}');
- t.is(contents, '<p><input type="text" placeholder="Good answer"></p>');
+ t.deepEqual(parse(contents), parse('<p><input type="text" placeholder="Good answer"></p>'));
});
test('line-input-overwrite-placeholder', t => {
const {contents} = render('[__Please not a bad answer__]{placeholder=\'not here\'}');
- t.is(contents, '<p><input placeholder="Please not a bad answer" type="text"></p>');
+ t.deepEqual(parse(contents), parse('<p><input placeholder="Please not a bad answer" type="text"></p>'));
});
test('line-input-overwrite-class', t => {
const {contents} = render('[__A result__]{class=\'unicorn\' .fox}');
- t.is(contents, '<p><input class="fox" type="text" placeholder="A result"></p>');
+ t.deepEqual(parse(contents), parse('<p><input class="fox" type="text" placeholder="A result"></p>'));
});
test('line-input-overwrite-id', t => {
const {contents} = render('[__email__]{id=unicorn #fox}');
- t.is(contents, '<p><input id="fox" type="text" placeholder="email"></p>');
+ t.deepEqual(parse(contents), parse('<p><input id="fox" type="text" placeholder="email"></p>'));
});
test('line-input-multi-id', t => {
const {contents} = render('[__Login__]{#unicorn #fox}');
- t.is(contents, '<p><input id="unicorn" type="text" placeholder="Login"></p>');
-});
-
-test('line-input-raw', t => {
- const {contents} = renderRaw(file(join(__dirname, 'input-raw.md')));
- t.snapshot(contents);
+ t.deepEqual(parse(contents), parse('<p><input id="unicorn" type="text" placeholder="Login"></p>'));
});
test('line-input-password', t => {
const {contents} = render('[__Password__]{#passwd type=password}');
- t.is(contents, '<p><input id="passwd" type="password" placeholder="Password"></p>');
+ t.deepEqual(parse(contents), parse('<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')));
+ 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')));
+ 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')));
+ 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')));
+ 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')));
+ 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')));
+ t.not(null, dom5.query(parse5.parse(contents), dom5.predicates.hasTagName('input')));
});
diff --git a/__tests__/input-simple.md b/__tests__/input-simple.md
index 4816cd8..005e724 100644
--- a/__tests__/input-simple.md
+++ b/__tests__/input-simple.md
@@ -2,5 +2,5 @@ This is a input line in a paragraph [___Type here___]. That's all forks.
This is a formulay :
-Login : [__Login__]
-Password : [__Password__]{type=password}
+Login : [__Login__]
+Password : [__Password__]{type=password}