Skip to content

Commit c768728

Browse files
committed
Refactor code-style
1 parent ce8f48f commit c768728

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const re = /[ \t\n\f\r]/g
1414
* @returns {boolean}
1515
* Whether the `value` is inter-element whitespace (`boolean`): consisting of
1616
* zero or more of space, tab (`\t`), line feed (`\n`), carriage return
17-
* (`\r`), or form feed (`\f`).
18-
* If a node is passed it must be a `Text` node, whose `value` field is
19-
* checked.
17+
* (`\r`), or form feed (`\f`); if a node is passed it must be a `Text` node,
18+
* whose `value` field is checked.
2019
*/
2120
export function whitespace(thing) {
2221
return typeof thing === 'object'

test.js

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
import assert from 'node:assert/strict'
22
import test from 'node:test'
33
import {whitespace} from './index.js'
4-
import * as mod from './index.js'
54

6-
test('whitespace', () => {
7-
assert.deepEqual(
8-
Object.keys(mod).sort(),
9-
['whitespace'],
10-
'should expose the public api'
11-
)
5+
test('whitespace', async function (t) {
6+
await t.test('should expose the public api', async function () {
7+
assert.deepEqual(Object.keys(await import('./index.js')).sort(), [
8+
'whitespace'
9+
])
10+
})
1211

13-
assert.equal(
14-
whitespace({type: 'comment', value: 'asd'}),
15-
false,
16-
'should return `false` without text'
17-
)
12+
await t.test('should return `false` without text', async function () {
13+
assert.equal(whitespace({type: 'comment', value: 'asd'}), false)
14+
})
1815

19-
assert.equal(
20-
whitespace({type: 'text', value: '\v'}),
21-
false,
22-
'should return `false` for other white-space'
16+
await t.test(
17+
'should return `false` for other white-space',
18+
async function () {
19+
assert.equal(whitespace({type: 'text', value: '\v'}), false)
20+
}
2321
)
2422

25-
assert.equal(
26-
whitespace({type: 'text', value: ' \t\r\n\f'}),
27-
true,
28-
'should return `true` for inter-element white-space'
23+
await t.test(
24+
'should return `true` for inter-element white-space',
25+
async function () {
26+
assert.equal(whitespace({type: 'text', value: ' \t\r\n\f'}), true)
27+
}
2928
)
3029

31-
assert.equal(
32-
whitespace(' \v'),
33-
false,
34-
'should return `false` for a `string` of text'
30+
await t.test(
31+
'should return `false` for a `string` of text',
32+
async function () {
33+
assert.equal(whitespace(' \v'), false)
34+
}
3535
)
3636

37-
assert.equal(
38-
whitespace(' \t\r\n\f'),
39-
true,
40-
'should return `true` for a `string` of inter-element white-space'
37+
await t.test(
38+
'should return `true` for a `string` of inter-element white-space',
39+
async function () {
40+
assert.equal(whitespace(' \t\r\n\f'), true)
41+
}
4142
)
4243
})

0 commit comments

Comments
 (0)