Loading client/src/components/Tool/utilities.test.ts 0 → 100644 +29 −0 Original line number Diff line number Diff line import { copyLink } from "./utilities"; const writeText = jest.fn(); Object.assign(navigator, { clipboard: { writeText, }, }); describe("copyLink", () => { beforeEach(() => { (navigator.clipboard.writeText as jest.Mock).mockResolvedValue(undefined); }); it("should copy the link to the clipboard", () => { const toolId = "MyToolId"; copyLink(toolId); expect(writeText).toHaveBeenCalledTimes(1); expect(writeText).toHaveBeenCalledWith(expect.stringContaining(toolId)); }); it("should encode the tool id", () => { const toolId = "My Tool Id"; copyLink(toolId); expect(writeText).toHaveBeenCalledTimes(1); expect(writeText).toHaveBeenCalledWith(expect.stringContaining("My%20Tool%20Id")); }); }); Loading
client/src/components/Tool/utilities.test.ts 0 → 100644 +29 −0 Original line number Diff line number Diff line import { copyLink } from "./utilities"; const writeText = jest.fn(); Object.assign(navigator, { clipboard: { writeText, }, }); describe("copyLink", () => { beforeEach(() => { (navigator.clipboard.writeText as jest.Mock).mockResolvedValue(undefined); }); it("should copy the link to the clipboard", () => { const toolId = "MyToolId"; copyLink(toolId); expect(writeText).toHaveBeenCalledTimes(1); expect(writeText).toHaveBeenCalledWith(expect.stringContaining(toolId)); }); it("should encode the tool id", () => { const toolId = "My Tool Id"; copyLink(toolId); expect(writeText).toHaveBeenCalledTimes(1); expect(writeText).toHaveBeenCalledWith(expect.stringContaining("My%20Tool%20Id")); }); });