-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix context tests for svelte v5, all tests working again
- Loading branch information
Showing
6 changed files
with
132 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
@component | ||
Wraps the to be tested svelte-konva component so that the context of the svelte-konva component can be tested | ||
--> | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import ContextReporter from './ContextReporter.test.svelte'; | ||
const { | ||
component, | ||
config, | ||
getHandle, | ||
getComponentContext | ||
}: { | ||
component: any; | ||
config?: any; | ||
getHandle?: (handle: any) => void; | ||
getComponentContext: (ctx: Map<string, any>) => void; | ||
} = $props(); | ||
let boundComponent: any; | ||
onMount(() => { | ||
// Once we have the inner component handle of the svelte-konva component we pass it to the callback to get access to it in the test function | ||
if (getHandle) getHandle(boundComponent.handle); | ||
}); | ||
</script> | ||
|
||
<svelte:component this={component} bind:this={boundComponent} {config}> | ||
<ContextReporter {getComponentContext} /> | ||
</svelte:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
@component | ||
Is attached as a child component to svelte-konva containers and reports its current container context via callback for use in test functions | ||
--> | ||
<script lang="ts"> | ||
import { getContext, onMount } from 'svelte'; | ||
import { CONTAINER_COMPONENT_KEYS } from 'svelte-konva/util/manageContext'; | ||
const { | ||
getComponentContext | ||
}: { | ||
getComponentContext: (ctx: Map<string, any>) => void; | ||
} = $props(); | ||
onMount(() => { | ||
const ctxMap = new Map(); | ||
CONTAINER_COMPONENT_KEYS.forEach((key) => { | ||
ctxMap.set(key, getContext(key)); | ||
}); | ||
getComponentContext(ctxMap); | ||
}); | ||
</script> |