-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases
game-with-hooks
game module
- Loading branch information
Showing
6 changed files
with
528 additions
and
3 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
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,28 @@ | ||
import { GameWithHooks } from "@modules/GameWithHooks/GameWithHooks"; | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import React from "react"; | ||
|
||
describe("GameWithHooks test cases", function () { | ||
describe("Render component behaviour", function () { | ||
it("should render game field by default", function () { | ||
const { asFragment } = render(<GameWithHooks />); | ||
|
||
expect(screen.getAllByRole("cell")).toHaveLength(81); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it("should observe onChange handler on game level", async function () { | ||
render(<GameWithHooks />); | ||
|
||
expect(screen.getAllByRole("cell")).toHaveLength(81); | ||
await userEvent.selectOptions(screen.getByRole("select-component"), "intermediate"); | ||
expect(screen.getByRole("option", { name: "intermediate" })).toBeEnabled(); | ||
expect(screen.getAllByRole("cell")).toHaveLength(256); | ||
|
||
await userEvent.selectOptions(screen.getByRole("select-component"), "expert"); | ||
expect(screen.getAllByRole("cell")).toHaveLength(484); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.