forked from rehypejs/rehype-minify
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
70 lines (61 loc) · 1.53 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
59
60
61
62
63
64
65
66
67
68
69
70
import test from 'tape'
import {rehype} from 'rehype'
import {u} from 'unist-builder'
import {h} from 'hastscript'
import min from './index.js'
test('rehype-sort-attribute-values', (t) => {
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('#foo.qux.quux.bar.foo.baz', {itemProp: true})])),
u('root', [h('#foo.bar.baz.foo.quux.qux', {itemProp: true})])
)
// 3 x foo, 2 x bar, 1 x baz, 1 x qux, 1 x quux.
t.deepEqual(
rehype()
.use(min)
.runSync(
u('root', [
h('.foo', [h('.bar.foo'), h('.quux'), h('.qux.baz.bar.foo')])
])
),
u('root', [h('.foo', [h('.foo.bar'), h('.quux'), h('.foo.bar.baz.qux')])])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('.foobar', [h('.foo.foobar')])])),
u('root', [h('.foobar', [h('.foobar.foo')])])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('.foo.foo')])),
u('root', [h('.foo.foo')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('.foo.foob')])),
u('root', [h('.foo.foob')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('.foob.foo')])),
u('root', [h('.foo.foob')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [h('.foob.fooa')])),
u('root', [h('.fooa.foob')])
)
t.deepEqual(
rehype()
.use(min)
.runSync(u('root', [{type: 'element', tagName: 'div', children: []}])),
u('root', [{type: 'element', tagName: 'div', children: []}])
)
t.end()
})