@testing-library/svelte 5.2.5 → 5.2.6
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/package.json +5 -2
- package/src/component-types.d.ts +28 -16
- package/types/component-types.d.ts +28 -16
- package/types/pure.d.ts +3 -3
- package/types/pure.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/svelte",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.6",
|
|
4
4
|
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -75,7 +75,10 @@
|
|
|
75
75
|
"build": "tsc -p tsconfig.build.json && cp src/component-types.d.ts types",
|
|
76
76
|
"contributors:add": "all-contributors add",
|
|
77
77
|
"contributors:generate": "all-contributors generate",
|
|
78
|
-
"preview-release": "./scripts/preview-release"
|
|
78
|
+
"preview-release": "./scripts/preview-release",
|
|
79
|
+
"install:3": "./scripts/install-dependencies 3",
|
|
80
|
+
"install:4": "./scripts/install-dependencies 4",
|
|
81
|
+
"install:5": "./scripts/install-dependencies 5"
|
|
79
82
|
},
|
|
80
83
|
"peerDependencies": {
|
|
81
84
|
"svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0",
|
package/src/component-types.d.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
import type
|
|
2
|
+
import type {
|
|
3
|
+
Component as ModernComponent,
|
|
4
|
+
ComponentConstructorOptions as LegacyConstructorOptions,
|
|
5
|
+
ComponentProps,
|
|
6
|
+
EventDispatcher,
|
|
7
|
+
mount,
|
|
8
|
+
SvelteComponent as LegacyComponent,
|
|
9
|
+
SvelteComponentTyped as Svelte3LegacyComponent,
|
|
10
|
+
} from 'svelte'
|
|
3
11
|
|
|
4
|
-
type IS_MODERN_SVELTE =
|
|
12
|
+
type IS_MODERN_SVELTE = ModernComponent extends (...args: any[]) => any
|
|
5
13
|
? true
|
|
6
14
|
: false
|
|
7
15
|
|
|
16
|
+
type IS_LEGACY_SVELTE_4 =
|
|
17
|
+
EventDispatcher<any> extends (...args: any[]) => any ? true : false
|
|
18
|
+
|
|
8
19
|
/** A compiled, imported Svelte component. */
|
|
9
20
|
export type Component<
|
|
10
|
-
P extends Record<string, any
|
|
11
|
-
E extends Record<string, any
|
|
21
|
+
P extends Record<string, any> = any,
|
|
22
|
+
E extends Record<string, any> = any,
|
|
12
23
|
> = IS_MODERN_SVELTE extends true
|
|
13
|
-
?
|
|
14
|
-
:
|
|
24
|
+
? ModernComponent<P, E> | LegacyComponent<P>
|
|
25
|
+
: IS_LEGACY_SVELTE_4 extends true
|
|
26
|
+
? LegacyComponent<P>
|
|
27
|
+
: Svelte3LegacyComponent<P>
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* The type of an imported, compiled Svelte component.
|
|
@@ -19,12 +32,12 @@ export type Component<
|
|
|
19
32
|
* In Svelte 5, this distinction no longer matters.
|
|
20
33
|
* In Svelte 4, this is the Svelte component class constructor.
|
|
21
34
|
*/
|
|
22
|
-
export type ComponentType<C> =
|
|
23
|
-
? C
|
|
24
|
-
:
|
|
35
|
+
export type ComponentType<C> = C extends LegacyComponent
|
|
36
|
+
? new (...args: any[]) => C
|
|
37
|
+
: C
|
|
25
38
|
|
|
26
39
|
/** The props of a component. */
|
|
27
|
-
export type Props<C extends Component
|
|
40
|
+
export type Props<C extends Component> = ComponentProps<C>
|
|
28
41
|
|
|
29
42
|
/**
|
|
30
43
|
* The exported fields of a component.
|
|
@@ -32,9 +45,9 @@ export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
|
|
|
32
45
|
* In Svelte 5, this is the set of variables marked as `export`'d.
|
|
33
46
|
* In Svelte 4, this is simply the instance of the component class.
|
|
34
47
|
*/
|
|
35
|
-
export type Exports<C> = C extends
|
|
48
|
+
export type Exports<C> = C extends LegacyComponent
|
|
36
49
|
? C
|
|
37
|
-
: C extends
|
|
50
|
+
: C extends ModernComponent<any, infer E>
|
|
38
51
|
? E
|
|
39
52
|
: never
|
|
40
53
|
|
|
@@ -43,7 +56,6 @@ export type Exports<C> = C extends Svelte.SvelteComponent
|
|
|
43
56
|
*
|
|
44
57
|
* In Svelte 4, these are the options passed to the component constructor.
|
|
45
58
|
*/
|
|
46
|
-
export type MountOptions<C extends Component
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: Svelte.ComponentConstructorOptions<Props<C>>
|
|
59
|
+
export type MountOptions<C extends Component> = C extends LegacyComponent
|
|
60
|
+
? LegacyConstructorOptions<Props<C>>
|
|
61
|
+
: Parameters<typeof mount<Props<C>, Exports<C>>>[1]
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
import type
|
|
2
|
+
import type {
|
|
3
|
+
Component as ModernComponent,
|
|
4
|
+
ComponentConstructorOptions as LegacyConstructorOptions,
|
|
5
|
+
ComponentProps,
|
|
6
|
+
EventDispatcher,
|
|
7
|
+
mount,
|
|
8
|
+
SvelteComponent as LegacyComponent,
|
|
9
|
+
SvelteComponentTyped as Svelte3LegacyComponent,
|
|
10
|
+
} from 'svelte'
|
|
3
11
|
|
|
4
|
-
type IS_MODERN_SVELTE =
|
|
12
|
+
type IS_MODERN_SVELTE = ModernComponent extends (...args: any[]) => any
|
|
5
13
|
? true
|
|
6
14
|
: false
|
|
7
15
|
|
|
16
|
+
type IS_LEGACY_SVELTE_4 =
|
|
17
|
+
EventDispatcher<any> extends (...args: any[]) => any ? true : false
|
|
18
|
+
|
|
8
19
|
/** A compiled, imported Svelte component. */
|
|
9
20
|
export type Component<
|
|
10
|
-
P extends Record<string, any
|
|
11
|
-
E extends Record<string, any
|
|
21
|
+
P extends Record<string, any> = any,
|
|
22
|
+
E extends Record<string, any> = any,
|
|
12
23
|
> = IS_MODERN_SVELTE extends true
|
|
13
|
-
?
|
|
14
|
-
:
|
|
24
|
+
? ModernComponent<P, E> | LegacyComponent<P>
|
|
25
|
+
: IS_LEGACY_SVELTE_4 extends true
|
|
26
|
+
? LegacyComponent<P>
|
|
27
|
+
: Svelte3LegacyComponent<P>
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* The type of an imported, compiled Svelte component.
|
|
@@ -19,12 +32,12 @@ export type Component<
|
|
|
19
32
|
* In Svelte 5, this distinction no longer matters.
|
|
20
33
|
* In Svelte 4, this is the Svelte component class constructor.
|
|
21
34
|
*/
|
|
22
|
-
export type ComponentType<C> =
|
|
23
|
-
? C
|
|
24
|
-
:
|
|
35
|
+
export type ComponentType<C> = C extends LegacyComponent
|
|
36
|
+
? new (...args: any[]) => C
|
|
37
|
+
: C
|
|
25
38
|
|
|
26
39
|
/** The props of a component. */
|
|
27
|
-
export type Props<C extends Component
|
|
40
|
+
export type Props<C extends Component> = ComponentProps<C>
|
|
28
41
|
|
|
29
42
|
/**
|
|
30
43
|
* The exported fields of a component.
|
|
@@ -32,9 +45,9 @@ export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
|
|
|
32
45
|
* In Svelte 5, this is the set of variables marked as `export`'d.
|
|
33
46
|
* In Svelte 4, this is simply the instance of the component class.
|
|
34
47
|
*/
|
|
35
|
-
export type Exports<C> = C extends
|
|
48
|
+
export type Exports<C> = C extends LegacyComponent
|
|
36
49
|
? C
|
|
37
|
-
: C extends
|
|
50
|
+
: C extends ModernComponent<any, infer E>
|
|
38
51
|
? E
|
|
39
52
|
: never
|
|
40
53
|
|
|
@@ -43,7 +56,6 @@ export type Exports<C> = C extends Svelte.SvelteComponent
|
|
|
43
56
|
*
|
|
44
57
|
* In Svelte 4, these are the options passed to the component constructor.
|
|
45
58
|
*/
|
|
46
|
-
export type MountOptions<C extends Component
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: Svelte.ComponentConstructorOptions<Props<C>>
|
|
59
|
+
export type MountOptions<C extends Component> = C extends LegacyComponent
|
|
60
|
+
? LegacyConstructorOptions<Props<C>>
|
|
61
|
+
: Parameters<typeof mount<Props<C>, Exports<C>>>[1]
|
package/types/pure.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Customize how Svelte renders the component.
|
|
3
3
|
*/
|
|
4
|
-
export type SvelteComponentOptions<C extends
|
|
4
|
+
export type SvelteComponentOptions<C extends import("./component-types.js").Component> = import("./component-types.js").Props<C> | Partial<import("./component-types.js").MountOptions<C>>;
|
|
5
5
|
/**
|
|
6
6
|
* Customize how Testing Library sets up the document and binds queries.
|
|
7
7
|
*/
|
|
@@ -12,7 +12,7 @@ export type RenderOptions<Q extends import("@testing-library/dom").Queries = typ
|
|
|
12
12
|
/**
|
|
13
13
|
* The rendered component and bound testing functions.
|
|
14
14
|
*/
|
|
15
|
-
export type RenderResult<C extends
|
|
15
|
+
export type RenderResult<C extends import("./component-types.js").Component, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")> = {
|
|
16
16
|
container: HTMLElement;
|
|
17
17
|
baseElement: HTMLElement;
|
|
18
18
|
component: import("./component-types.js").Exports<C>;
|
|
@@ -91,5 +91,5 @@ export const fireEvent: FireFunction & FireObject;
|
|
|
91
91
|
* @param {RenderOptions<Q>} renderOptions - Customize how Testing Library sets up the document and binds queries.
|
|
92
92
|
* @returns {RenderResult<C, Q>} The rendered component and bound testing functions.
|
|
93
93
|
*/
|
|
94
|
-
export function render<C extends
|
|
94
|
+
export function render<C extends import("./component-types.js").Component, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")>(Component: import("./component-types.js").ComponentType<C>, options?: SvelteComponentOptions<C>, renderOptions?: RenderOptions<Q>): RenderResult<C, Q>;
|
|
95
95
|
//# sourceMappingURL=pure.d.ts.map
|
package/types/pure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../src/pure.js"],"names":[],"mappings":";;;mCAewD,CAAC,SAA5C,
|
|
1
|
+
{"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../src/pure.js"],"names":[],"mappings":";;;mCAewD,CAAC,SAA5C,OAAQ,sBAAsB,EAAE,SAAU,IAC1C,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;;;;0BAMvD,CAAC,SAA3C,OAAQ,sBAAsB,EAAE,OAAQ,6DACxC;IACR,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,OAAO,CAAC,EAAE,CAAC,CAAA;CACZ;;;;yBAMoD,CAAC,SAA5C,OAAQ,sBAAsB,EAAE,SAAU,EACA,CAAC,SAA3C,OAAQ,sBAAsB,EAAE,OAAQ,6DAExC;IACR,SAAS,EAAE,WAAW,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,SAAS,EAAE,OAAO,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACpD,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,GAAG,gBAAgB,KAAK,IAAI,CAAA;IACpD,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpF,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,GAAG,GACD,CAAY,IAAP,MAAM,CAAC,GAAG,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACnE;2BAkGS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC;yBAItI,GACP,CAA6C,IAAxC,OAAO,sBAAsB,EAAE,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAC1L;AApBJ;;;;;GAKG;AACH,gCAHiB,OAAO,gBACX,OAAO,CAAC,IAAI,CAAC,CAOzB;AAjBD,oEAAoE;AACpE,gCAGC;AAeD;;GAEG;AAEH;;;;GAIG;AAEH;;;;;;;GAOG;AACH,wBAFU,YAAY,GAAG,UAAU,CAMlC;AAvJD;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;GAUG;AACH,uBARwD,CAAC,SAA5C,OAAQ,sBAAsB,EAAE,SAAU,EACA,CAAC,SAA3C,OAAQ,sBAAsB,EAAE,OAAQ,sEAE1C,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC,CAAC,YAC/C,sBAAsB,CAAC,CAAC,CAAC,kBACzB,aAAa,CAAC,CAAC,CAAC,GACd,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CA8C9B"}
|