forked from rehypejs/rehype-minify
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
36 lines (32 loc) · 810 Bytes
/
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
import test from 'tape'
import {rehype} from 'rehype'
import {u} from 'unist-builder'
import {h} from 'hastscript'
import min from './index.js'
test('rehype-remove-external-script-content', (t) => {
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('script', 'alert(true)')])),
u('root', [h('script', 'alert(true)')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('script', {src: 'index.js'}, 'alert(true)')])),
u('root', [h('script', {src: 'index.js'})])
)
t.deepEqual(
rehype()
.use(min)
.runSync(
u('root', [
h('script', {type: 'fooscript', src: 'index.js'}, 'alert(true)')
])
),
u('root', [
h('script', {type: 'fooscript', src: 'index.js'}, 'alert(true)')
])
)
t.end()
})