-
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.
- Loading branch information
1 parent
222e759
commit df1b26f
Showing
10 changed files
with
150 additions
and
68 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { render } from "@testing-library/react"; | ||
import App from "./App"; | ||
|
||
describe("components", () => { | ||
test("renders UserInput", () => { | ||
const { getByText } = render(<App />); | ||
const userInputHeadingText = getByText(/User realtime input/i); | ||
expect(userInputHeadingText).toBeInTheDocument(); | ||
}); | ||
test("renders DbLike", async () => { | ||
const { getByText } = render(<App />); | ||
const userInputHeadingText = getByText(/DB like saved output/i); | ||
expect(userInputHeadingText).toBeInTheDocument(); | ||
}); | ||
}); |
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
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,41 @@ | ||
import { | ||
render, | ||
fireEvent, | ||
screen, | ||
waitFor, | ||
getByText, | ||
} from "@testing-library/react"; | ||
|
||
import UserInput from "../UserInput"; | ||
import DbLike from "../DbLike"; | ||
|
||
const userInputDefaultProps = { | ||
setSavedValue: jest.fn(), | ||
value: "test", | ||
}; | ||
|
||
const dbLikeDefaultProps = { | ||
debouncedValue: "", | ||
}; | ||
|
||
beforeEach(() => render(<DbLike {...dbLikeDefaultProps} />)); | ||
|
||
describe("DB like output", () => { | ||
test("renders do like heading", () => { | ||
const dbLikeHeading = screen.getByText(/DB like saved output/i); | ||
expect(dbLikeHeading).toBeInTheDocument(); | ||
}); | ||
|
||
test("should change one second after user typed", async () => { | ||
const { getByRole } = render(<UserInput {...userInputDefaultProps} />); | ||
const textArea = getByRole("textbox") as HTMLInputElement; | ||
fireEvent.change(textArea, { target: { value: "hello" } }); | ||
const { container } = render(<DbLike debouncedValue={textArea.value} />); | ||
await waitFor( | ||
() => expect(getByText(container, "hello")).toBeInTheDocument(), | ||
{ | ||
timeout: 2000, | ||
} | ||
); | ||
}); | ||
}); |
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,23 @@ | ||
import { render, fireEvent, screen } from "@testing-library/react"; | ||
|
||
import UserInput from "../UserInput"; | ||
|
||
const defaultProps = { | ||
setSavedValue: jest.fn(), | ||
value: "test", | ||
}; | ||
|
||
beforeEach(() => render(<UserInput {...defaultProps} />)); | ||
|
||
describe("user input", () => { | ||
test("renders user input heading", () => { | ||
const userInputHeading = screen.getByText(/User realtime input/i); | ||
expect(userInputHeading).toBeInTheDocument(); | ||
}); | ||
|
||
test("should be able to type", async () => { | ||
const textArea = screen.getByRole("textbox") as HTMLInputElement; | ||
fireEvent.change(textArea, { target: { value: "hello" } }); | ||
expect(textArea.value).toBe("hello"); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.