Merge branch 'docks64-clipboard'

docks66-json-schema
Yanick Champoux 2023-05-16 15:04:25 -04:00
commit 49f01933b9
4 changed files with 31 additions and 2 deletions

View File

@ -4,6 +4,10 @@ project:
with_stats: true
ticket_url: null
releases:
- version: NEXT
changes:
- desc: clipboard copy the serialized data
type: fix
- version: 3.2.0
changes:
- desc: add SMRs

View File

@ -59,6 +59,10 @@ tasks:
- git checkout {{.PARENT_BRANCH}}
- git weld -
analyzer:
cmds:
- vite-bundle-visualizer
publish:
cmds:
- { task: build }

View File

@ -1,7 +1,7 @@
<article>
<nav>
<button
use:clipboard={{ text: data }}
use:clipboard={{ text: serialized }}
on:copied={copied}
on:error={copyError}>{copyLabel} <i>content_paste</i></button
>

View File

@ -1,5 +1,8 @@
import { render, waitFor } from "@testing-library/svelte";
import { fireEvent, render, waitFor } from "@testing-library/svelte";
import "@testing-library/jest-dom";
import { vi } from "vitest";
import userEvent from "@testing-library/user-event";
import { tick } from "svelte";
import Serialized from "./Serialized.svelte";
@ -11,3 +14,21 @@ test("basic", () => {
});
waitFor(() => expect(getByText("hello world")).toBeInTheDocument());
});
test("clipboard", async () => {
const { getByText } = render(Serialized, {
props: {
data: { a: 1 },
},
});
await tick();
userEvent.setup();
const write = vi.spyOn(navigator.clipboard, "writeText");
await fireEvent.click(getByText("clipboard"));
expect(navigator.clipboard.writeText).not.toHaveBeenCalledWith({ a: 1 });
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(`{\n "a": 1\n}`);
});