-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from shammy642/show-show-show-me-your-tests
show show show me your tests
- Loading branch information
Showing
6 changed files
with
79 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
export default function CheckMark() { | ||
export default function Clipboard() { | ||
return ( | ||
<svg className="w-6 h-6 text-white-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"> | ||
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-5-4v4h4V3h-4Z"/> | ||
</svg> | ||
|
||
<svg | ||
data-testid="clipboard-svg" | ||
className="w-6 h-6 text-white-800 dark:text-white" | ||
aria-hidden="true" | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-5-4v4h4V3h-4Z" | ||
/> | ||
</svg> | ||
); | ||
} |
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,51 @@ | ||
//imports needed | ||
import { render, screen } from "@testing-library/react"; | ||
import { describe, expect, test, vi } from "vitest"; | ||
import { CopyToClipboardButton } from "../../src/components/CopyToClipboardButton"; | ||
import userEvent from "@testing-library/user-event"; | ||
|
||
vi.mock("../../src/socket.js", () => { | ||
return { socket: { emit: vi.fn() } }; | ||
}); | ||
const setIsCopied = vi.fn(); | ||
|
||
describe("Avatar dropdown", () => { | ||
test("if is copied is true show copied svg", async () => { | ||
render( | ||
<CopyToClipboardButton | ||
content={"test content"} | ||
isCopied={true} | ||
setIsCopied={setIsCopied} | ||
/> | ||
); | ||
const imgEl = screen.getByTestId("copied-svg"); | ||
expect(imgEl).toBeDefined(); | ||
}); | ||
test("if is copied is false show clipbaord svg", async () => { | ||
render( | ||
<CopyToClipboardButton | ||
content={"test content"} | ||
isCopied={false} | ||
setIsCopied={setIsCopied} | ||
/> | ||
); | ||
const imgEl = screen.getByTestId("clipboard-svg"); | ||
expect(imgEl).toBeDefined(); | ||
}); | ||
test("when user clicks on copied", async () => { | ||
const user = userEvent.setup(); | ||
render( | ||
<CopyToClipboardButton | ||
content={"test content"} | ||
isCopied={false} | ||
setIsCopied={setIsCopied} | ||
/> | ||
); | ||
await user.click(screen.getByRole("button")); | ||
|
||
const clipboardText = await navigator.clipboard.readText(); | ||
|
||
expect(clipboardText).toBe("test content"); | ||
expect(setIsCopied).toHaveBeenCalledWith(true) | ||
}); | ||
}); |
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