Run eslint on test/
This commit is contained in:
parent
e498c5b6e2
commit
7f15dceef7
4 changed files with 22 additions and 22 deletions
|
@ -1,13 +1,13 @@
|
|||
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";
|
||||
|
||||
describe("App.tsx", () => {
|
||||
beforeEach(() => {
|
||||
const chrome: any = {i18n: {getMessage}};
|
||||
const chrome: any = { i18n: { getMessage } };
|
||||
global.chrome = chrome;
|
||||
});
|
||||
|
||||
|
@ -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/>));
|
||||
|
|
|
@ -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";
|
||||
|
@ -8,7 +8,7 @@ describe("ErrorRenderer.tsx", () => {
|
|||
const error = new Error("This is an example error message");
|
||||
|
||||
beforeEach(() => {
|
||||
const chrome: any = {i18n: {getMessage}};
|
||||
const chrome: any = { i18n: { getMessage } };
|
||||
global.chrome = chrome;
|
||||
render(<ErrorRenderer error={error}/>);
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
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";
|
||||
|
||||
describe("ResponseRenderer.tsx", () => {
|
||||
beforeEach(() => {
|
||||
const chrome: any = {i18n: {getMessage}};
|
||||
const chrome: any = { i18n: { getMessage } };
|
||||
global.chrome = chrome;
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe("ResponseRenderer.tsx", () => {
|
|||
};
|
||||
|
||||
describe("when isTorExitNode is false", () => {
|
||||
const response = {...defaultResponse};
|
||||
const response = { ...defaultResponse };
|
||||
|
||||
beforeEach(() => {
|
||||
render(<ResponseRenderer response={response}/>);
|
||||
|
@ -56,7 +56,7 @@ describe("ResponseRenderer.tsx", () => {
|
|||
});
|
||||
|
||||
describe("when isTorExitNode is true", () => {
|
||||
const response = {...defaultResponse, isTorExitNode: true};
|
||||
const response = { ...defaultResponse, isTorExitNode: true };
|
||||
|
||||
beforeEach(() => {
|
||||
render(<ResponseRenderer response={response}/>);
|
||||
|
@ -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();
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {TServerResponse} from "~/lib/response";
|
||||
import { TServerResponse } from "~/lib/response";
|
||||
|
||||
export function success(_path: RequestInfo | URL, _options?: RequestInit) {
|
||||
const json = () => (
|
||||
|
@ -11,18 +11,18 @@ export function success(_path: RequestInfo | URL, _options?: RequestInit) {
|
|||
YourFuckingTorExit: false
|
||||
})
|
||||
)
|
||||
))
|
||||
));
|
||||
|
||||
return new Promise<any>((resolve) => {
|
||||
resolve({status: 200, json});
|
||||
resolve({ status: 200, json });
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue