Fix waitFor in some tests

This commit is contained in:
jwu-fisker
2021-01-07 16:21:42 -08:00
parent 116581c7dd
commit 30408840e9
2 changed files with 21 additions and 31 deletions

View File

@@ -13,8 +13,6 @@ const renderRoute = async (route) => {
const { container } = render(<App />);
if (screen.queryByText(LOADING_STATUS)) {
await waitForElementToBeRemoved(() => screen.getByText(LOADING_STATUS));
} else {
await waitFor(() => {});
}
return container;
};
@@ -24,48 +22,48 @@ describe("App", () => {
it("Route / unauthenticated", async () => {
setToken(null);
const container = await renderRoute("/");
expect(container).toMatchSnapshot();
expect(container.querySelector("h1").innerHTML).toEqual("Sign in");
expect(container).toMatchSnapshot();
cleanup();
});
it("Route /signup unauthenticated", async () => {
setToken(null);
const container = await renderRoute("/signup");
expect(container).toMatchSnapshot();
expect(container.querySelector("h1").innerHTML).toEqual("Sign up");
expect(container).toMatchSnapshot();
cleanup();
});
it("Route /home unauthenticated", async () => {
setToken(null);
const container = await renderRoute("/home");
expect(container).toMatchSnapshot();
expect(container.querySelector("h1").innerHTML).toEqual("Sign in");
expect(container).toMatchSnapshot();
cleanup();
});
it("Route / authenticated", async () => {
setToken(TEST_TOKEN);
const container = await renderRoute("/");
expect(container).toMatchSnapshot();
expect(container.querySelector("h1").innerHTML).toEqual("Upload file");
expect(container).toMatchSnapshot();
cleanup();
});
it("Route /signup authenticated", async () => {
setToken(TEST_TOKEN);
const container = await renderRoute("/signup");
expect(container).toMatchSnapshot();
expect(container.querySelector("h1").innerHTML).toEqual("Upload file");
expect(container).toMatchSnapshot();
cleanup();
});
it("Route /home authenticated", async () => {
setToken(TEST_TOKEN);
const container = await renderRoute("/home");
expect(container).toMatchSnapshot();
expect(container.querySelector("h1").innerHTML).toEqual("Upload file");
expect(container).toMatchSnapshot();
cleanup();
});