Merge branch 'docks64-clipboard'
This commit is contained in:
commit
49f01933b9
@ -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
|
||||
|
@ -59,6 +59,10 @@ tasks:
|
||||
- git checkout {{.PARENT_BRANCH}}
|
||||
- git weld -
|
||||
|
||||
analyzer:
|
||||
cmds:
|
||||
- vite-bundle-visualizer
|
||||
|
||||
publish:
|
||||
cmds:
|
||||
- { task: build }
|
||||
|
@ -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
|
||||
>
|
||||
|
@ -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}`);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user