Skip to content

Commit a5ccabe

Browse files
committed
feat: update types for overridden getConfig and configure functions
1 parent 86a9b27 commit a5ccabe

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

types/index.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ import {
55
Queries,
66
BoundFunction,
77
prettyFormat,
8+
Config as ConfigDTL,
89
} from '@testing-library/dom'
910
import {Renderer} from 'react-dom'
1011
import {act as reactAct} from 'react-dom/test-utils'
1112

1213
export * from '@testing-library/dom'
1314

15+
export interface Config extends ConfigDTL {
16+
reactStrictMode: boolean
17+
}
18+
19+
export interface ConfigFn {
20+
(existingConfig: Config): Partial<Config>
21+
}
22+
23+
export function configure(configDelta: ConfigFn | Partial<Config>): void
24+
25+
export function getConfig(): Config
26+
1427
export type RenderResult<
1528
Q extends Queries = typeof queries,
1629
Container extends Element | DocumentFragment = HTMLElement,

types/test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ export function testFireEvent() {
6262
fireEvent.click(container)
6363
}
6464

65+
export function testConfigure() {
66+
// test for DTL's config
67+
pure.configure({testIdAttribute: 'foobar'})
68+
pure.configure(existingConfig => ({
69+
testIdAttribute: `modified-${existingConfig.testIdAttribute}`,
70+
}))
71+
72+
// test for RTL's config
73+
pure.configure({reactStrictMode: true})
74+
pure.configure(existingConfig => ({
75+
reactStrictMode: !existingConfig.reactStrictMode,
76+
}))
77+
}
78+
79+
export function testGetConfig() {
80+
// test for DTL's config
81+
pure.getConfig().testIdAttribute
82+
83+
// test for RTL's config
84+
pure.getConfig().reactStrictMode
85+
}
86+
6587
export function testDebug() {
6688
const {debug, getAllByTestId} = render(
6789
<>

0 commit comments

Comments
 (0)