-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
38 lines (31 loc) · 1.12 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict'
const rehypeParse = require('rehype-parse')
const rehypeResolution = require('./')
const rehypeStringify = require('rehype-stringify')
const unified = require('unified')
const { test } = require('tap')
function parse (html, cb) {
unified()
.use(rehypeParse, { fragment: true })
.use(rehypeResolution)
.use(rehypeStringify)
.process(html, cb)
}
test('the basics', t => {
const fixtures = [
['<img src="img/elva.jpg" alt="Dressed as a fairy">',
'<img src="img/elva.jpg" alt="Dressed as a fairy">'],
['<img src="img/[email protected]" alt="Dressed as a fairy">',
'<img src="img/[email protected]" alt="Dressed as a fairy" srcset="img/[email protected] 1x, img/[email protected] 2x, img/[email protected] 3x">'],
['<img src="img/[email protected]" srcset="img/[email protected] 1x, img/[email protected] 2x, img/[email protected] 3x">',
'<img src="img/[email protected]" srcset="img/[email protected] 1x, img/[email protected] 2x, img/[email protected] 3x">']
]
t.plan(fixtures.length)
fixtures.forEach(([src, wanted]) => {
parse(src, (er, found) => {
if (er) throw er
const { contents } = found
t.is(contents, wanted)
})
})
})