mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
chore(jest): stub carbon-icons-svelte
This commit is contained in:
parent
ddb91f6327
commit
68622ba613
2 changed files with 48 additions and 0 deletions
|
@ -92,6 +92,9 @@
|
||||||
"js",
|
"js",
|
||||||
"svelte"
|
"svelte"
|
||||||
],
|
],
|
||||||
|
"moduleNameMapper": {
|
||||||
|
"^carbon-icons-svelte*": "<rootDir>src/internal/Icon.stub.svelte"
|
||||||
|
},
|
||||||
"setupFilesAfterEnv": [
|
"setupFilesAfterEnv": [
|
||||||
"regenerator-runtime/runtime",
|
"regenerator-runtime/runtime",
|
||||||
"@testing-library/jest-dom/extend-expect"
|
"@testing-library/jest-dom/extend-expect"
|
||||||
|
|
45
src/internal/Icon.stub.svelte
Normal file
45
src/internal/Icon.stub.svelte
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<script>
|
||||||
|
let className = undefined;
|
||||||
|
export { className as class };
|
||||||
|
export let id = undefined;
|
||||||
|
export let tabindex = undefined;
|
||||||
|
export let focusable = false;
|
||||||
|
export let title = undefined;
|
||||||
|
export let style = 'will-change: transform;';
|
||||||
|
|
||||||
|
const preserveAspectRatio = 'xMidYMid meet';
|
||||||
|
$: ariaLabel = $$props['aria-label'];
|
||||||
|
$: ariaLabelledBy = $$props['aria-labelledby'];
|
||||||
|
$: labelled = ariaLabel || ariaLabelledBy || title;
|
||||||
|
$: attributes = {
|
||||||
|
'aria-label': ariaLabel,
|
||||||
|
'aria-labelledby': ariaLabelledBy,
|
||||||
|
'aria-hidden': labelled ? undefined : true,
|
||||||
|
role: labelled ? 'img' : undefined,
|
||||||
|
focusable: tabindex === '0' ? true : focusable,
|
||||||
|
tabindex
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
on:click
|
||||||
|
on:mouseover
|
||||||
|
on:mouseenter
|
||||||
|
on:mouseleave
|
||||||
|
on:keyup
|
||||||
|
on:keydown
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
class={className}
|
||||||
|
{preserveAspectRatio}
|
||||||
|
{style}
|
||||||
|
{id}
|
||||||
|
{...attributes}>
|
||||||
|
<slot>
|
||||||
|
{#if title}
|
||||||
|
<title>{title}</title>
|
||||||
|
{/if}
|
||||||
|
</slot>
|
||||||
|
</svg>
|
Loading…
Add table
Add a link
Reference in a new issue