forked from rehypejs/rehype-minify
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
58 lines (52 loc) · 1.27 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import test from 'tape'
import {rehype} from 'rehype'
import {u} from 'unist-builder'
import {h} from 'hastscript'
import min from './index.js'
test('rehype-concat-javascript', (t) => {
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('script', 'alert(1)'), h('script', 'alert(2)')])),
u('root', [h('script', 'alert(1);alert(2)')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('script', 'alert(1);'), h('script', 'alert(2);')])),
u('root', [h('script', 'alert(1);;alert(2);')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(
u('root', [
h('script', 'alert(1)'),
h('script', {type: 'text/fooscript'}, 'alert(2)')
])
),
u('root', [
h('script', 'alert(1)'),
h('script', {type: 'text/fooscript'}, 'alert(2)')
])
)
t.deepEqual(
rehype()
.use(min)
.runSync(
u('root', [
h('script', 'alert(1)'),
h('script', {src: 'foo'}),
h('script', 'alert(2)')
])
),
u('root', [h('script', 'alert(1);alert(2)'), h('script', {src: 'foo'})])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('script', 'alert(1)')])),
u('root', [h('script', 'alert(1)')])
)
t.end()
})