-
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.
Fix test cases running error on queue
- Loading branch information
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/components/scoreboard/__snapshots__/scoreboard.test.tsx.snap
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,47 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Scoreboard test cases Scoreboard renders correctly 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="wrapperScoreboard" | ||
> | ||
<div | ||
class="parentCounter" | ||
> | ||
000 | ||
</div> | ||
<div> | ||
<select | ||
class="selectLevel" | ||
role="select-component" | ||
> | ||
<option | ||
class="optionLevel" | ||
> | ||
beginner | ||
</option> | ||
<option | ||
class="optionLevel" | ||
> | ||
intermediate | ||
</option> | ||
<option | ||
class="optionLevel" | ||
> | ||
expert | ||
</option> | ||
</select> | ||
<button | ||
class="resetButton" | ||
> | ||
🙂 | ||
</button> | ||
</div> | ||
<div | ||
class="parentCounter" | ||
> | ||
010 | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; |
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 { ScoreBoard } from "@components/scoreboard/scoreboard"; | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import React from "react"; | ||
|
||
describe("Scoreboard test cases", () => { | ||
const levels = ["beginner", "intermediate", "expert"]; | ||
|
||
it("Scoreboard renders correctly", () => { | ||
const { asFragment } = render( | ||
<ScoreBoard time="000" levels={levels} onReset={() => null} mines="010" onChange={() => null} /> | ||
); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
it("Scoreboard select level handler check", async () => { | ||
const onChange = jest.fn(); | ||
|
||
render(<ScoreBoard time="000" levels={levels} onReset={() => null} mines="010" onChange={onChange} />); | ||
|
||
await userEvent.selectOptions(screen.getByRole("select-component"), "expert"); | ||
|
||
expect(screen.getByRole("option", { name: "expert" })).toBeEnabled(); | ||
|
||
await Promise.resolve(); | ||
expect(onChange).toHaveBeenCalled(); | ||
}); | ||
}); |