3
3
// Definitions by: Rahim Alwer <https://github.com/mihar-22>
4
4
5
5
import { queries , Queries , BoundFunction , EventType } from '@testing-library/dom'
6
- import { SvelteComponent } from 'svelte/types/runtime'
6
+ import { SvelteComponentTyped } from 'svelte/types/runtime'
7
7
8
8
export * from '@testing-library/dom'
9
9
10
- type SvelteComponentOptions = any
10
+ export interface SvelteComponentOptions < P extends Record < string , any > = any > {
11
+ target ?: HTMLElement
12
+ anchor ?: string
13
+ props ?: P
14
+ context ?: any
15
+ hydrate ?: boolean
16
+ intro ?: boolean
17
+ }
11
18
12
19
type Omit < T , K extends keyof T > = Pick < T , Exclude < keyof T , K > >
13
20
@@ -16,7 +23,7 @@ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
16
23
*/
17
24
export type RenderResult < Q extends Queries = typeof queries > = {
18
25
container : Element
19
- component : SvelteComponent
26
+ component : SvelteComponentTyped
20
27
debug : ( el ?: Element | DocumentFragment ) => void
21
28
rerender : ( options : SvelteComponentOptions ) => void
22
29
unmount : ( ) => void
@@ -28,17 +35,27 @@ export interface RenderOptions<Q extends Queries = typeof queries> {
28
35
}
29
36
30
37
export function render (
31
- component : typeof SvelteComponent ,
38
+ component : SvelteComponentTyped ,
32
39
componentOptions ?: SvelteComponentOptions ,
33
40
renderOptions ?: Omit < RenderOptions , 'queries' >
34
41
) : RenderResult
35
42
36
43
export function render < Q extends Queries > (
37
- component : typeof SvelteComponent ,
44
+ component : SvelteComponentTyped ,
38
45
componentOptions ?: SvelteComponentOptions ,
39
46
renderOptions ?: RenderOptions < Q > ,
40
47
) : RenderResult < Q >
41
48
49
+ export function render <
50
+ P extends Record < string , any > = any ,
51
+ E extends Record < string , any > = any ,
52
+ S extends Record < string , any > = any
53
+ > (
54
+ component : SvelteComponentTyped < P , E , S > ,
55
+ componentOptions ?: SvelteComponentOptions < P > ,
56
+ renderOptions ?: Omit < RenderOptions , "queries" >
57
+ ) : RenderResult ;
58
+
42
59
/**
43
60
* Unmounts trees that were mounted with render.
44
61
*/
0 commit comments