-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
25 lines (21 loc) · 806 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import assert from 'node:assert/strict'
import test from 'node:test'
import {h} from 'hastscript'
import {headingRank} from 'hast-util-heading-rank'
test('headingRank', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(
Object.keys(await import('hast-util-heading-rank')).sort(),
['headingRank']
)
})
await t.test('should return `undefined` for non-elements', async function () {
assert.equal(headingRank({type: 'text', value: '!'}), undefined)
})
await t.test('should return `undefined` for non-headings', async function () {
assert.equal(headingRank(h('p', '!')), undefined)
})
await t.test('should return the rank of a heading', async function () {
assert.equal(headingRank(h('h5', '!')), 5)
})
})