fix(ui): fix tests under nodejs 18

This commit is contained in:
Łukasz Mierzwa
2022-04-26 08:36:16 +01:00
committed by Łukasz Mierzwa
parent f98d614a85
commit d0ee44243a
5 changed files with 6 additions and 77 deletions

65
ui/package-lock.json generated
View File

@@ -81,7 +81,6 @@
"eslint-plugin-jest": "26.1.5",
"eslint-plugin-prettier": "4.0.0",
"fetch-mock": "9.11.0",
"jest-canvas-mock": "2.3.1",
"prettier": "2.6.2",
"purgecss": "4.1.3",
"react-scripts": "5.0.1",
@@ -14985,12 +14984,6 @@
"node": ">=4"
}
},
"node_modules/cssfontparser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/cssfontparser/-/cssfontparser-1.2.1.tgz",
"integrity": "sha1-9AIvyPlwDGgCnVQghK+69CWj8+M=",
"dev": true
},
"node_modules/csshake": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/csshake/-/csshake-1.5.3.tgz",
@@ -20396,16 +20389,6 @@
}
}
},
"node_modules/jest-canvas-mock": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/jest-canvas-mock/-/jest-canvas-mock-2.3.1.tgz",
"integrity": "sha512-5FnSZPrX3Q2ZfsbYNE3wqKR3+XorN8qFzDzB5o0golWgt6EOX1+emBnpOc9IAQ+NXFj8Nzm3h7ZdE/9H0ylBcg==",
"dev": true,
"dependencies": {
"cssfontparser": "^1.2.1",
"moo-color": "^1.0.2"
}
},
"node_modules/jest-changed-files": {
"version": "27.5.1",
"resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-27.5.1.tgz",
@@ -23870,21 +23853,6 @@
"integrity": "sha512-I1mnb5xn4fO80BH9BLcF0yLypy2UKl+Cb01Fu0hJRkJjlCRtxZMWkTdAtDd5ZqCOxtCkhmRwyI57vWT+1iZ67w==",
"dev": true
},
"node_modules/moo-color": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/moo-color/-/moo-color-1.0.3.tgz",
"integrity": "sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==",
"dev": true,
"dependencies": {
"color-name": "^1.1.4"
}
},
"node_modules/moo-color/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
@@ -44418,12 +44386,6 @@
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
"dev": true
},
"cssfontparser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/cssfontparser/-/cssfontparser-1.2.1.tgz",
"integrity": "sha1-9AIvyPlwDGgCnVQghK+69CWj8+M=",
"dev": true
},
"csshake": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/csshake/-/csshake-1.5.3.tgz",
@@ -48562,16 +48524,6 @@
"jest-cli": "^27.5.1"
}
},
"jest-canvas-mock": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/jest-canvas-mock/-/jest-canvas-mock-2.3.1.tgz",
"integrity": "sha512-5FnSZPrX3Q2ZfsbYNE3wqKR3+XorN8qFzDzB5o0golWgt6EOX1+emBnpOc9IAQ+NXFj8Nzm3h7ZdE/9H0ylBcg==",
"dev": true,
"requires": {
"cssfontparser": "^1.2.1",
"moo-color": "^1.0.2"
}
},
"jest-changed-files": {
"version": "27.5.1",
"resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-27.5.1.tgz",
@@ -51223,23 +51175,6 @@
"integrity": "sha512-I1mnb5xn4fO80BH9BLcF0yLypy2UKl+Cb01Fu0hJRkJjlCRtxZMWkTdAtDd5ZqCOxtCkhmRwyI57vWT+1iZ67w==",
"dev": true
},
"moo-color": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/moo-color/-/moo-color-1.0.3.tgz",
"integrity": "sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==",
"dev": true,
"requires": {
"color-name": "^1.1.4"
},
"dependencies": {
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
}
}
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@@ -80,7 +80,6 @@
"eslint-plugin-jest": "26.1.5",
"eslint-plugin-prettier": "4.0.0",
"fetch-mock": "9.11.0",
"jest-canvas-mock": "2.3.1",
"prettier": "2.6.2",
"purgecss": "4.1.3",
"react-scripts": "5.0.1",

View File

@@ -42,10 +42,8 @@ afterEach(() => {
localStorage.setItem("themeConfig", "");
jest.restoreAllMocks();
window.history.pushState({}, "App", "/");
global.window.location = {
href: "http://localhost/",
search: "",
};
global.window.location.href = "http://localhost/";
global.window.location.search = "";
});
describe("<App />", () => {
@@ -125,7 +123,7 @@ describe("<App />", () => {
};
const event = new PopStateEvent("popstate");
window.onpopstate(event);
window.dispatchEvent(event);
expect(window.location.search).toBe("?q=bar");
});
@@ -137,7 +135,7 @@ describe("<App />", () => {
tree.unmount();
const event = new PopStateEvent("popstate");
window.onpopstate(event);
window.dispatchEvent(event);
});
it("populates silence from from 'm' query arg", () => {

View File

@@ -73,9 +73,9 @@ const App: FC<AppProps> = observer(({ defaultFilters, uiDefaults }) => {
);
useEffect(() => {
window.onpopstate = onPopState;
window.addEventListener("popstate", onPopState);
return () => {
window.onpopstate = () => {};
window.removeEventListener("popstate", onPopState);
};
}, [onPopState]);

View File

@@ -29,9 +29,6 @@ jest.mock("react-intersection-observer");
// https://github.com/airbnb/enzyme
Enzyme.configure({ adapter: new Adapter() });
// favico.js needs canvas
require("jest-canvas-mock");
// https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#new-deprecations
const reactDeprecationWarning =
/.*has been renamed, and is not recommended for use.*/;