From ffa1eeb73488b6a672d36b689cf233efa3b0eec0 Mon Sep 17 00:00:00 2001
From: 0x1eef <0x1eef@protonmail.com>
Date: Sat, 3 Aug 2024 05:01:20 -0300
Subject: [PATCH] TypeScript fixes
---
test/App.test.tsx | 11 +++++++----
test/ErrorRenderer.test.tsx | 3 ++-
test/ResponseRenderer.test.tsx | 4 +++-
tsconfig.json | 3 ---
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/test/App.test.tsx b/test/App.test.tsx
index 0e9cf90..6b0c5b5 100644
--- a/test/App.test.tsx
+++ b/test/App.test.tsx
@@ -6,18 +6,21 @@ import { getMessage } from "./mocks/chrome.i18n";
import { success, error, loading } from "./mocks/fetch";
describe("App.tsx", () => {
+ const globalChrome = global.chrome;
+ const globalFetch = global.fetch;
+
beforeEach(() => {
const chrome: any = { i18n: { getMessage } };
global.chrome = chrome;
});
afterEach(() => {
- global.chrome = undefined;
+ global.chrome = globalChrome;
});
describe("when the request is loading", () => {
beforeEach(() => { global.fetch = loading; });
- afterEach(() => { global.fetch = undefined; });
+ afterEach(() => { global.fetch = globalFetch; });
test("loading text is rendered", () => {
render();
@@ -27,7 +30,7 @@ describe("App.tsx", () => {
describe("when the request is a success", () => {
beforeEach(() => { global.fetch = success; });
- afterEach(() => { global.fetch = undefined; });
+ afterEach(() => { global.fetch = globalFetch; });
test("response is rendered", async () => {
await act(() => render());
@@ -37,7 +40,7 @@ describe("App.tsx", () => {
describe("when the request throws an error", () => {
beforeEach(() => { global.fetch = error; });
- afterEach(() => { global.fetch = undefined; });
+ afterEach(() => { global.fetch = globalFetch; });
test("error is rendered", async () => {
await act(() => render());
diff --git a/test/ErrorRenderer.test.tsx b/test/ErrorRenderer.test.tsx
index d530922..a2f7960 100644
--- a/test/ErrorRenderer.test.tsx
+++ b/test/ErrorRenderer.test.tsx
@@ -5,6 +5,7 @@ import { ErrorRenderer } from "~/components/ErrorRenderer";
import { getMessage } from "./mocks/chrome.i18n";
describe("ErrorRenderer.tsx", () => {
+ const globalChrome = global.chrome;
const error = new Error("This is an example error message");
beforeEach(() => {
@@ -14,7 +15,7 @@ describe("ErrorRenderer.tsx", () => {
});
afterEach(() => {
- global.chrome = undefined;
+ global.chrome = globalChrome;
});
test("an error is rendered", () => {
diff --git a/test/ResponseRenderer.test.tsx b/test/ResponseRenderer.test.tsx
index ee75f07..3f3d2a8 100644
--- a/test/ResponseRenderer.test.tsx
+++ b/test/ResponseRenderer.test.tsx
@@ -5,13 +5,15 @@ import { ResponseRenderer } from "~/components/ResponseRenderer";
import { getMessage } from "./mocks/chrome.i18n";
describe("ResponseRenderer.tsx", () => {
+ const globalChrome = global.chrome;
+
beforeEach(() => {
const chrome: any = { i18n: { getMessage } };
global.chrome = chrome;
});
afterEach(() => {
- global.chrome = undefined;
+ global.chrome = globalChrome;
});
const defaultResponse = {
diff --git a/tsconfig.json b/tsconfig.json
index fe67d0c..6c289f7 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,14 +1,11 @@
{
"compilerOptions": {
"strict": true,
- "strictNullChecks": false,
"module": "commonjs",
"target": "ES2020",
- "noImplicitAny": true,
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "react",
- "allowJs": true,
"lib": [ "ES2020", "DOM" ],
"baseUrl": "src/",
"paths": { "~/*": ["js/*"] },