Skip to content

Commit 96e5180

Browse files
committed
Refactor code-style
1 parent 3e5d047 commit 96e5180

File tree

2 files changed

+49
-47
lines changed

2 files changed

+49
-47
lines changed

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import {visit} from 'unist-util-visit'
2020
* Node type.
2121
* @param {Tree} tree
2222
* Tree to clean.
23-
* @param {Options | boolean | null | undefined} [options]
24-
* Configuration.
23+
* @param {Options | boolean | null | undefined} [options={force: false}]
24+
* Configuration (default: `{force: false}`).
2525
* @returns {Tree}
2626
* The given, modified, `tree`.
2727
*/
28-
// To do: next major: return `void`.
28+
// To do: next major: return `undefined`.
2929
// To do: remove `force` shortcut, replace with options.
3030
export function removePosition(tree, options) {
3131
const force =

test.js

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,57 @@ import test from 'node:test'
33
import {fromMarkdown} from 'mdast-util-from-markdown'
44
import {u} from 'unist-builder'
55
import {removePosition} from './index.js'
6-
import * as mod from './index.js'
76

8-
test('removePosition', () => {
9-
assert.deepEqual(
10-
Object.keys(mod).sort(),
11-
['removePosition'],
12-
'should expose the public api'
13-
)
7+
test('removePosition', 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+
'removePosition'
11+
])
12+
})
1413

15-
const empty = {position: undefined}
14+
await t.test('should work softly', async function () {
15+
const empty = {position: undefined}
1616

17-
assert.deepEqual(
18-
removePosition(fromMarkdown('Some **strong**, _emphasis_, and `code`.')),
19-
u('root', empty, [
20-
u('paragraph', empty, [
21-
u('text', empty, 'Some '),
22-
u('strong', empty, [u('text', empty, 'strong')]),
23-
u('text', empty, ', '),
24-
u('emphasis', empty, [u('text', empty, 'emphasis')]),
25-
u('text', empty, ', and '),
26-
u('inlineCode', empty, 'code'),
27-
u('text', empty, '.')
17+
assert.deepEqual(
18+
removePosition(fromMarkdown('Some **strong**, _emphasis_, and `code`.')),
19+
u('root', empty, [
20+
u('paragraph', empty, [
21+
u('text', empty, 'Some '),
22+
u('strong', empty, [u('text', empty, 'strong')]),
23+
u('text', empty, ', '),
24+
u('emphasis', empty, [u('text', empty, 'emphasis')]),
25+
u('text', empty, ', and '),
26+
u('inlineCode', empty, 'code'),
27+
u('text', empty, '.')
28+
])
2829
])
29-
]),
30-
'should work softly'
31-
)
30+
)
31+
})
3232

33-
assert.deepEqual(
34-
removePosition(
35-
fromMarkdown('Some **strong**, _emphasis_, and `code`.'),
36-
true
37-
),
38-
u('root', [
39-
u('paragraph', [
40-
u('text', 'Some '),
41-
u('strong', [u('text', 'strong')]),
42-
u('text', ', '),
43-
u('emphasis', [u('text', 'emphasis')]),
44-
u('text', ', and '),
45-
u('inlineCode', 'code'),
46-
u('text', '.')
33+
await t.test('should work by force', async function () {
34+
assert.deepEqual(
35+
removePosition(
36+
fromMarkdown('Some **strong**, _emphasis_, and `code`.'),
37+
true
38+
),
39+
u('root', [
40+
u('paragraph', [
41+
u('text', 'Some '),
42+
u('strong', [u('text', 'strong')]),
43+
u('text', ', '),
44+
u('emphasis', [u('text', 'emphasis')]),
45+
u('text', ', and '),
46+
u('inlineCode', 'code'),
47+
u('text', '.')
48+
])
4749
])
48-
]),
49-
'should work by force'
50-
)
50+
)
51+
})
5152

52-
assert.deepEqual(
53-
removePosition(fromMarkdown('x'), {force: true}),
54-
u('root', [u('paragraph', [u('text', 'x')])]),
55-
'should support options'
56-
)
53+
await t.test('should support options', async function () {
54+
assert.deepEqual(
55+
removePosition(fromMarkdown('x'), {force: true}),
56+
u('root', [u('paragraph', [u('text', 'x')])])
57+
)
58+
})
5759
})

0 commit comments

Comments
 (0)