1- import { describe , expect , withCorpus } from '../../corpus-fixture'
1+ import { describe , expect , getUIResults , withCorpus } from '../../corpus-fixture'
22
33expect
44
5- import type { StrippedLocation } from '@/lib/enhancer'
6- import { EnhancerRegistry } from '../../../src/lib/registries'
75import { CORPUS } from '../../corpus/_corpus-index'
86
9- const enhancers = new EnhancerRegistry ( )
10-
11- function getUIResults ( document : Document , window : Window ) {
12- const textareas = document . querySelectorAll ( 'textarea' )
13- const location : StrippedLocation = {
14- host : window . location . host ,
15- pathname : window . location . pathname ,
16- }
17- const uiResults = [ ]
18- for ( const textarea of textareas ) {
19- const enhanced = enhancers . tryToEnhance ( textarea , location )
20- const forValue = `id=${ textarea . id } name=${ textarea . name } className=${ textarea . className } `
21- if ( enhanced ) {
22- uiResults . push ( {
23- for : forValue ,
24- title : enhanced . enhancer . tableTitle ( enhanced . spot ) ,
25- upperDecoration : enhanced . enhancer . tableUpperDecoration ( enhanced . spot ) ,
26- } )
27- } else {
28- uiResults . push ( {
29- for : forValue ,
30- title : null ,
31- upperDecoration : null ,
32- } )
33- }
34- }
35- return uiResults
36- }
37-
387// Get all corpus entries that start with 'gh_'
398const githubCorpusEntries = Object . keys ( CORPUS ) . filter ( ( key ) => key . startsWith ( 'gh_' ) )
409
@@ -43,7 +12,7 @@ describe('github ui', () => {
4312 withCorpus (
4413 corpusKey as keyof typeof CORPUS ,
4514 ) . it ( 'should render correct UI elements' , async ( ) => {
46- expect ( getUIResults ( document , window ) ) . toMatchSnapshot ( )
15+ expect ( getUIResults ( ) ) . toMatchSnapshot ( )
4716 } )
4817 }
4918} )
0 commit comments