-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtest.js
38 lines (36 loc) · 1.19 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {rehype} from 'rehype'
import min from 'rehype-sort-attributes'
test('rehype-sort-attributes', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(
Object.keys(await import('rehype-sort-attributes')).sort(),
['default']
)
})
await t.test('should work', async function () {
assert.equal(
rehype()
.use(min)
.data('settings', {fragment: true})
.processSync(
[
'<a id="alpha" class="bravo" href="#charlie"></a>',
'<a class="delta echo" href="#foxtrot"></a>',
'<a hidden class="golf" href="#hotel"></a>',
'<a title="india" hidden href="#juliett"></a>',
'<img srcset="kilo.jpg" src="lima.jpg"></a>'
].join('\n')
)
.toString(),
[
'<a href="#charlie" class="bravo" id="alpha"></a>',
'<a href="#foxtrot" class="delta echo"></a>',
'<a href="#hotel" class="golf" hidden></a>',
'<a href="#juliett" hidden title="india"></a>',
'<img src="lima.jpg" srcset="kilo.jpg">'
].join('\n')
)
})
})