aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-02-05 22:21:49 +0100
committerache <ache@ache.one>2018-02-05 22:21:49 +0100
commit9dd5edb18f8c23f3f43e253fb5c4c04ac98f173a (patch)
tree6ad1f34037e2c93766be26c5ebf913fe25e1ecf3 /__tests__
parentAdd a gitignore file (diff)
add tests with AVA
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/__snapshots__/index.js.md28
-rw-r--r--__tests__/__snapshots__/index.js.snapbin0 -> 353 bytes
-rw-r--r--__tests__/index.js57
-rw-r--r--__tests__/input-raw.md13
-rw-r--r--__tests__/input-simple.md6
5 files changed, 104 insertions, 0 deletions
diff --git a/__tests__/__snapshots__/index.js.md b/__tests__/__snapshots__/index.js.md
new file mode 100644
index 0000000..9c20d55
--- /dev/null
+++ b/__tests__/__snapshots__/index.js.md
@@ -0,0 +1,28 @@
+# Snapshot report for `__tests__/index.js`
+
+The actual snapshot is saved in `index.js.snap`.
+
+Generated by [AVA](https://ava.li).
+
+## line-input-raw
+
+> Snapshot 1
+
+ `<p>This is a input line in a paragraph <input type="text" placeholder="Type here">. That's all forks.</p>␊
+ <p>This is a formulay :</p>␊
+ <p>Login : <input type="text" placeholder="Login">␊
+ Password : <input type="password" placeholder="Password"></p>␊
+ <div>␊
+ Dangerous HTML 🐯 !␊
+ </div>␊
+ <p>Your email : <input id="email" type="text" placeholder="email">␊
+ Verification : <input id="verif" type="text" placeholder="verif"></p>
+
+## line-input
+
+> Snapshot 1
+
+ `<p>This is a input line in a paragraph <input type="text" placeholder="Type here">. That's all forks.</p>␊
+ <p>This is a formulay :</p>␊
+ <p>Login : <input type="text" placeholder="Login">␊
+ Password : <input type="password" placeholder="Password"></p>` \ No newline at end of file
diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap
new file mode 100644
index 0000000..dd28871
--- /dev/null
+++ b/__tests__/__snapshots__/index.js.snap
Binary files differ
diff --git a/__tests__/index.js b/__tests__/index.js
new file mode 100644
index 0000000..b359cd9
--- /dev/null
+++ b/__tests__/index.js
@@ -0,0 +1,57 @@
+import {readFileSync as file} from 'fs';
+import {join} from 'path';
+import unified from 'unified';
+
+import test from 'ava';
+import raw from 'rehype-raw';
+import reParse from 'remark-parse';
+import stringify from 'rehype-stringify';
+import remark2rehype from 'remark-rehype';
+
+import plugin from '../app';
+
+const render = text => unified()
+ .use(reParse)
+ .use(plugin)
+ .use(remark2rehype)
+ .use(stringify)
+ .processSync(text);
+
+const renderRaw = text => unified()
+ .use(reParse)
+ .use(plugin)
+ .use(remark2rehype, {allowDangerousHTML: true})
+ .use(raw)
+ .use(stringify)
+ .processSync(text);
+
+test('line-input', t => {
+ const {contents} = render(file(join(__dirname, 'input-simple.md')));
+ t.snapshot(contents);
+});
+
+test('line-input-simple', t => {
+ const {contents} = render('[__here__]');
+ t.is(contents, '<p><input type="text" placeholder="here"></p>');
+});
+
+test('line-input-empty', t => {
+ const {contents} = render('[____]');
+ t.is(contents, '<p><input type="text"></p>');
+});
+
+test.todo('id text');
+test.todo('class');
+test.todo('classes');
+test.todo('key-value');
+test.todo('classes key-value id');
+test.todo('overwrite type');
+test.todo('overwrite placeholder');
+test.todo('overwrite class');
+test.todo('overwrite id');
+test.todo('multiple id');
+
+test('line-input-raw', t => {
+ const {contents} = renderRaw(file(join(__dirname, 'input-raw.md')));
+ t.snapshot(contents);
+});
diff --git a/__tests__/input-raw.md b/__tests__/input-raw.md
new file mode 100644
index 0000000..e7922da
--- /dev/null
+++ b/__tests__/input-raw.md
@@ -0,0 +1,13 @@
+This is a input line in a paragraph [___Type here___]. That's all forks.
+
+This is a formulay :
+
+Login : [__Login__]
+Password : [__Password__]{type=password}
+
+<div>
+Dangerous HTML 🐯 !
+</div>
+
+Your email : [__email__]{#email}
+Verification : [__verif__]{#verif}
diff --git a/__tests__/input-simple.md b/__tests__/input-simple.md
new file mode 100644
index 0000000..4816cd8
--- /dev/null
+++ b/__tests__/input-simple.md
@@ -0,0 +1,6 @@
+This is a input line in a paragraph [___Type here___]. That's all forks.
+
+This is a formulay :
+
+Login : [__Login__]
+Password : [__Password__]{type=password}