Skip to content

Commit

Permalink
Merge branch 'ysaskia-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Aug 19, 2022
2 parents e168c19 + 01c78b0 commit 696181e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@
"code",
"test"
]
},
{
"login": "ysaskia",
"name": "Yoann",
"avatar_url": "https://avatars.githubusercontent.com/u/1370679?v=4",
"profile": "https://github.com/ysaskia",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Thanks goes to these people ([emoji key][emojis]):
<td align="center"><a href="https://github.com/ronmerkin"><img src="https://avatars.githubusercontent.com/u/17492527?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ron Merkin</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ronmerkin" title="Code">💻</a></td>
<td align="center"><a href="http://www.benmccann.com"><img src="https://avatars.githubusercontent.com/u/322311?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben McCann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmccann" title="Tests">⚠️</a></td>
<td align="center"><a href="https://johnbowser.dev/"><img src="https://avatars.githubusercontent.com/u/66637570?v=4?s=100" width="100px;" alt=""/><br /><sub><b>John Bowser</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=jgbowser" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=jgbowser" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/ysaskia"><img src="https://avatars.githubusercontent.com/u/1370679?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yoann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ysaskia" title="Code">💻</a></td>
</tr>
</table>

Expand Down
28 changes: 15 additions & 13 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
// Definitions by: Rahim Alwer <https://github.com/mihar-22>

import {queries, Queries, BoundFunction, EventType} from '@testing-library/dom'
import { SvelteComponent } from 'svelte/types/runtime'
import { SvelteComponent, ComponentProps } from 'svelte/types/runtime'

export * from '@testing-library/dom'

type SvelteComponentOptions = any
type SvelteComponentOptions<C extends SvelteComponent> = ComponentProps<C> | {props: ComponentProps<C>}

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

type Constructor<T> = new (...args: any[]) => T;

/**
* Render a Component into the Document.
*/
export type RenderResult<Q extends Queries = typeof queries> = {
export type RenderResult<C extends SvelteComponent, Q extends Queries = typeof queries> = {
container: HTMLElement
component: SvelteComponent
component: C
debug: (el?: HTMLElement | DocumentFragment) => void
rerender: (options: SvelteComponentOptions) => void
rerender: (options: SvelteComponentOptions<C>) => void
unmount: () => void
} & { [P in keyof Q]: BoundFunction<Q[P]> }

Expand All @@ -27,17 +29,17 @@ export interface RenderOptions<Q extends Queries = typeof queries> {
queries?: Q
}

export function render(
component: typeof SvelteComponent,
componentOptions?: SvelteComponentOptions,
export function render<C extends SvelteComponent>(
component: C,
componentOptions?: SvelteComponentOptions<C>,
renderOptions?: Omit<RenderOptions, 'queries'>
): RenderResult
): RenderResult<C>

export function render<Q extends Queries>(
component: typeof SvelteComponent,
componentOptions?: SvelteComponentOptions,
export function render<C extends SvelteComponent, Q extends Queries>(
component: Constructor<C>,
componentOptions?: SvelteComponentOptions<C>,
renderOptions?: RenderOptions<Q>,
): RenderResult<Q>
): RenderResult<C, Q>

/**
* Unmounts trees that were mounted with render.
Expand Down

0 comments on commit 696181e

Please sign in to comment.