Skip to content

Commit d8e251d

Browse files
author
Chance Strickland
committed
Add integration test for the application
1 parent 7d677ba commit d8e251d

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/App.test.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,45 @@ import { fireEvent, render } from "@testing-library/react";
66
import { App } from "./App";
77

88
describe("<App />", () => {
9-
test("truth", () => {
10-
expect(true).toBe(true);
9+
it("should render the text input", () => {
10+
let { getByRole } = render(<App />);
11+
expect(getByRole("textbox")).toBeInTheDocument();
12+
});
13+
14+
it("should render the progress slider", () => {
15+
let { getByRole } = render(<App />);
16+
expect(getByRole("slider")).toBeInTheDocument();
17+
});
18+
19+
describe("when rendering the completion %", () => {
20+
test("should initially indicated no time allocated", () => {
21+
let { getByText } = render(<App />);
22+
expect(getByText("No time allocated yet")).toBeInTheDocument();
23+
});
24+
25+
test("should read 100% Complete when task time is at max", () => {
26+
let { getByRole, getByText, getByLabelText } = render(<App />);
27+
let slider = getByRole("slider");
28+
let input = getByRole("textbox");
29+
30+
userEvent.type(input, "2");
31+
fireEvent.click(slider);
32+
33+
// nudge twice
34+
fireEvent.keyDown(slider, { key: "ArrowRight" });
35+
fireEvent.keyDown(slider, { key: "ArrowRight" });
36+
37+
fireEvent.click(getByLabelText("Subtract"));
38+
39+
expect(getByText("100% complete")).toBeInTheDocument();
40+
});
41+
42+
test("should read 0% Complete when task time is at min", () => {
43+
let { getByRole, getByText, getByLabelText, container } = render(<App />);
44+
let input = getByRole("textbox");
45+
userEvent.type(input, "2");
46+
47+
expect(getByText("0% complete")).toBeInTheDocument();
48+
});
1149
});
1250
});

0 commit comments

Comments
 (0)