2
2
// Project: https://github.com/testing-library/svelte-testing-library
3
3
// Definitions by: Rahim Alwer <https://github.com/mihar-22>
4
4
5
- import { BoundFunction , EventType , Queries , queries } from '@testing-library/dom'
6
- import { ComponentConstructorOptions , ComponentProps , SvelteComponent } from 'svelte'
5
+ import {
6
+ BoundFunction ,
7
+ EventType ,
8
+ Queries ,
9
+ queries ,
10
+ } from '@testing-library/dom'
11
+ import {
12
+ ComponentConstructorOptions ,
13
+ ComponentProps ,
14
+ SvelteComponent ,
15
+ } from 'svelte'
7
16
8
17
export * from '@testing-library/dom'
9
18
10
- type SvelteComponentOptions < C extends SvelteComponent > = ComponentProps < C > | Pick < ComponentConstructorOptions < ComponentProps < C > > , "anchor" | "props" | "hydrate" | "intro" | "context" >
19
+ type SvelteComponentOptions < C extends SvelteComponent > =
20
+ | ComponentProps < C >
21
+ | Pick <
22
+ ComponentConstructorOptions < ComponentProps < C > > ,
23
+ 'anchor' | 'props' | 'hydrate' | 'intro' | 'context'
24
+ >
11
25
12
26
type Omit < T , K extends keyof T > = Pick < T , Exclude < keyof T , K > >
13
27
14
- type Constructor < T > = new ( ...args : any [ ] ) => T ;
28
+ type Constructor < T > = new ( ...args : any [ ] ) => T
15
29
16
30
/**
17
31
* Render a Component into the Document.
18
32
*/
19
- export type RenderResult < C extends SvelteComponent , Q extends Queries = typeof queries > = {
33
+ export type RenderResult <
34
+ C extends SvelteComponent ,
35
+ Q extends Queries = typeof queries ,
36
+ > = {
20
37
container : HTMLElement
21
38
component : C
22
39
debug : ( el ?: HTMLElement | DocumentFragment ) => void
23
- rerender : ( options : SvelteComponentOptions < C > ) => void
40
+ rerender : ( props : ComponentProps < C > ) => Promise < void >
24
41
unmount : ( ) => void
25
42
} & { [ P in keyof Q ] : BoundFunction < Q [ P ] > }
26
43
@@ -38,7 +55,7 @@ export function render<C extends SvelteComponent>(
38
55
export function render < C extends SvelteComponent , Q extends Queries > (
39
56
component : Constructor < C > ,
40
57
componentOptions ?: SvelteComponentOptions < C > ,
41
- renderOptions ?: RenderOptions < Q > ,
58
+ renderOptions ?: RenderOptions < Q >
42
59
) : RenderResult < C , Q >
43
60
44
61
/**
@@ -50,13 +67,19 @@ export function cleanup(): void
50
67
* Fires DOM events on an element provided by @testing-library/dom. Since Svelte needs to flush
51
68
* pending state changes via `tick`, these methods have been override and now return a promise.
52
69
*/
53
- export type FireFunction = ( element : Document | Element | Window , event : Event ) => Promise < boolean > ;
70
+ export type FireFunction = (
71
+ element : Document | Element | Window ,
72
+ event : Event
73
+ ) => Promise < boolean >
54
74
55
75
export type FireObject = {
56
- [ K in EventType ] : ( element : Document | Element | Window , options ?: { } ) => Promise < boolean > ;
57
- } ;
76
+ [ K in EventType ] : (
77
+ element : Document | Element | Window ,
78
+ options ?: { }
79
+ ) => Promise < boolean >
80
+ }
58
81
59
- export const fireEvent : FireFunction & FireObject ;
82
+ export const fireEvent : FireFunction & FireObject
60
83
61
84
/**
62
85
* Calls a function and notifies Svelte to flush any pending state changes.
0 commit comments