aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-05-18 04:44:26 +0200
committerache <ache@ache.one>2018-05-18 04:44:26 +0200
commit9afd1788992caa72523fa3e84c3a421a843ebc71 (patch)
tree4917e838cde53328af10e26e5a2cea2d338796f6 /__tests__
parentAdd tests with ava (diff)
Tests with README
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/index.js42
1 files changed, 39 insertions, 3 deletions
diff --git a/__tests__/index.js b/__tests__/index.js
index 6a09cf9..3c86fea 100644
--- a/__tests__/index.js
+++ b/__tests__/index.js
@@ -1,5 +1,6 @@
+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';
@@ -14,14 +15,14 @@ const Stream = stream.Readable;
const render = text => unified()
.use(reParse)
- .use(plugin)
+ .use(plugin, {allowDangerousDOMEventHandlers: false, scope: 'permissive'})
.use(remark2rehype)
.use(stringify)
.processSync(text);
const renderRaw = text => unified()
.use(reParse)
- .use(plugin)
+ .use(plugin, {allowDangerousDOMEventHandlers: true, scope: 'permissive'})
.use(remark2rehype, {allowDangerousHTML: true})
.use(raw)
.use(stringify)
@@ -99,3 +100,38 @@ test('em', async t => {
await string2stream(contents).pipe(parser);
});
+test('readme', async t => {
+ const fileExample = file(join(__dirname, 'readMeTest.txt'));
+ const {contents} = render(fileExample);
+ const parser = new parse5.SAXParser();
+
+ parser.on('startTag', (name, attrs) => {
+ switch (name) {
+ case 'img':
+ t.true(propEgal({height: 50, alt: 'alt', src: 'img'}, attrs));
+ break;
+ case 'a':
+ t.true(propEgal({ref: 'external', src: 'https://rms.sexy'}, attrs));
+ break;
+ case 'h3':
+ t.true(propEgal({style: 'color:red;'}, attrs));
+ break;
+ case 'em':
+ t.true(propEgal({style: 'color:yellow;'}, attrs));
+ break;
+ case 'strong':
+ t.true(propEgal({awesome: ''}, attrs));
+ break;
+ case 'del':
+ t.true(propEgal({style: 'color: grey;'}, attrs));
+ break;
+ case 'code':
+ t.true(propEgal({lang: 'c'}, attrs));
+ break;
+ default:
+ }
+ });
+
+ await string2stream(contents).pipe(parser);
+});
+