Skip to content

Commit

Permalink
fixing lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack committed Nov 22, 2024
1 parent eeb06b3 commit d2d2c6e
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions frontend/src/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { render, screen, fireEvent } from "@testing-library/react";
import App from "../App";
import WS from "jest-websocket-mock";

Expand Down Expand Up @@ -29,9 +29,7 @@ describe("Steptime view changes", () => {
})
);

const elements = await screen.findAllByRole("listitem", {
name: /CurrentStepTime/i,
});
const elements = await screen.findAllByTestId(/current-step-time-left/);

elements.forEach((element) => {
expect(element).toHaveStyle("border-color: green");
Expand All @@ -49,9 +47,7 @@ describe("Steptime view changes", () => {
})
);

const elements = await screen.findAllByRole("listitem", {
name: /CurrentStepTime/i,
});
const elements = await screen.findAllByTestId(/current-step-time-left/);

elements.forEach((element) => {
expect(element).toHaveStyle("border-color: yellow");
Expand All @@ -69,9 +65,7 @@ describe("Steptime view changes", () => {
})
);

const elements = await screen.findAllByRole("listitem", {
name: /CurrentStepTime/i,
});
const elements = await screen.findAllByTestId(/current-step-time-left/);

elements.forEach((element) => {
expect(element).toHaveStyle("border-color: red");
Expand Down Expand Up @@ -132,9 +126,9 @@ describe("WebSocket in App Component", () => {
})
);

await waitFor(() =>
expect(consoleLogSpy).toHaveBeenCalledWith("Data received from backend")
);
await new Promise((resolve) => setTimeout(resolve, 100));

expect(consoleLogSpy).toHaveBeenCalledWith("Data received from backend");

consoleLogSpy.mockRestore();
});
Expand All @@ -144,9 +138,7 @@ describe("WebSocket in App Component", () => {

await server.connected;

await waitFor(() => {
expect(server).toReceiveMessage("Websocket Connected to React");
});
expect(server).toReceiveMessage("Websocket Connected to React");
});

test("User is notified on WS Close", async () => {
Expand All @@ -158,11 +150,9 @@ describe("WebSocket in App Component", () => {

server.close();

await waitFor(() =>
expect(consoleLogSpy).toHaveBeenCalledWith(
"WebSocket connection closed: ",
expect.any(Object)
)
expect(consoleLogSpy).toHaveBeenCalledWith(
"WebSocket connection closed: ",
expect.any(Object)
);

consoleLogSpy.mockRestore();
Expand Down

0 comments on commit d2d2c6e

Please sign in to comment.