Run eslint on test/

This commit is contained in:
0x1eef 2023-09-29 15:25:24 -03:00
parent e498c5b6e2
commit 7f15dceef7
4 changed files with 22 additions and 22 deletions

View file

@ -1,6 +1,6 @@
import React from "react";
import '@testing-library/jest-dom'
import { render, screen, act, waitFor } from "@testing-library/react";
import '@testing-library/jest-dom';
import { render, screen, act } from "@testing-library/react";
import { App } from "~/components/App";
import { getMessage } from "./mocks/chrome.i18n";
import { success, error, loading } from "./mocks/fetch";
@ -16,18 +16,18 @@ describe("App.tsx", () => {
});
describe("when the request is loading", () => {
beforeEach(() => { global.fetch = loading });
afterEach(() => { global.fetch = undefined });
beforeEach(() => { global.fetch = loading; });
afterEach(() => { global.fetch = undefined; });
test("loading text is rendered", () => {
render(<App/>);
expect(screen.getByText("Loading...")).toBeInTheDocument();
})
});
});
describe("when the request is a success", () => {
beforeEach(() => { global.fetch = success });
afterEach(() => { global.fetch = undefined });
beforeEach(() => { global.fetch = success; });
afterEach(() => { global.fetch = undefined; });
test("response is rendered", async () => {
await act(() => render(<App/>));
@ -36,8 +36,8 @@ describe("App.tsx", () => {
});
describe("when the request throws an error", () => {
beforeEach(() => { global.fetch = error });
afterEach(() => { global.fetch = undefined });
beforeEach(() => { global.fetch = error; });
afterEach(() => { global.fetch = undefined; });
test("error is rendered", async () => {
await act(() => render(<App/>));

View file

@ -1,5 +1,5 @@
import React from "react";
import '@testing-library/jest-dom'
import '@testing-library/jest-dom';
import { render, screen } from "@testing-library/react";
import { ErrorRenderer } from "~/components/ErrorRenderer";
import { getMessage } from "./mocks/chrome.i18n";

View file

@ -1,5 +1,5 @@
import React from "react";
import '@testing-library/jest-dom'
import '@testing-library/jest-dom';
import { render, screen } from "@testing-library/react";
import { ResponseRenderer } from "~/components/ResponseRenderer";
import { getMessage } from "./mocks/chrome.i18n";
@ -65,6 +65,6 @@ describe("ResponseRenderer.tsx", () => {
test("isTorExitNode is rendered as Yes", () => {
expect(screen.getByText("Tor exit node")).toBeInTheDocument();
expect(screen.getByText("Yes")).toBeInTheDocument();
})
});
});
});

View file

@ -11,7 +11,7 @@ export function success(_path: RequestInfo | URL, _options?: RequestInit) {
YourFuckingTorExit: false
})
)
))
));
return new Promise<any>((resolve) => {
resolve({ status: 200, json });
@ -21,8 +21,8 @@ export function success(_path: RequestInfo | URL, _options?: RequestInit) {
export function error(_path: RequestInfo | URL, _options?: RequestInit) {
return new Promise<any>(() => {
throw new Error("Request error");
})
};
});
}
export function loading(_path: RequestInfo | URL, _options?: RequestInit) {
return new Promise<any>(() => null);