Skip to content

Commit 85ce03b

Browse files
committed
Refactor code-style
1 parent 696e6f5 commit 85ce03b

File tree

2 files changed

+46
-41
lines changed

2 files changed

+46
-41
lines changed

lib/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* @typedef {import('hast').Element} Element
3-
*/
4-
51
import {convertElement} from 'hast-util-is-element'
62

73
/**
@@ -18,7 +14,7 @@ import {convertElement} from 'hast-util-is-element'
1814
export const embedded = convertElement(
1915
/**
2016
* @param element
21-
* @returns {element is Element & {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}}
17+
* @returns {element is {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}}
2218
*/
2319
function (element) {
2420
return (

test.js

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,58 @@ import test from 'node:test'
33
import {embedded} from './index.js'
44
import * as mod from './index.js'
55

6-
test('embedded', () => {
7-
assert.deepEqual(
8-
Object.keys(mod).sort(),
9-
['embedded'],
10-
'should expose the public api'
11-
)
6+
test('embedded', async function (t) {
7+
await t.test('should expose the public api', async function () {
8+
assert.deepEqual(Object.keys(mod).sort(), ['embedded'])
9+
})
1210

13-
// @ts-expect-error: check how a missing node is handled.
14-
assert.equal(embedded(), false, 'should return `false` without node')
11+
await t.test('should return `false` without node', async function () {
12+
// @ts-expect-error: check how a missing node is handled.
13+
assert.equal(embedded(), false)
14+
})
1515

16-
assert.equal(embedded(null), false, 'should return `false` with `null`')
16+
await t.test('should return `false` with `null`', async function () {
17+
assert.equal(embedded(null), false)
18+
})
1719

18-
assert.equal(
19-
embedded({type: 'text'}),
20-
false,
21-
'should return `false` when without `element`'
20+
await t.test(
21+
'should return `false` when without `element`',
22+
async function () {
23+
assert.equal(embedded({type: 'text'}), false)
24+
}
2225
)
2326

24-
assert.equal(
25-
embedded({type: 'element'}),
26-
false,
27-
'should return `false` when with invalid `element`'
27+
await t.test(
28+
'should return `false` when with invalid `element`',
29+
async function () {
30+
assert.equal(embedded({type: 'element'}), false)
31+
}
2832
)
2933

30-
assert.equal(
31-
embedded({
32-
type: 'element',
33-
tagName: 'a',
34-
properties: {href: '#alpha', title: 'Bravo'},
35-
children: [{type: 'text', value: 'Charlie'}]
36-
}),
37-
false,
38-
'should return `false` when without not embedded'
34+
await t.test(
35+
'should return `false` when without not embedded',
36+
async function () {
37+
assert.equal(
38+
embedded({
39+
type: 'element',
40+
tagName: 'a',
41+
properties: {href: '#alpha', title: 'Bravo'},
42+
children: [{type: 'text', value: 'Charlie'}]
43+
}),
44+
false
45+
)
46+
}
3947
)
4048

41-
assert.equal(
42-
embedded({
43-
type: 'element',
44-
tagName: 'audio',
45-
properties: {src: 'delta.ogg'},
46-
children: []
47-
}),
48-
true,
49-
'should return `true` when with embedded'
50-
)
49+
await t.test('should return `true` when with embedded', async function () {
50+
assert.equal(
51+
embedded({
52+
type: 'element',
53+
tagName: 'audio',
54+
properties: {src: 'delta.ogg'},
55+
children: []
56+
}),
57+
true
58+
)
59+
})
5160
})

0 commit comments

Comments
 (0)