Skip to content

Commit 245f873

Browse files
committed
Fixup with some renames.
1 parent 85831d4 commit 245f873

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

tests/corpus-fixture.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,27 @@ export const describe = baseDescribe
4040
// Re-export expect from vitest
4141
export { expect }
4242

43+
// Fluent interface for any corpus type (HAR or HTML)
44+
export function withCorpus(corpusKey: keyof typeof CORPUS) {
45+
return {
46+
it: (name: string, fn: () => void | Promise<void>) => {
47+
return baseTest(`${String(corpusKey)}:${name}`, async () => {
48+
// Setup DOM for any corpus type (delegates to HAR or HTML based on type)
49+
await setupDOM(corpusKey)
50+
51+
try {
52+
return await fn()
53+
} finally {
54+
// Cleanup after test
55+
cleanupDOM()
56+
}
57+
})
58+
},
59+
}
60+
}
61+
4362
// Helper function for detection tests
44-
export function getDetectionResults() {
63+
export function detectedSpots() {
4564
const enhancers = new EnhancerRegistry()
4665
const textareas = document.querySelectorAll('textarea')
4766
const location: StrippedLocation = {
@@ -61,7 +80,7 @@ export function getDetectionResults() {
6180
}
6281

6382
// Helper function for UI tests
64-
export function getUIResults() {
83+
export function tableUI() {
6584
const enhancers = new EnhancerRegistry()
6685
const textareas = document.querySelectorAll('textarea')
6786
const location: StrippedLocation = {
@@ -88,22 +107,3 @@ export function getUIResults() {
88107
}
89108
return uiResults
90109
}
91-
92-
// Fluent interface for any corpus type (HAR or HTML)
93-
export function withCorpus(corpusKey: keyof typeof CORPUS) {
94-
return {
95-
it: (name: string, fn: () => void | Promise<void>) => {
96-
return baseTest(`${String(corpusKey)}:${name}`, async () => {
97-
// Setup DOM for any corpus type (delegates to HAR or HTML based on type)
98-
await setupDOM(corpusKey)
99-
100-
try {
101-
return await fn()
102-
} finally {
103-
// Cleanup after test
104-
cleanupDOM()
105-
}
106-
})
107-
},
108-
}
109-
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { CORPUS } from '../../corpus/_corpus-index'
2-
import { describe, expect, getDetectionResults, withCorpus } from '../../corpus-fixture'
2+
import { describe, detectedSpots, expect, withCorpus } from '../../corpus-fixture'
33

44
// Get all corpus entries that start with 'gh_'
5-
const githubCorpusEntries = Object.keys(CORPUS).filter((key) => key.startsWith('gh_'))
5+
const githubCorpusEntries = (Object.keys(CORPUS) as Array<keyof typeof CORPUS>).filter((key) =>
6+
key.startsWith('gh_'),
7+
)
68

79
describe('github detection', () => {
810
for (const corpusKey of githubCorpusEntries) {
9-
withCorpus(corpusKey as keyof typeof CORPUS).it('should detect correct spots', async () => {
10-
expect(getDetectionResults()).toMatchSnapshot()
11+
withCorpus(corpusKey).it('should detect correct spots', async () => {
12+
expect(detectedSpots()).toMatchSnapshot()
1113
})
1214
}
1315
})

tests/lib/enhancers/gh_ui.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { describe, expect, getUIResults, withCorpus } from '../../corpus-fixture'
1+
import { describe, expect, tableUI, withCorpus } from '../../corpus-fixture'
22

33
expect
44

55
import { CORPUS } from '../../corpus/_corpus-index'
66

77
// Get all corpus entries that start with 'gh_'
8-
const githubCorpusEntries = Object.keys(CORPUS).filter((key) => key.startsWith('gh_'))
8+
const githubCorpusEntries = (Object.keys(CORPUS) as Array<keyof typeof CORPUS>).filter((key) =>
9+
key.startsWith('gh_'),
10+
)
911

1012
describe('github ui', () => {
1113
for (const corpusKey of githubCorpusEntries) {
12-
withCorpus(
13-
corpusKey as keyof typeof CORPUS,
14-
).it('should render correct UI elements', async () => {
15-
expect(getUIResults()).toMatchSnapshot()
14+
withCorpus(corpusKey).it('should render correct UI elements', async () => {
15+
expect(tableUI()).toMatchSnapshot()
1616
})
1717
}
1818
})

0 commit comments

Comments
 (0)