Skip to content

Commit f0b2dc2

Browse files
committed
test: use vi.defineHelper
1 parent b58b408 commit f0b2dc2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/aria.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
renderAriaTree,
1414
renderAriaTemplate,
1515
} from '../src/aria'
16-
import { describe, expect, test } from 'vitest'
16+
import { describe, expect, test, vi } from 'vitest'
1717
import * as yaml from 'yaml'
1818

1919
function parseAriaTemplate(text: string) {
@@ -36,14 +36,13 @@ function match(html: string, template: string) {
3636
}
3737
}
3838

39-
// TODO: use vi.defineHelper
40-
function runPipeline(
39+
const runPipeline = vi.defineHelper((
4140
htmlOrElement: string | Element,
4241
options?: {
4342
assertPass?: boolean
4443
assertAriaTemplateRoundTrip?: boolean
4544
}
46-
) {
45+
) => {
4746
const captured =
4847
typeof htmlOrElement === 'string'
4948
? capture(htmlOrElement)
@@ -52,11 +51,11 @@ function runPipeline(
5251
const parsed = parseAriaTemplate(rendered)
5352
const matched = matchAriaTree(captured, parsed)
5453
if (options?.assertPass !== false) {
55-
expect.soft(matched.pass).toBe(true)
54+
expect.soft(matched.pass, `roundtrip should match`).toBe(true)
5655
}
5756
if (options?.assertAriaTemplateRoundTrip !== false) {
5857
const renderedTemplate = renderAriaTemplate(parsed)
59-
expect.soft(renderedTemplate).toBe(rendered)
58+
expect.soft(renderedTemplate, `template roundtrip should match`).toBe(rendered)
6059
}
6160
return {
6261
captured,
@@ -69,7 +68,7 @@ function runPipeline(
6968
pass: matched.pass,
7069
},
7170
}
72-
}
71+
})
7372

7473
describe('basic', () => {
7574
test('heading', () => {

0 commit comments

Comments
 (0)