@storybook/sveltekit 9.0.0-alpha.2 → 9.0.0-alpha.20
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/dist/{chunk-REI2Y3HY.mjs → chunk-UUT6FZ4K.mjs} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +3 -2
- package/dist/preview.js +1 -1
- package/dist/preview.mjs +1 -1
- package/package.json +10 -10
- package/template/stories_svelte-kit-skeleton-ts/modules/Environment.svelte +8 -0
- package/template/stories_svelte-kit-skeleton-ts/modules/Forms.svelte +7 -0
- package/template/stories_svelte-kit-skeleton-ts/modules/Hrefs.svelte +8 -0
- package/template/stories_svelte-kit-skeleton-ts/modules/Navigation.svelte +37 -0
- package/template/stories_svelte-kit-skeleton-ts/modules/Paths.svelte +6 -0
- package/template/stories_svelte-kit-skeleton-ts/modules/Stores.svelte +17 -0
- package/template/stories_svelte-kit-skeleton-ts/modules/environment.stories.js +8 -0
- package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/forms.stories.js +2 -3
- package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/hrefs.stories.js +2 -3
- package/template/{stories_svelte-kit-skeleton-js → stories_svelte-kit-skeleton-ts/modules}/navigation.stories.js +2 -3
- package/template/stories_svelte-kit-skeleton-ts/modules/paths.stories.js +8 -0
- package/template/stories_svelte-kit-skeleton-ts/{stores.stories.js → modules/stores.stories.js} +1 -2
- package/template/stories_svelte-kit-prerelease-ts/docs-jsdoc-runes.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/docs-ts-inline-prop-types.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/docs-ts-referenced-prop-types.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/docs-ts.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/navigation.stories.js +0 -121
- package/template/stories_svelte-kit-prerelease-ts/stores.stories.js +0 -116
- package/template/stories_svelte-kit-skeleton-js/environment.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-js/forms.stories.js +0 -27
- package/template/stories_svelte-kit-skeleton-js/hrefs.stories.js +0 -53
- package/template/stories_svelte-kit-skeleton-js/paths.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-js/stores.stories.js +0 -116
- package/template/stories_svelte-kit-skeleton-ts/docs-ts.stories.js +0 -10
- package/template/stories_svelte-kit-skeleton-ts/environment.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-ts/forms.stories.js +0 -27
- package/template/stories_svelte-kit-skeleton-ts/hrefs.stories.js +0 -53
- package/template/stories_svelte-kit-skeleton-ts/navigation.stories.js +0 -121
- package/template/stories_svelte-kit-skeleton-ts/paths.stories.js +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __export } from './chunk-CEH6MNVV.mjs';
|
|
2
|
-
import { action } from '
|
|
2
|
+
import { action } from 'storybook/actions';
|
|
3
3
|
import { onMount, setContext, getContext } from 'svelte';
|
|
4
4
|
|
|
5
5
|
var preview_exports={};__export(preview_exports,{decorators:()=>decorators});function setAfterNavigateArgument(afterNavigateArgs){setContext("after-navigate-args",afterNavigateArgs);}function createMockedStore(contextName){return [{subscribe(runner){let page2=getContext(contextName);return runner(page2),()=>{}}},value=>{setContext(contextName,value);}]}var[page,setPage]=createMockedStore("page-ctx"),[navigating,setNavigating]=createMockedStore("navigating-ctx"),[updated,setUpdated]=createMockedStore("updated-ctx");updated.check=()=>{};var normalizeHrefConfig=hrefConfig=>typeof hrefConfig=="function"?{callback:hrefConfig,asRegex:!1}:hrefConfig,svelteKitMocksDecorator=(Story,ctx)=>{let svelteKitParameters=ctx.parameters?.sveltekit_experimental??{};return setPage(svelteKitParameters?.stores?.page),setNavigating(svelteKitParameters?.stores?.navigating),setUpdated(svelteKitParameters?.stores?.updated),setAfterNavigateArgument(svelteKitParameters?.navigation?.afterNavigate),onMount(()=>{let globalClickListener=e=>{let element=e.composedPath().findLast(el=>el instanceof HTMLElement&&el.tagName==="A");if(element&&element instanceof HTMLAnchorElement){let to=element.getAttribute("href");if(!to)return;e.preventDefault();let defaultActionCallback=()=>action("navigate")(to,e);if(!svelteKitParameters.hrefs){defaultActionCallback();return}let callDefaultCallback=!0;Object.entries(svelteKitParameters.hrefs).forEach(([href,hrefConfig])=>{let{callback,asRegex}=normalizeHrefConfig(hrefConfig);(asRegex?new RegExp(href).test(to):to===href)&&(callDefaultCallback=!1,callback?.(to,e));}),callDefaultCallback&&defaultActionCallback();}};function createListeners(baseModule,functions,defaultToAction){let toRemove=[];return functions.forEach(func=>{let hasFunction=svelteKitParameters[baseModule]?.[func]&&svelteKitParameters[baseModule][func]instanceof Function;if(hasFunction||defaultToAction){let listener=({detail=[]})=>{let args=Array.isArray(detail)?detail:[];(hasFunction?svelteKitParameters[baseModule][func]:action(func))(...args);},eventType=`storybook:${func}`;toRemove.push({eventType,listener}),window.addEventListener(eventType,listener);}}),()=>{toRemove.forEach(({eventType,listener})=>{window.removeEventListener(eventType,listener);});}}let removeNavigationListeners=createListeners("navigation",["goto","invalidate","invalidateAll","pushState","replaceState"],!0),removeFormsListeners=createListeners("forms",["enhance"]);return window.addEventListener("click",globalClickListener),()=>{window.removeEventListener("click",globalClickListener),removeNavigationListeners(),removeFormsListeners();}}),Story()},decorators=[svelteKitMocksDecorator];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { SvelteRenderer } from '@storybook/svelte';
|
|
2
|
+
export * from '@storybook/svelte';
|
|
1
3
|
export { F as FrameworkOptions, H as HrefConfig, N as NormalizedHrefConfig, S as StorybookConfig, a as SvelteKitParameters } from './types-3f08d935.js';
|
|
2
4
|
import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations } from 'storybook/internal/types';
|
|
3
|
-
import { SvelteRenderer } from '@storybook/svelte';
|
|
4
5
|
import '@storybook/builder-vite';
|
|
5
6
|
|
|
6
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{setProjectAnnotations:()=>setProjectAnnotations});module.exports=__toCommonJS(index_exports);
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default"));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{setProjectAnnotations:()=>setProjectAnnotations});module.exports=__toCommonJS(index_exports);__reExport(index_exports,require("@storybook/svelte"),module.exports);var import_svelte4=require("@storybook/svelte"),import_preview_api=require("storybook/preview-api");var preview_exports={};__export(preview_exports,{decorators:()=>decorators});var import_actions=require("storybook/actions"),import_svelte3=require("svelte");var import_svelte=require("svelte");function setAfterNavigateArgument(afterNavigateArgs){(0,import_svelte.setContext)("after-navigate-args",afterNavigateArgs)}var import_svelte2=require("svelte");function createMockedStore(contextName){return[{subscribe(runner){let page2=(0,import_svelte2.getContext)(contextName);return runner(page2),()=>{}}},value=>{(0,import_svelte2.setContext)(contextName,value)}]}var[page,setPage]=createMockedStore("page-ctx"),[navigating,setNavigating]=createMockedStore("navigating-ctx"),[updated,setUpdated]=createMockedStore("updated-ctx");updated.check=()=>{};var normalizeHrefConfig=hrefConfig=>typeof hrefConfig=="function"?{callback:hrefConfig,asRegex:!1}:hrefConfig,svelteKitMocksDecorator=(Story,ctx)=>{let svelteKitParameters=ctx.parameters?.sveltekit_experimental??{};return setPage(svelteKitParameters?.stores?.page),setNavigating(svelteKitParameters?.stores?.navigating),setUpdated(svelteKitParameters?.stores?.updated),setAfterNavigateArgument(svelteKitParameters?.navigation?.afterNavigate),(0,import_svelte3.onMount)(()=>{let globalClickListener=e=>{let element=e.composedPath().findLast(el=>el instanceof HTMLElement&&el.tagName==="A");if(element&&element instanceof HTMLAnchorElement){let to=element.getAttribute("href");if(!to)return;e.preventDefault();let defaultActionCallback=()=>(0,import_actions.action)("navigate")(to,e);if(!svelteKitParameters.hrefs){defaultActionCallback();return}let callDefaultCallback=!0;Object.entries(svelteKitParameters.hrefs).forEach(([href,hrefConfig])=>{let{callback,asRegex}=normalizeHrefConfig(hrefConfig);(asRegex?new RegExp(href).test(to):to===href)&&(callDefaultCallback=!1,callback?.(to,e))}),callDefaultCallback&&defaultActionCallback()}};function createListeners(baseModule,functions,defaultToAction){let toRemove=[];return functions.forEach(func=>{let hasFunction=svelteKitParameters[baseModule]?.[func]&&svelteKitParameters[baseModule][func]instanceof Function;if(hasFunction||defaultToAction){let listener=({detail=[]})=>{let args=Array.isArray(detail)?detail:[];(hasFunction?svelteKitParameters[baseModule][func]:(0,import_actions.action)(func))(...args)},eventType=`storybook:${func}`;toRemove.push({eventType,listener}),window.addEventListener(eventType,listener)}}),()=>{toRemove.forEach(({eventType,listener})=>{window.removeEventListener(eventType,listener)})}}let removeNavigationListeners=createListeners("navigation",["goto","invalidate","invalidateAll","pushState","replaceState"],!0),removeFormsListeners=createListeners("forms",["enhance"]);return window.addEventListener("click",globalClickListener),()=>{window.removeEventListener("click",globalClickListener),removeNavigationListeners(),removeFormsListeners()}}),Story()},decorators=[svelteKitMocksDecorator];function setProjectAnnotations(projectAnnotations){return(0,import_preview_api.setDefaultProjectAnnotations)(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS),(0,import_preview_api.setProjectAnnotations)(projectAnnotations)}var INTERNAL_DEFAULT_PROJECT_ANNOTATIONS=(0,import_preview_api.composeConfigs)([import_svelte4.INTERNAL_DEFAULT_PROJECT_ANNOTATIONS,preview_exports]);0&&(module.exports={setProjectAnnotations,...require("@storybook/svelte")});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { preview_exports } from './chunk-
|
|
1
|
+
import { preview_exports } from './chunk-UUT6FZ4K.mjs';
|
|
2
2
|
import './chunk-CEH6MNVV.mjs';
|
|
3
|
-
import { composeConfigs, setDefaultProjectAnnotations, setProjectAnnotations as setProjectAnnotations$1 } from 'storybook/internal/preview-api';
|
|
4
3
|
import { INTERNAL_DEFAULT_PROJECT_ANNOTATIONS as INTERNAL_DEFAULT_PROJECT_ANNOTATIONS$1 } from '@storybook/svelte';
|
|
4
|
+
export * from '@storybook/svelte';
|
|
5
|
+
import { composeConfigs, setDefaultProjectAnnotations, setProjectAnnotations as setProjectAnnotations$1 } from 'storybook/preview-api';
|
|
5
6
|
|
|
6
7
|
function setProjectAnnotations(projectAnnotations){return setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS),setProjectAnnotations$1(projectAnnotations)}var INTERNAL_DEFAULT_PROJECT_ANNOTATIONS=composeConfigs([INTERNAL_DEFAULT_PROJECT_ANNOTATIONS$1,preview_exports]);
|
|
7
8
|
|
package/dist/preview.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preview_exports={};__export(preview_exports,{decorators:()=>decorators});module.exports=__toCommonJS(preview_exports);var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preview_exports={};__export(preview_exports,{decorators:()=>decorators});module.exports=__toCommonJS(preview_exports);var import_actions=require("storybook/actions"),import_svelte3=require("svelte");var import_svelte=require("svelte");function setAfterNavigateArgument(afterNavigateArgs){(0,import_svelte.setContext)("after-navigate-args",afterNavigateArgs)}var import_svelte2=require("svelte");function createMockedStore(contextName){return[{subscribe(runner){let page2=(0,import_svelte2.getContext)(contextName);return runner(page2),()=>{}}},value=>{(0,import_svelte2.setContext)(contextName,value)}]}var[page,setPage]=createMockedStore("page-ctx"),[navigating,setNavigating]=createMockedStore("navigating-ctx"),[updated,setUpdated]=createMockedStore("updated-ctx");updated.check=()=>{};var normalizeHrefConfig=hrefConfig=>typeof hrefConfig=="function"?{callback:hrefConfig,asRegex:!1}:hrefConfig,svelteKitMocksDecorator=(Story,ctx)=>{let svelteKitParameters=ctx.parameters?.sveltekit_experimental??{};return setPage(svelteKitParameters?.stores?.page),setNavigating(svelteKitParameters?.stores?.navigating),setUpdated(svelteKitParameters?.stores?.updated),setAfterNavigateArgument(svelteKitParameters?.navigation?.afterNavigate),(0,import_svelte3.onMount)(()=>{let globalClickListener=e=>{let element=e.composedPath().findLast(el=>el instanceof HTMLElement&&el.tagName==="A");if(element&&element instanceof HTMLAnchorElement){let to=element.getAttribute("href");if(!to)return;e.preventDefault();let defaultActionCallback=()=>(0,import_actions.action)("navigate")(to,e);if(!svelteKitParameters.hrefs){defaultActionCallback();return}let callDefaultCallback=!0;Object.entries(svelteKitParameters.hrefs).forEach(([href,hrefConfig])=>{let{callback,asRegex}=normalizeHrefConfig(hrefConfig);(asRegex?new RegExp(href).test(to):to===href)&&(callDefaultCallback=!1,callback?.(to,e))}),callDefaultCallback&&defaultActionCallback()}};function createListeners(baseModule,functions,defaultToAction){let toRemove=[];return functions.forEach(func=>{let hasFunction=svelteKitParameters[baseModule]?.[func]&&svelteKitParameters[baseModule][func]instanceof Function;if(hasFunction||defaultToAction){let listener=({detail=[]})=>{let args=Array.isArray(detail)?detail:[];(hasFunction?svelteKitParameters[baseModule][func]:(0,import_actions.action)(func))(...args)},eventType=`storybook:${func}`;toRemove.push({eventType,listener}),window.addEventListener(eventType,listener)}}),()=>{toRemove.forEach(({eventType,listener})=>{window.removeEventListener(eventType,listener)})}}let removeNavigationListeners=createListeners("navigation",["goto","invalidate","invalidateAll","pushState","replaceState"],!0),removeFormsListeners=createListeners("forms",["enhance"]);return window.addEventListener("click",globalClickListener),()=>{window.removeEventListener("click",globalClickListener),removeNavigationListeners(),removeFormsListeners()}}),Story()},decorators=[svelteKitMocksDecorator];0&&(module.exports={decorators});
|
package/dist/preview.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { decorators } from './chunk-
|
|
1
|
+
export { decorators } from './chunk-UUT6FZ4K.mjs';
|
|
2
2
|
import './chunk-CEH6MNVV.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/sveltekit",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.20",
|
|
4
4
|
"description": "Storybook for SvelteKit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"types": "dist/index.d.ts",
|
|
55
55
|
"files": [
|
|
56
56
|
"dist/**/*",
|
|
57
|
+
"template/**/*",
|
|
57
58
|
"README.md",
|
|
58
59
|
"*.js",
|
|
59
60
|
"*.d.ts",
|
|
@@ -64,23 +65,22 @@
|
|
|
64
65
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"@storybook/
|
|
68
|
-
"@storybook/
|
|
69
|
-
"@storybook/svelte": "9.0.0-alpha.
|
|
70
|
-
"@storybook/svelte-vite": "9.0.0-alpha.2"
|
|
68
|
+
"@storybook/builder-vite": "9.0.0-alpha.20",
|
|
69
|
+
"@storybook/svelte": "9.0.0-alpha.20",
|
|
70
|
+
"@storybook/svelte-vite": "9.0.0-alpha.20"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/node": "^22.0.0",
|
|
74
74
|
"typescript": "^5.7.3",
|
|
75
|
-
"vite": "^
|
|
75
|
+
"vite": "^6.2.5"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"storybook": "^9.0.0-alpha.
|
|
79
|
-
"svelte": "^
|
|
80
|
-
"vite": "^
|
|
78
|
+
"storybook": "^9.0.0-alpha.20",
|
|
79
|
+
"svelte": "^5.0.0",
|
|
80
|
+
"vite": "^5.0.0 || ^6.0.0"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
83
|
+
"node": ">=20.0.0"
|
|
84
84
|
},
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { browser, dev, building, version } from '$app/environment';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div data-testid="browser">{browser}</div>
|
|
6
|
+
<div data-testid="dev">{dev}</div>
|
|
7
|
+
<div data-testid="building">{building}</div>
|
|
8
|
+
<div data-testid="version" data-chromatic="ignore">{version}</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { goto, invalidate, invalidateAll, afterNavigate, replaceState, pushState } from '$app/navigation';
|
|
3
|
+
|
|
4
|
+
export let afterNavigateFn;
|
|
5
|
+
|
|
6
|
+
afterNavigate(afterNavigateFn);
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<button
|
|
10
|
+
on:click={() => {
|
|
11
|
+
goto('/storybook-goto');
|
|
12
|
+
}}>goto</button
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
<button
|
|
16
|
+
on:click={() => {
|
|
17
|
+
invalidate('/storybook-invalidate');
|
|
18
|
+
}}>invalidate</button
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
<button
|
|
22
|
+
on:click={() => {
|
|
23
|
+
invalidateAll();
|
|
24
|
+
}}>invalidateAll</button
|
|
25
|
+
>
|
|
26
|
+
|
|
27
|
+
<button
|
|
28
|
+
on:click={() => {
|
|
29
|
+
pushState('/storybook-push-state', {});
|
|
30
|
+
}}>pushState</button
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
<button
|
|
34
|
+
on:click={() => {
|
|
35
|
+
replaceState('/storybook-replace-state', {});
|
|
36
|
+
}}>replaceState</button
|
|
37
|
+
>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { page, navigating, updated, getStores } from '$app/stores';
|
|
3
|
+
|
|
4
|
+
let { navigating: navigatingStore, page: pageStore, updated: updatedStore } = getStores();
|
|
5
|
+
|
|
6
|
+
updated.check();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<p>Directly importing</p>
|
|
10
|
+
<pre>{JSON.stringify($page, null, 2)}</pre>
|
|
11
|
+
<pre>{JSON.stringify($navigating, null, 2)}</pre>
|
|
12
|
+
<pre>{JSON.stringify($updated, null, 2)}</pre>
|
|
13
|
+
|
|
14
|
+
<p>With getStores</p>
|
|
15
|
+
<pre>{JSON.stringify($pageStore, null, 2)}</pre>
|
|
16
|
+
<pre>{JSON.stringify($navigatingStore, null, 2)}</pre>
|
|
17
|
+
<pre>{JSON.stringify($updatedStore, null, 2)}</pre>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { expect, fn, within } from '
|
|
1
|
+
import { expect, fn, within } from 'storybook/test';
|
|
2
2
|
|
|
3
3
|
import Forms from './Forms.svelte';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/forms',
|
|
6
|
+
title: 'stories/frameworks/sveltekit/modules/forms',
|
|
7
7
|
component: Forms,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
const enhance = fn();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { expect, fn, within } from '
|
|
1
|
+
import { expect, fn, within } from 'storybook/test';
|
|
2
2
|
|
|
3
3
|
import Hrefs from './Hrefs.svelte';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/hrefs',
|
|
6
|
+
title: 'stories/frameworks/sveltekit/modules/hrefs',
|
|
7
7
|
component: Hrefs,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
export const DefaultActions = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { expect, fn, within } from '
|
|
1
|
+
import { expect, fn, within } from 'storybook/test';
|
|
2
2
|
|
|
3
3
|
import Navigation from './Navigation.svelte';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/navigation',
|
|
6
|
+
title: 'stories/frameworks/sveltekit/modules/navigation',
|
|
7
7
|
component: Navigation,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
const goto = fn();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import DocsTSReferencedPropTypes from './DocsTSReferencedPropTypes.svelte';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'stories/renderers/svelte/docs-ts-referenced-prop-types',
|
|
5
|
-
component: DocsTSReferencedPropTypes,
|
|
6
|
-
args: {},
|
|
7
|
-
tags: ['autodocs'],
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const Primary = {};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Navigation from './Navigation.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/navigation',
|
|
7
|
-
component: Navigation,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const goto = fn();
|
|
12
|
-
|
|
13
|
-
export const Goto = {
|
|
14
|
-
async play({ canvasElement }) {
|
|
15
|
-
const canvas = within(canvasElement);
|
|
16
|
-
const button = canvas.getByText('goto');
|
|
17
|
-
button.click();
|
|
18
|
-
expect(goto).toHaveBeenCalledWith('/storybook-goto');
|
|
19
|
-
},
|
|
20
|
-
parameters: {
|
|
21
|
-
sveltekit_experimental: {
|
|
22
|
-
navigation: {
|
|
23
|
-
goto,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const replaceState = fn();
|
|
30
|
-
|
|
31
|
-
export const ReplaceState = {
|
|
32
|
-
async play({ canvasElement }) {
|
|
33
|
-
const canvas = within(canvasElement);
|
|
34
|
-
const button = canvas.getByText('replaceState');
|
|
35
|
-
button.click();
|
|
36
|
-
expect(replaceState).toHaveBeenCalledWith('/storybook-replace-state', {});
|
|
37
|
-
},
|
|
38
|
-
parameters: {
|
|
39
|
-
sveltekit_experimental: {
|
|
40
|
-
navigation: {
|
|
41
|
-
replaceState,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const pushState = fn();
|
|
48
|
-
|
|
49
|
-
export const PushState = {
|
|
50
|
-
async play({ canvasElement }) {
|
|
51
|
-
const canvas = within(canvasElement);
|
|
52
|
-
const button = canvas.getByText('pushState');
|
|
53
|
-
button.click();
|
|
54
|
-
expect(pushState).toHaveBeenCalledWith('/storybook-push-state', {});
|
|
55
|
-
},
|
|
56
|
-
parameters: {
|
|
57
|
-
sveltekit_experimental: {
|
|
58
|
-
navigation: {
|
|
59
|
-
pushState,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const DefaultActions = {};
|
|
66
|
-
|
|
67
|
-
const invalidate = fn();
|
|
68
|
-
|
|
69
|
-
export const Invalidate = {
|
|
70
|
-
async play({ canvasElement }) {
|
|
71
|
-
const canvas = within(canvasElement);
|
|
72
|
-
const button = canvas.getByText('invalidate', { exact: true });
|
|
73
|
-
button.click();
|
|
74
|
-
expect(invalidate).toHaveBeenCalledWith('/storybook-invalidate');
|
|
75
|
-
},
|
|
76
|
-
parameters: {
|
|
77
|
-
sveltekit_experimental: {
|
|
78
|
-
navigation: {
|
|
79
|
-
invalidate,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const invalidateAll = fn();
|
|
86
|
-
|
|
87
|
-
export const InvalidateAll = {
|
|
88
|
-
async play({ canvasElement }) {
|
|
89
|
-
const canvas = within(canvasElement);
|
|
90
|
-
const button = canvas.getByText('invalidateAll');
|
|
91
|
-
button.click();
|
|
92
|
-
expect(invalidateAll).toHaveBeenCalledWith();
|
|
93
|
-
},
|
|
94
|
-
parameters: {
|
|
95
|
-
sveltekit_experimental: {
|
|
96
|
-
navigation: {
|
|
97
|
-
invalidateAll,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const afterNavigateFn = fn();
|
|
104
|
-
|
|
105
|
-
export const AfterNavigate = {
|
|
106
|
-
async play() {
|
|
107
|
-
expect(afterNavigateFn).toHaveBeenCalledWith({ test: 'passed' });
|
|
108
|
-
},
|
|
109
|
-
args: {
|
|
110
|
-
afterNavigateFn,
|
|
111
|
-
},
|
|
112
|
-
parameters: {
|
|
113
|
-
sveltekit_experimental: {
|
|
114
|
-
navigation: {
|
|
115
|
-
afterNavigate: {
|
|
116
|
-
test: 'passed',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import Stores from './Stores.svelte';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'stories/sveltekit/modules/stores',
|
|
5
|
-
component: Stores,
|
|
6
|
-
tags: ['autodocs'],
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const AllUndefined = {};
|
|
10
|
-
|
|
11
|
-
export const PageStore = {
|
|
12
|
-
parameters: {
|
|
13
|
-
sveltekit_experimental: {
|
|
14
|
-
stores: {
|
|
15
|
-
page: {
|
|
16
|
-
data: {
|
|
17
|
-
test: 'passed',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const NavigatingStore = {
|
|
26
|
-
parameters: {
|
|
27
|
-
sveltekit_experimental: {
|
|
28
|
-
stores: {
|
|
29
|
-
navigating: {
|
|
30
|
-
route: {
|
|
31
|
-
id: '/storybook',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const UpdatedStore = {
|
|
40
|
-
parameters: {
|
|
41
|
-
sveltekit_experimental: {
|
|
42
|
-
stores: {
|
|
43
|
-
updated: true,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const PageAndNavigatingStore = {
|
|
50
|
-
parameters: {
|
|
51
|
-
sveltekit_experimental: {
|
|
52
|
-
stores: {
|
|
53
|
-
page: {
|
|
54
|
-
data: {
|
|
55
|
-
test: 'passed',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
navigating: {
|
|
59
|
-
route: {
|
|
60
|
-
id: '/storybook',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const PageAndUpdatedStore = {
|
|
69
|
-
parameters: {
|
|
70
|
-
sveltekit_experimental: {
|
|
71
|
-
stores: {
|
|
72
|
-
page: {
|
|
73
|
-
data: {
|
|
74
|
-
test: 'passed',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
updated: true,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const NavigatingAndUpdatedStore = {
|
|
84
|
-
parameters: {
|
|
85
|
-
sveltekit_experimental: {
|
|
86
|
-
stores: {
|
|
87
|
-
navigating: {
|
|
88
|
-
route: {
|
|
89
|
-
id: '/storybook',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
updated: true,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const AllThreeStores = {
|
|
99
|
-
parameters: {
|
|
100
|
-
sveltekit_experimental: {
|
|
101
|
-
stores: {
|
|
102
|
-
page: {
|
|
103
|
-
data: {
|
|
104
|
-
test: 'passed',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
navigating: {
|
|
108
|
-
route: {
|
|
109
|
-
id: '/storybook',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
updated: true,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Environment from './Environment.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/environment',
|
|
7
|
-
component: Environment,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Default = {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { expect, fn, userEvent, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Forms from './Forms.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/forms',
|
|
7
|
-
component: Forms,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const enhance = fn();
|
|
12
|
-
|
|
13
|
-
export const Enhance = {
|
|
14
|
-
async play({ canvasElement }) {
|
|
15
|
-
const canvas = within(canvasElement);
|
|
16
|
-
const button = canvas.getByRole('button');
|
|
17
|
-
await userEvent.click(button);
|
|
18
|
-
expect(enhance).toHaveBeenCalled();
|
|
19
|
-
},
|
|
20
|
-
parameters: {
|
|
21
|
-
sveltekit_experimental: {
|
|
22
|
-
forms: {
|
|
23
|
-
enhance,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Hrefs from './Hrefs.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/hrefs',
|
|
7
|
-
component: Hrefs,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const DefaultActions = {
|
|
12
|
-
async play({ canvasElement }) {
|
|
13
|
-
const canvas = within(canvasElement);
|
|
14
|
-
|
|
15
|
-
const initialUrl = window.location.toString();
|
|
16
|
-
|
|
17
|
-
const basicHref = canvas.getByText('/basic-href');
|
|
18
|
-
basicHref.click();
|
|
19
|
-
|
|
20
|
-
const complexHref = canvas.getByText(
|
|
21
|
-
'/deep/nested/link?with=true&multiple-params=200#and-an-id'
|
|
22
|
-
);
|
|
23
|
-
complexHref.click();
|
|
24
|
-
|
|
25
|
-
const finalUrl = window.location.toString();
|
|
26
|
-
expect(finalUrl).toBe(initialUrl);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const basicStringMatch = fn();
|
|
31
|
-
const noMatch = fn();
|
|
32
|
-
const exactStringMatch = fn();
|
|
33
|
-
const regexMatch = fn();
|
|
34
|
-
|
|
35
|
-
export const Callbacks = {
|
|
36
|
-
parameters: {
|
|
37
|
-
sveltekit_experimental: {
|
|
38
|
-
hrefs: {
|
|
39
|
-
'/basic-href': basicStringMatch,
|
|
40
|
-
'/basic': noMatch,
|
|
41
|
-
'/deep/nested/link?with=true&multiple-params=200#and-an-id': exactStringMatch,
|
|
42
|
-
'nested/link\\?with': { callback: regexMatch, asRegex: true },
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
play: async (ctx) => {
|
|
47
|
-
await DefaultActions.play(ctx);
|
|
48
|
-
expect(basicStringMatch).toHaveBeenCalledTimes(1);
|
|
49
|
-
expect(noMatch).not.toHaveBeenCalled();
|
|
50
|
-
expect(exactStringMatch).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(regexMatch).toHaveBeenCalledTimes(1);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import Stores from './Stores.svelte';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'stories/sveltekit/modules/stores',
|
|
5
|
-
component: Stores,
|
|
6
|
-
tags: ['autodocs'],
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const AllUndefined = {};
|
|
10
|
-
|
|
11
|
-
export const PageStore = {
|
|
12
|
-
parameters: {
|
|
13
|
-
sveltekit_experimental: {
|
|
14
|
-
stores: {
|
|
15
|
-
page: {
|
|
16
|
-
data: {
|
|
17
|
-
test: 'passed',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const NavigatingStore = {
|
|
26
|
-
parameters: {
|
|
27
|
-
sveltekit_experimental: {
|
|
28
|
-
stores: {
|
|
29
|
-
navigating: {
|
|
30
|
-
route: {
|
|
31
|
-
id: '/storybook',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const UpdatedStore = {
|
|
40
|
-
parameters: {
|
|
41
|
-
sveltekit_experimental: {
|
|
42
|
-
stores: {
|
|
43
|
-
updated: true,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const PageAndNavigatingStore = {
|
|
50
|
-
parameters: {
|
|
51
|
-
sveltekit_experimental: {
|
|
52
|
-
stores: {
|
|
53
|
-
page: {
|
|
54
|
-
data: {
|
|
55
|
-
test: 'passed',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
navigating: {
|
|
59
|
-
route: {
|
|
60
|
-
id: '/storybook',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const PageAndUpdatedStore = {
|
|
69
|
-
parameters: {
|
|
70
|
-
sveltekit_experimental: {
|
|
71
|
-
stores: {
|
|
72
|
-
page: {
|
|
73
|
-
data: {
|
|
74
|
-
test: 'passed',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
updated: true,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const NavigatingAndUpdatedStore = {
|
|
84
|
-
parameters: {
|
|
85
|
-
sveltekit_experimental: {
|
|
86
|
-
stores: {
|
|
87
|
-
navigating: {
|
|
88
|
-
route: {
|
|
89
|
-
id: '/storybook',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
updated: true,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const AllThreeStores = {
|
|
99
|
-
parameters: {
|
|
100
|
-
sveltekit_experimental: {
|
|
101
|
-
stores: {
|
|
102
|
-
page: {
|
|
103
|
-
data: {
|
|
104
|
-
test: 'passed',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
navigating: {
|
|
108
|
-
route: {
|
|
109
|
-
id: '/storybook',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
updated: true,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Environment from './Environment.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/environment',
|
|
7
|
-
component: Environment,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Default = {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Forms from './Forms.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/forms',
|
|
7
|
-
component: Forms,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const enhance = fn();
|
|
12
|
-
|
|
13
|
-
export const Enhance = {
|
|
14
|
-
async play({ canvasElement }) {
|
|
15
|
-
const canvas = within(canvasElement);
|
|
16
|
-
const button = canvas.getByText('enhance');
|
|
17
|
-
button.click();
|
|
18
|
-
expect(enhance).toHaveBeenCalled();
|
|
19
|
-
},
|
|
20
|
-
parameters: {
|
|
21
|
-
sveltekit_experimental: {
|
|
22
|
-
forms: {
|
|
23
|
-
enhance,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Hrefs from './Hrefs.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/hrefs',
|
|
7
|
-
component: Hrefs,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const DefaultActions = {
|
|
12
|
-
async play({ canvasElement }) {
|
|
13
|
-
const canvas = within(canvasElement);
|
|
14
|
-
|
|
15
|
-
const initialUrl = window.location.toString();
|
|
16
|
-
|
|
17
|
-
const basicHref = canvas.getByText('/basic-href');
|
|
18
|
-
basicHref.click();
|
|
19
|
-
|
|
20
|
-
const complexHref = canvas.getByText(
|
|
21
|
-
'/deep/nested/link?with=true&multiple-params=200#and-an-id'
|
|
22
|
-
);
|
|
23
|
-
complexHref.click();
|
|
24
|
-
|
|
25
|
-
const finalUrl = window.location.toString();
|
|
26
|
-
expect(finalUrl).toBe(initialUrl);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const basicStringMatch = fn();
|
|
31
|
-
const noMatch = fn();
|
|
32
|
-
const exactStringMatch = fn();
|
|
33
|
-
const regexMatch = fn();
|
|
34
|
-
|
|
35
|
-
export const Callbacks = {
|
|
36
|
-
parameters: {
|
|
37
|
-
sveltekit_experimental: {
|
|
38
|
-
hrefs: {
|
|
39
|
-
'/basic-href': basicStringMatch,
|
|
40
|
-
'/basic': noMatch,
|
|
41
|
-
'/deep/nested/link?with=true&multiple-params=200#and-an-id': exactStringMatch,
|
|
42
|
-
'nested/link\\?with': { callback: regexMatch, asRegex: true },
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
play: async (ctx) => {
|
|
47
|
-
await DefaultActions.play(ctx);
|
|
48
|
-
expect(basicStringMatch).toHaveBeenCalledTimes(1);
|
|
49
|
-
expect(noMatch).not.toHaveBeenCalled();
|
|
50
|
-
expect(exactStringMatch).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(regexMatch).toHaveBeenCalledTimes(1);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { expect, fn, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Navigation from './Navigation.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/navigation',
|
|
7
|
-
component: Navigation,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const goto = fn();
|
|
12
|
-
|
|
13
|
-
export const Goto = {
|
|
14
|
-
async play({ canvasElement }) {
|
|
15
|
-
const canvas = within(canvasElement);
|
|
16
|
-
const button = canvas.getByText('goto');
|
|
17
|
-
button.click();
|
|
18
|
-
expect(goto).toHaveBeenCalledWith('/storybook-goto');
|
|
19
|
-
},
|
|
20
|
-
parameters: {
|
|
21
|
-
sveltekit_experimental: {
|
|
22
|
-
navigation: {
|
|
23
|
-
goto,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const replaceState = fn();
|
|
30
|
-
|
|
31
|
-
export const ReplaceState = {
|
|
32
|
-
async play({ canvasElement }) {
|
|
33
|
-
const canvas = within(canvasElement);
|
|
34
|
-
const button = canvas.getByText('replaceState');
|
|
35
|
-
button.click();
|
|
36
|
-
expect(replaceState).toHaveBeenCalledWith('/storybook-replace-state', {});
|
|
37
|
-
},
|
|
38
|
-
parameters: {
|
|
39
|
-
sveltekit_experimental: {
|
|
40
|
-
navigation: {
|
|
41
|
-
replaceState,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const pushState = fn();
|
|
48
|
-
|
|
49
|
-
export const PushState = {
|
|
50
|
-
async play({ canvasElement }) {
|
|
51
|
-
const canvas = within(canvasElement);
|
|
52
|
-
const button = canvas.getByText('pushState');
|
|
53
|
-
button.click();
|
|
54
|
-
expect(pushState).toHaveBeenCalledWith('/storybook-push-state', {});
|
|
55
|
-
},
|
|
56
|
-
parameters: {
|
|
57
|
-
sveltekit_experimental: {
|
|
58
|
-
navigation: {
|
|
59
|
-
pushState,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const DefaultActions = {};
|
|
66
|
-
|
|
67
|
-
const invalidate = fn();
|
|
68
|
-
|
|
69
|
-
export const Invalidate = {
|
|
70
|
-
async play({ canvasElement }) {
|
|
71
|
-
const canvas = within(canvasElement);
|
|
72
|
-
const button = canvas.getByText('invalidate', { exact: true });
|
|
73
|
-
button.click();
|
|
74
|
-
expect(invalidate).toHaveBeenCalledWith('/storybook-invalidate');
|
|
75
|
-
},
|
|
76
|
-
parameters: {
|
|
77
|
-
sveltekit_experimental: {
|
|
78
|
-
navigation: {
|
|
79
|
-
invalidate,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const invalidateAll = fn();
|
|
86
|
-
|
|
87
|
-
export const InvalidateAll = {
|
|
88
|
-
async play({ canvasElement }) {
|
|
89
|
-
const canvas = within(canvasElement);
|
|
90
|
-
const button = canvas.getByText('invalidateAll');
|
|
91
|
-
button.click();
|
|
92
|
-
expect(invalidateAll).toHaveBeenCalledWith();
|
|
93
|
-
},
|
|
94
|
-
parameters: {
|
|
95
|
-
sveltekit_experimental: {
|
|
96
|
-
navigation: {
|
|
97
|
-
invalidateAll,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const afterNavigateFn = fn();
|
|
104
|
-
|
|
105
|
-
export const AfterNavigate = {
|
|
106
|
-
async play() {
|
|
107
|
-
expect(afterNavigateFn).toHaveBeenCalledWith({ test: 'passed' });
|
|
108
|
-
},
|
|
109
|
-
args: {
|
|
110
|
-
afterNavigateFn,
|
|
111
|
-
},
|
|
112
|
-
parameters: {
|
|
113
|
-
sveltekit_experimental: {
|
|
114
|
-
navigation: {
|
|
115
|
-
afterNavigate: {
|
|
116
|
-
test: 'passed',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
};
|