Fix waitFor in some tests
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user