mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-08 00:40:52 +08:00
chore: make lint pass for vitest tests
This commit is contained in:
@@ -65,5 +65,14 @@ export default defineConfig([
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// Vitest tests often intentionally place imports after `vi.mock(...)` to ensure
|
||||||
|
// modules under test see the mocked dependencies. `import/order` can't safely
|
||||||
|
// auto-fix those cases, so disable it for test files.
|
||||||
|
{
|
||||||
|
files: ["src/**/*.test.{js,jsx}", "src/**/*.spec.{js,jsx}"],
|
||||||
|
rules: {
|
||||||
|
"import/order": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
globalIgnores(["./config/", "./.venv/", "./.next/", "./site/"]),
|
globalIgnores(["./config/", "./.venv/", "./.next/", "./site/"]),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -53,12 +53,7 @@ describe("widgets/linkwarden/component", () => {
|
|||||||
useWidgetAPI.mockImplementation((_widget, endpoint) => {
|
useWidgetAPI.mockImplementation((_widget, endpoint) => {
|
||||||
if (endpoint === "collections") {
|
if (endpoint === "collections") {
|
||||||
return {
|
return {
|
||||||
data: [
|
data: [{ _count: { links: 2 } }, { _count: { links: 3 } }],
|
||||||
// eslint-disable-next-line no-underscore-dangle
|
|
||||||
{ _count: { links: 2 } },
|
|
||||||
// eslint-disable-next-line no-underscore-dangle
|
|
||||||
{ _count: { links: 3 } },
|
|
||||||
],
|
|
||||||
error: undefined,
|
error: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { describe, expect, it, vi } from "vitest";
|
|||||||
vi.mock("next/image", () => ({
|
vi.mock("next/image", () => ({
|
||||||
default: (props) => {
|
default: (props) => {
|
||||||
const { src, alt, objectFit, className, onError } = props;
|
const { src, alt, objectFit, className, onError } = props;
|
||||||
|
// This is a unit-test stub for next/image; using <img> is intentional here.
|
||||||
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
return <img alt={alt} src={src} data-object-fit={objectFit} className={className} onError={onError} />;
|
return <img alt={alt} src={src} data-object-fit={objectFit} className={className} onError={onError} />;
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user