@testing-library/svelte 3.1.2 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -135,6 +135,7 @@ Thanks goes to these people ([emoji key][emojis]):
135
135
  <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>
136
136
  <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>
137
137
  <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>
138
+ <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>
138
139
  </tr>
139
140
  </table>
140
141
 
package/dist/pure.js CHANGED
@@ -41,7 +41,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
41
41
 
42
42
  const containerCache = new Map();
43
43
  const componentCache = new Set();
44
- const svelteComponentOptions = ['anchor', 'props', 'hydrate', 'intro', 'context'];
44
+ const svelteComponentOptions = ['accessors', 'anchor', 'props', 'hydrate', 'intro', 'context'];
45
45
 
46
46
  const render = (Component, _ref = {}, {
47
47
  container,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/svelte",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -3,59 +3,43 @@
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, ComponentProps } 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<C extends SvelteComponent> = ComponentProps<C> | {props: ComponentProps<C>}
18
11
 
19
12
  type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
20
13
 
14
+ type Constructor<T> = new (...args: any[]) => T;
15
+
21
16
  /**
22
17
  * Render a Component into the Document.
23
18
  */
24
- export type RenderResult<Q extends Queries = typeof queries> = {
25
- container: Element
26
- component: SvelteComponent
27
- component: SvelteComponentTyped
28
- debug: (el?: Element | DocumentFragment) => void
29
- rerender: (options: SvelteComponentOptions) => void
19
+ export type RenderResult<C extends SvelteComponent, Q extends Queries = typeof queries> = {
20
+ container: HTMLElement
21
+ component: C
22
+ debug: (el?: HTMLElement | DocumentFragment) => void
23
+ rerender: (options: SvelteComponentOptions<C>) => void
30
24
  unmount: () => void
31
25
  } & { [P in keyof Q]: BoundFunction<Q[P]> }
32
26
 
33
27
  export interface RenderOptions<Q extends Queries = typeof queries> {
34
- container?: Element
28
+ container?: HTMLElement
35
29
  queries?: Q
36
30
  }
37
31
 
38
- export function render(
39
- component: SvelteComponentTyped,
40
- componentOptions?: SvelteComponentOptions,
32
+ export function render<C extends SvelteComponent>(
33
+ component: Constructor<C>,
34
+ componentOptions?: SvelteComponentOptions<C>,
41
35
  renderOptions?: Omit<RenderOptions, 'queries'>
42
- ): RenderResult
36
+ ): RenderResult<C>
43
37
 
44
- export function render<Q extends Queries>(
45
- component: SvelteComponentTyped,
46
- componentOptions?: SvelteComponentOptions,
38
+ export function render<C extends SvelteComponent, Q extends Queries>(
39
+ component: Constructor<C>,
40
+ componentOptions?: SvelteComponentOptions<C>,
47
41
  renderOptions?: RenderOptions<Q>,
48
- ): RenderResult<Q>
49
-
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;
42
+ ): RenderResult<C, Q>
59
43
 
60
44
  /**
61
45
  * Unmounts trees that were mounted with render.