-
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 #99 from shammy642/test_coverage
Test coverage
- Loading branch information
Showing
13 changed files
with
332 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
//imports needed | ||
import { render, screen } from "@testing-library/react"; | ||
import { describe, expect, test,vi } from "vitest"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { AvatarDropdown } from "../../src/components/AvatarDropdown"; | ||
import { socket } from "../../src/socket"; | ||
|
||
|
||
vi.mock("../../src/socket.js", () => { | ||
return { socket: { emit: vi.fn() } }; | ||
}); | ||
const setAvatar = vi.fn() | ||
const setAvatarOpen = vi.fn() | ||
|
||
describe("Avatar dropdown", () => { | ||
test('user can select a specific avatar', async () => { | ||
const user = userEvent.setup() | ||
//user sees the avatar list | ||
render(<AvatarDropdown setAvatar={setAvatar} isOpen={true} setAvatarOpen={setAvatarOpen}/>) | ||
//user clicks on an avatar | ||
const avatarEl = screen.getByAltText("Avatar 0") | ||
await user.click(avatarEl) | ||
//handle click is called | ||
expect(setAvatar).toHaveBeenCalledWith("/src/assets/1.png") | ||
expect(socket.emit).toHaveBeenCalledWith("avatar-selected","/src/assets/1.png") | ||
expect(setAvatarOpen).toHaveBeenCalledWith(false) | ||
|
||
}) | ||
}) | ||
|
||
|
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.