-
-
Notifications
You must be signed in to change notification settings - Fork 408
Expand file tree
/
Copy pathapp.test.js
More file actions
56 lines (45 loc) · 1.45 KB
/
app.test.js
File metadata and controls
56 lines (45 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @jest-environment jsdom
*/
import { getByTestId, getByRole } from "@testing-library/dom";
import "@testing-library/jest-dom";
import { App } from "../src/app";
describe("button and counter", () => {
let container = App();
// Reset the App before each test
beforeEach(() => {
container = App();
});
test("contains description paragraph with mention of 'increment' in header", () => {
expect(
container.querySelector("header").querySelector("p")
).toHaveTextContent(/increment/i);
});
test("counter starts at 0", () => {
expect(getByTestId(container, "counter")).toHaveTextContent(/^0$/);
});
test("pressing Increment increases the counter", () => {
const button = getByRole(container, "button", {
name: "Increment",
});
button.click();
button.click();
expect(getByTestId(container, "counter")).toHaveTextContent(/^2$/);
});
// describe.skip("decrement button", () => {
test("pressing Decrement decreases the counter", () => {
const button = getByRole(container, "button", {
name: "Decrement",
});
button.click();
button.click();
button.click();
expect(getByTestId(container, "counter")).toHaveTextContent(/^-3$/);
});
test("contains description paragraph with mention of 'decrement' in header", () => {
expect(
container.querySelector("header").querySelectorAll("p")[1]
).toHaveTextContent(/decrement/i);
});
});
//});