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