Skip to content

Commit 5088642

Browse files
committed
Refactor code-style
1 parent 60c6802 commit 5088642

File tree

2 files changed

+50
-25
lines changed

2 files changed

+50
-25
lines changed

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* @typedef {import('hast').Nodes} Nodes
33
*/
44

5-
import {convertElement} from 'hast-util-is-element'
6-
import {hasProperty} from 'hast-util-has-property'
75
import {embedded} from 'hast-util-embedded'
6+
import {hasProperty} from 'hast-util-has-property'
87
import {isBodyOkLink} from 'hast-util-is-body-ok-link'
8+
import {convertElement} from 'hast-util-is-element'
99

1010
const basic = convertElement([
1111
'a',

test.js

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,53 @@
11
import assert from 'node:assert/strict'
22
import test from 'node:test'
3-
import {u} from 'unist-builder'
43
import {h} from 'hastscript'
4+
import {u} from 'unist-builder'
55
import {phrasing} from './index.js'
6-
import * as mod from './index.js'
7-
8-
test('phrasing()', () => {
9-
assert.deepEqual(
10-
Object.keys(mod).sort(),
11-
['phrasing'],
12-
'should expose the public api'
13-
)
14-
15-
assert.ok(!phrasing(h('div', 'Alpha')), 'flow')
16-
assert.ok(phrasing(h('meta', {itemProp: 'bravo'})), 'meta w/ itemProp')
17-
assert.ok(!phrasing(h('meta', {charSet: 'utf8'})), 'meta w/o itemProp')
18-
assert.ok(phrasing(u('text', 'charlie')), 'text')
19-
assert.ok(phrasing(u('text', '\n\t')), 'inter-element white-space')
20-
assert.ok(phrasing(h('a', {href: '/'}, 'Delta')), 'listed elements (a)')
21-
assert.ok(phrasing(h('b', {id: 'echo'}, 'Foxtrott')), 'listed elements (b)')
22-
assert.ok(phrasing(h('wbr')), 'listed elements (wbr)')
23-
assert.ok(phrasing(h('svg')), 'embedded content')
24-
assert.ok(
25-
phrasing(h('link', {rel: ['stylesheet'], href: 'index.css'})),
26-
'body-ok links'
27-
)
6+
7+
test('phrasing()', async function (t) {
8+
await t.test('should expose the public api', async function () {
9+
assert.deepEqual(Object.keys(await import('./index.js')).sort(), [
10+
'phrasing'
11+
])
12+
})
13+
14+
await t.test('should support flow', async function () {
15+
assert(!phrasing(h('div', 'Alpha')))
16+
})
17+
18+
await t.test('should support meta w/ itemProp', async function () {
19+
assert(phrasing(h('meta', {itemProp: 'bravo'})))
20+
})
21+
22+
await t.test('should support meta w/o itemProp', async function () {
23+
assert(!phrasing(h('meta', {charSet: 'utf8'})))
24+
})
25+
26+
await t.test('should support text', async function () {
27+
assert(phrasing(u('text', 'charlie')))
28+
})
29+
30+
await t.test('should support inter-element whitespace', async function () {
31+
assert(phrasing(u('text', '\n\t')))
32+
})
33+
34+
await t.test('should support listed elements (a)', async function () {
35+
assert(phrasing(h('a', {href: '/'}, 'Delta')))
36+
})
37+
38+
await t.test('should support listed elements (b)', async function () {
39+
assert(phrasing(h('b', {id: 'echo'}, 'Foxtrott')))
40+
})
41+
42+
await t.test('should support listed elements (wbr)', async function () {
43+
assert(phrasing(h('wbr')))
44+
})
45+
46+
await t.test('should support embedded content', async function () {
47+
assert(phrasing(h('svg')))
48+
})
49+
50+
await t.test('should support body-ok links', async function () {
51+
assert(phrasing(h('link', {rel: ['stylesheet'], href: 'index.css'})))
52+
})
2853
})

0 commit comments

Comments
 (0)