Skip to content

Commit cfa4c80

Browse files
committed
Refactor code-style
1 parent 56c88e4 commit cfa4c80

File tree

1 file changed

+106
-100
lines changed

1 file changed

+106
-100
lines changed

test/footnote.js

Lines changed: 106 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,34 @@ import {toHast} from '../index.js'
1212

1313
test('footnote', async function (t) {
1414
await t.test('should render `footnote`s (#1)', async function () {
15-
const tree = toHast({
16-
type: 'root',
17-
children: [
18-
{
19-
type: 'footnoteDefinition',
20-
identifier: '1',
15+
assert.equal(
16+
toHtml(
17+
// @ts-expect-error: to do: remove when `to-html` is released.
18+
toHast({
19+
type: 'root',
2120
children: [
2221
{
23-
type: 'blockquote',
22+
type: 'footnoteDefinition',
23+
identifier: '1',
2424
children: [
25-
{type: 'paragraph', children: [{type: 'text', value: 'delta'}]}
25+
{
26+
type: 'blockquote',
27+
children: [
28+
{
29+
type: 'paragraph',
30+
children: [{type: 'text', value: 'delta'}]
31+
}
32+
]
33+
}
2634
]
35+
},
36+
{
37+
type: 'paragraph',
38+
children: [{type: 'footnoteReference', identifier: '1'}]
2739
}
2840
]
29-
},
30-
{
31-
type: 'paragraph',
32-
children: [{type: 'footnoteReference', identifier: '1'}]
33-
}
34-
]
35-
})
36-
assert(tree, 'expected node')
37-
assert.equal(
38-
// @ts-expect-error: to do: remove when `to-html` is released.
39-
toHtml(tree),
41+
})
42+
),
4043
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
4144
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
4245
<ol>
@@ -52,22 +55,22 @@ test('footnote', async function (t) {
5255
})
5356

5457
await t.test('should render footnotes in tables', async function () {
55-
const tree = toHast(
56-
fromMarkdown(
57-
`| Footnotes |
58+
assert.equal(
59+
toHtml(
60+
// @ts-expect-error: to do: remove when `to-html` is released.
61+
toHast(
62+
fromMarkdown(
63+
`| Footnotes |
5864
| ---- |
5965
| [^1] |
6066
| [^2] |
6167
6268
[^1]: a
6369
[^2]: b`,
64-
{extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()]}
65-
)
66-
)
67-
assert(tree, 'expected node')
68-
assert.equal(
69-
// @ts-expect-error: to do: remove when `to-html` is released.
70-
toHtml(tree),
70+
{extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()]}
71+
)
72+
)
73+
),
7174
`<table>
7275
<thead>
7376
<tr>
@@ -97,20 +100,20 @@ test('footnote', async function (t) {
97100
})
98101

99102
await t.test('should render footnotes in table cells', async function () {
100-
const tree = toHast(
101-
fromMarkdown(
102-
`| [^1] | [^2] |
103+
assert.equal(
104+
toHtml(
105+
// @ts-expect-error: to do: remove when `to-html` is released.
106+
toHast(
107+
fromMarkdown(
108+
`| [^1] | [^2] |
103109
| ---- | ---- |
104110
105111
[^1]: a
106112
[^2]: b`,
107-
{extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()]}
108-
)
109-
)
110-
assert(tree, 'expected node')
111-
assert.equal(
112-
// @ts-expect-error: to do: remove when `to-html` is released.
113-
toHtml(tree),
113+
{extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()]}
114+
)
115+
)
116+
),
114117
`<table>
115118
<thead>
116119
<tr>
@@ -135,16 +138,16 @@ test('footnote', async function (t) {
135138
await t.test(
136139
'should render reused and resursive footnotes',
137140
async function () {
138-
const tree = toHast(
139-
fromMarkdown('Call[^1][^1]\n\n[^1]: Recursion[^1][^1]', {
140-
extensions: [gfm()],
141-
mdastExtensions: [gfmFromMarkdown()]
142-
})
143-
)
144-
assert(tree, 'expected node')
145141
assert.equal(
146-
// @ts-expect-error: to do: remove when `to-html` is released.
147-
toHtml(tree),
142+
toHtml(
143+
// @ts-expect-error: to do: remove when `to-html` is released.
144+
toHast(
145+
fromMarkdown('Call[^1][^1]\n\n[^1]: Recursion[^1][^1]', {
146+
extensions: [gfm()],
147+
mdastExtensions: [gfmFromMarkdown()]
148+
})
149+
)
150+
),
148151
`<p>Call<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup><sup><a href="#user-content-fn-1" id="user-content-fnref-1-2" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
149152
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
150153
<ol>
@@ -160,17 +163,20 @@ test('footnote', async function (t) {
160163
await t.test(
161164
'should support `footnoteLabel`, `footnoteBackLabel`',
162165
async function () {
163-
const tree = toHast(
164-
fromMarkdown('[^1]\n[^1]: a', {
165-
extensions: [gfm()],
166-
mdastExtensions: [gfmFromMarkdown()]
167-
}),
168-
{footnoteLabel: 'Voetnoten', footnoteBackLabel: 'Terug naar de inhoud'}
169-
)
170-
assert(tree, 'expected node')
171166
assert.equal(
172-
// @ts-expect-error: to do: remove when `to-html` is released.
173-
toHtml(tree),
167+
toHtml(
168+
// @ts-expect-error: to do: remove when `to-html` is released.
169+
toHast(
170+
fromMarkdown('[^1]\n[^1]: a', {
171+
extensions: [gfm()],
172+
mdastExtensions: [gfmFromMarkdown()]
173+
}),
174+
{
175+
footnoteLabel: 'Voetnoten',
176+
footnoteBackLabel: 'Terug naar de inhoud'
177+
}
178+
)
179+
),
174180
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
175181
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Voetnoten</h2>
176182
<ol>
@@ -286,17 +292,17 @@ test('footnote', async function (t) {
286292
)
287293

288294
await t.test('should support an empty `clobberPrefix`', async function () {
289-
const tree = toHast(
290-
fromMarkdown('[^1]\n[^1]: a', {
291-
extensions: [gfm()],
292-
mdastExtensions: [gfmFromMarkdown()]
293-
}),
294-
{clobberPrefix: ''}
295-
)
296-
assert(tree, 'expected node')
297295
assert.equal(
298-
// @ts-expect-error: to do: remove when `to-html` is released.
299-
toHtml(tree),
296+
toHtml(
297+
// @ts-expect-error: to do: remove when `to-html` is released.
298+
toHast(
299+
fromMarkdown('[^1]\n[^1]: a', {
300+
extensions: [gfm()],
301+
mdastExtensions: [gfmFromMarkdown()]
302+
}),
303+
{clobberPrefix: ''}
304+
)
305+
),
300306
`<p><sup><a href="#fn-1" id="fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
301307
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
302308
<ol>
@@ -309,17 +315,17 @@ test('footnote', async function (t) {
309315
})
310316

311317
await t.test('should support a `footnoteLabelTagName`', async function () {
312-
const tree = toHast(
313-
fromMarkdown('[^1]\n[^1]: a', {
314-
extensions: [gfm()],
315-
mdastExtensions: [gfmFromMarkdown()]
316-
}),
317-
{footnoteLabelTagName: 'h1'}
318-
)
319-
assert(tree, 'expected node')
320318
assert.equal(
321-
// @ts-expect-error: to do: remove when `to-html` is released.
322-
toHtml(tree),
319+
toHtml(
320+
// @ts-expect-error: to do: remove when `to-html` is released.
321+
toHast(
322+
fromMarkdown('[^1]\n[^1]: a', {
323+
extensions: [gfm()],
324+
mdastExtensions: [gfmFromMarkdown()]
325+
}),
326+
{footnoteLabelTagName: 'h1'}
327+
)
328+
),
323329
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
324330
<section data-footnotes class="footnotes"><h1 class="sr-only" id="footnote-label">Footnotes</h1>
325331
<ol>
@@ -332,17 +338,17 @@ test('footnote', async function (t) {
332338
})
333339

334340
await t.test('should support a `footnoteLabelProperties`', async function () {
335-
const tree = toHast(
336-
fromMarkdown('[^1]\n[^1]: a', {
337-
extensions: [gfm()],
338-
mdastExtensions: [gfmFromMarkdown()]
339-
}),
340-
{footnoteLabelProperties: {}}
341-
)
342-
assert(tree, 'expected node')
343341
assert.equal(
344-
// @ts-expect-error: to do: remove when `to-html` is released.
345-
toHtml(tree),
342+
toHtml(
343+
// @ts-expect-error: to do: remove when `to-html` is released.
344+
toHast(
345+
fromMarkdown('[^1]\n[^1]: a', {
346+
extensions: [gfm()],
347+
mdastExtensions: [gfmFromMarkdown()]
348+
}),
349+
{footnoteLabelProperties: {}}
350+
)
351+
),
346352
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
347353
<section data-footnotes class="footnotes"><h2 id="footnote-label">Footnotes</h2>
348354
<ol>
@@ -355,19 +361,19 @@ test('footnote', async function (t) {
355361
})
356362

357363
await t.test('should support funky footnote identifiers', async function () {
358-
const tree = toHast(
359-
fromMarkdown(
360-
'a[^__proto__] b[^__proto__] c[^constructor]\n\n[^__proto__]: d\n[^constructor]: e',
361-
{
362-
extensions: [gfm()],
363-
mdastExtensions: [gfmFromMarkdown()]
364-
}
365-
)
366-
)
367-
assert(tree, 'expected node')
368364
assert.equal(
369-
// @ts-expect-error: to do: remove when `to-html` is released.
370-
toHtml(tree),
365+
toHtml(
366+
// @ts-expect-error: to do: remove when `to-html` is released.
367+
toHast(
368+
fromMarkdown(
369+
'a[^__proto__] b[^__proto__] c[^constructor]\n\n[^__proto__]: d\n[^constructor]: e',
370+
{
371+
extensions: [gfm()],
372+
mdastExtensions: [gfmFromMarkdown()]
373+
}
374+
)
375+
)
376+
),
371377
`<p>a<sup><a href="#user-content-fn-__proto__" id="user-content-fnref-__proto__" data-footnote-ref aria-describedby="footnote-label">1</a></sup> b<sup><a href="#user-content-fn-__proto__" id="user-content-fnref-__proto__-2" data-footnote-ref aria-describedby="footnote-label">1</a></sup> c<sup><a href="#user-content-fn-constructor" id="user-content-fnref-constructor" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
372378
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
373379
<ol>

0 commit comments

Comments
 (0)