Skip to content

Commit f43da7a

Browse files
committed
Refactor code-style
1 parent 73e986b commit f43da7a

File tree

1 file changed

+69
-64
lines changed

1 file changed

+69
-64
lines changed

test/index.js

Lines changed: 69 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,85 @@
11
import assert from 'node:assert/strict'
2-
import {test} from 'node:test'
2+
import test from 'node:test'
33
import {fromHtmlIsomorphic} from 'hast-util-from-html-isomorphic'
44

5-
test('parse document', () => {
6-
const html = '<html><head></head><body></body></html>'
7-
const tree = fromHtmlIsomorphic(html)
5+
test('hast-util-from-html-isomorphic', async function (t) {
6+
await t.test('should parse a document', async function () {
7+
const html = '<html><head></head><body></body></html>'
8+
const tree = fromHtmlIsomorphic(html)
89

9-
assert.deepEqual(tree, {
10-
type: 'root',
11-
children: [
12-
{
13-
type: 'element',
14-
tagName: 'html',
15-
properties: {},
16-
children: [
17-
{
18-
type: 'element',
19-
tagName: 'head',
20-
properties: {},
21-
children: []
22-
},
23-
{
24-
type: 'element',
25-
tagName: 'body',
26-
properties: {},
27-
children: []
28-
}
29-
]
30-
}
31-
]
10+
assert.deepEqual(tree, {
11+
type: 'root',
12+
children: [
13+
{
14+
type: 'element',
15+
tagName: 'html',
16+
properties: {},
17+
children: [
18+
{
19+
type: 'element',
20+
tagName: 'head',
21+
properties: {},
22+
children: []
23+
},
24+
{
25+
type: 'element',
26+
tagName: 'body',
27+
properties: {},
28+
children: []
29+
}
30+
]
31+
}
32+
]
33+
})
34+
})
35+
36+
await t.test('should support `fragment: true`', async function () {
37+
const html = '<div><p></p></div>'
38+
const tree = fromHtmlIsomorphic(html, {fragment: true})
39+
40+
assert.deepEqual(tree, {
41+
type: 'root',
42+
children: [
43+
{
44+
type: 'element',
45+
tagName: 'div',
46+
properties: {},
47+
children: [
48+
{
49+
type: 'element',
50+
tagName: 'p',
51+
properties: {},
52+
children: []
53+
}
54+
]
55+
}
56+
]
57+
})
3258
})
33-
})
3459

35-
test('parse single element fragment', () => {
36-
const html = '<div><p></p></div>'
37-
const tree = fromHtmlIsomorphic(html, {fragment: true})
60+
await t.test(
61+
'should support `fragment: true` w/ multiple children',
62+
async function () {
63+
const html = '<p></p><div></div>'
64+
const tree = fromHtmlIsomorphic(html, {fragment: true})
3865

39-
assert.deepEqual(tree, {
40-
type: 'root',
41-
children: [
42-
{
43-
type: 'element',
44-
tagName: 'div',
45-
properties: {},
66+
assert.deepEqual(tree, {
67+
type: 'root',
4668
children: [
4769
{
4870
type: 'element',
4971
tagName: 'p',
72+
children: [],
73+
properties: {}
74+
},
75+
{
76+
type: 'element',
77+
tagName: 'div',
5078
properties: {},
5179
children: []
5280
}
5381
]
54-
}
55-
]
56-
})
57-
})
58-
59-
test('parse multi element fragment', () => {
60-
const html = '<p></p><div></div>'
61-
const tree = fromHtmlIsomorphic(html, {fragment: true})
62-
63-
assert.deepEqual(tree, {
64-
type: 'root',
65-
children: [
66-
{
67-
type: 'element',
68-
tagName: 'p',
69-
children: [],
70-
properties: {}
71-
},
72-
{
73-
type: 'element',
74-
tagName: 'div',
75-
properties: {},
76-
children: []
77-
}
78-
]
79-
})
82+
})
83+
}
84+
)
8085
})

0 commit comments

Comments
 (0)