TypeScript fixes
This commit is contained in:
parent
c2e5925ced
commit
ffa1eeb734
4 changed files with 12 additions and 9 deletions
|
@ -6,18 +6,21 @@ import { getMessage } from "./mocks/chrome.i18n";
|
||||||
import { success, error, loading } from "./mocks/fetch";
|
import { success, error, loading } from "./mocks/fetch";
|
||||||
|
|
||||||
describe("App.tsx", () => {
|
describe("App.tsx", () => {
|
||||||
|
const globalChrome = global.chrome;
|
||||||
|
const globalFetch = global.fetch;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const chrome: any = { i18n: { getMessage } };
|
const chrome: any = { i18n: { getMessage } };
|
||||||
global.chrome = chrome;
|
global.chrome = chrome;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
global.chrome = undefined;
|
global.chrome = globalChrome;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when the request is loading", () => {
|
describe("when the request is loading", () => {
|
||||||
beforeEach(() => { global.fetch = loading; });
|
beforeEach(() => { global.fetch = loading; });
|
||||||
afterEach(() => { global.fetch = undefined; });
|
afterEach(() => { global.fetch = globalFetch; });
|
||||||
|
|
||||||
test("loading text is rendered", () => {
|
test("loading text is rendered", () => {
|
||||||
render(<App/>);
|
render(<App/>);
|
||||||
|
@ -27,7 +30,7 @@ describe("App.tsx", () => {
|
||||||
|
|
||||||
describe("when the request is a success", () => {
|
describe("when the request is a success", () => {
|
||||||
beforeEach(() => { global.fetch = success; });
|
beforeEach(() => { global.fetch = success; });
|
||||||
afterEach(() => { global.fetch = undefined; });
|
afterEach(() => { global.fetch = globalFetch; });
|
||||||
|
|
||||||
test("response is rendered", async () => {
|
test("response is rendered", async () => {
|
||||||
await act(() => render(<App/>));
|
await act(() => render(<App/>));
|
||||||
|
@ -37,7 +40,7 @@ describe("App.tsx", () => {
|
||||||
|
|
||||||
describe("when the request throws an error", () => {
|
describe("when the request throws an error", () => {
|
||||||
beforeEach(() => { global.fetch = error; });
|
beforeEach(() => { global.fetch = error; });
|
||||||
afterEach(() => { global.fetch = undefined; });
|
afterEach(() => { global.fetch = globalFetch; });
|
||||||
|
|
||||||
test("error is rendered", async () => {
|
test("error is rendered", async () => {
|
||||||
await act(() => render(<App/>));
|
await act(() => render(<App/>));
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { ErrorRenderer } from "~/components/ErrorRenderer";
|
||||||
import { getMessage } from "./mocks/chrome.i18n";
|
import { getMessage } from "./mocks/chrome.i18n";
|
||||||
|
|
||||||
describe("ErrorRenderer.tsx", () => {
|
describe("ErrorRenderer.tsx", () => {
|
||||||
|
const globalChrome = global.chrome;
|
||||||
const error = new Error("This is an example error message");
|
const error = new Error("This is an example error message");
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -14,7 +15,7 @@ describe("ErrorRenderer.tsx", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
global.chrome = undefined;
|
global.chrome = globalChrome;
|
||||||
});
|
});
|
||||||
|
|
||||||
test("an error is rendered", () => {
|
test("an error is rendered", () => {
|
||||||
|
|
|
@ -5,13 +5,15 @@ import { ResponseRenderer } from "~/components/ResponseRenderer";
|
||||||
import { getMessage } from "./mocks/chrome.i18n";
|
import { getMessage } from "./mocks/chrome.i18n";
|
||||||
|
|
||||||
describe("ResponseRenderer.tsx", () => {
|
describe("ResponseRenderer.tsx", () => {
|
||||||
|
const globalChrome = global.chrome;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const chrome: any = { i18n: { getMessage } };
|
const chrome: any = { i18n: { getMessage } };
|
||||||
global.chrome = chrome;
|
global.chrome = chrome;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
global.chrome = undefined;
|
global.chrome = globalChrome;
|
||||||
});
|
});
|
||||||
|
|
||||||
const defaultResponse = {
|
const defaultResponse = {
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"strictNullChecks": false,
|
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"noImplicitAny": true,
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"allowJs": true,
|
|
||||||
"lib": [ "ES2020", "DOM" ],
|
"lib": [ "ES2020", "DOM" ],
|
||||||
"baseUrl": "src/",
|
"baseUrl": "src/",
|
||||||
"paths": { "~/*": ["js/*"] },
|
"paths": { "~/*": ["js/*"] },
|
||||||
|
|
Loading…
Reference in a new issue