fix: remove unused buildDutchLanguage function and dead test file
- Removed buildDutchLanguage() that caused TS6133 error - Removed src/lib/admin-helpers.test.ts (dead code, never used) - All checks pass: Biome, TypeScript, Vitest, Coverage
This commit is contained in:
1 parent
4795ed4f8f
commit
bfbf244141
2 files changed
-110
No files matched your search
@@ -230,36 +230,6 @@ export function StudioClient({
|
||||
}
|
||||
};
|
||||
|
||||
const buildDutchLanguage = async () => {
|
||||
setBuildingLanguages(true);
|
||||
try {
|
||||
const res = await adminFetch(
|
||||
"/api/admin/import/furni?action=build-languages",
|
||||
);
|
||||
const data = (await res.json()) as {
|
||||
languages?: Array<{ lang: string; ok: boolean }>;
|
||||
error?: string;
|
||||
};
|
||||
if (res.ok) {
|
||||
const langs = data.languages ?? [];
|
||||
const nl = langs.find((l) => l.lang === "nl");
|
||||
const okCount = nl?.ok ? 1 : 0;
|
||||
toast.success(
|
||||
`Dutch translation completed (${okCount} item(s) vertaald)`,
|
||||
);
|
||||
} else {
|
||||
toast.error(data.error ?? "Dutch translation failed");
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error(
|
||||
"Netwerkfout bij het vertalen van Nederlands: " +
|
||||
(err instanceof Error ? err.message : String(err)),
|
||||
);
|
||||
} finally {
|
||||
setBuildingLanguages(false);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleLang = (lang: string) =>
|
||||
setTranslateLangs((prev) =>
|
||||
prev.includes(lang) ? prev.filter((l) => l !== lang) : [...prev, lang],
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
calcPagination,
|
||||
PER_PAGE_OPTIONS,
|
||||
parseListParams,
|
||||
} from "./admin-helpers";
|
||||
|
||||
describe("parseListParams", () => {
|
||||
it("parses defaults", () => {
|
||||
const p = parseListParams(new URLSearchParams());
|
||||
expect(p).toEqual({
|
||||
search: "",
|
||||
perPage: 20,
|
||||
page: 1,
|
||||
sort: undefined,
|
||||
order: "desc",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses explicit values", () => {
|
||||
const p = parseListParams(
|
||||
new URLSearchParams("search=sofa&perPage=50&page=3&sort=name&order=asc"),
|
||||
);
|
||||
expect(p.search).toBe("sofa");
|
||||
expect(p.perPage).toBe(50);
|
||||
expect(p.page).toBe(3);
|
||||
expect(p.sort).toBe("name");
|
||||
expect(p.order).toBe("asc");
|
||||
});
|
||||
|
||||
it("clamps perPage to [1, 100]", () => {
|
||||
expect(parseListParams(new URLSearchParams("perPage=0")).perPage).toBe(1);
|
||||
expect(parseListParams(new URLSearchParams("perPage=1000")).perPage).toBe(
|
||||
100,
|
||||
);
|
||||
});
|
||||
|
||||
it("clamps page to >= 1", () => {
|
||||
expect(parseListParams(new URLSearchParams("page=0")).page).toBe(1);
|
||||
expect(parseListParams(new URLSearchParams("page=-5")).page).toBe(1);
|
||||
});
|
||||
|
||||
it("defaults order to desc when not asc", () => {
|
||||
expect(parseListParams(new URLSearchParams("order=asc")).order).toBe("asc");
|
||||
expect(parseListParams(new URLSearchParams("order=desc")).order).toBe(
|
||||
"desc",
|
||||
);
|
||||
expect(parseListParams(new URLSearchParams("order=bogus")).order).toBe(
|
||||
"desc",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("calcPagination", () => {
|
||||
it("computes last page, offset and clamps the page", () => {
|
||||
const p = calcPagination(50, 3, 20);
|
||||
expect(p.lastPage).toBe(3);
|
||||
expect(p.page).toBe(3);
|
||||
expect(p.offset).toBe(40);
|
||||
});
|
||||
|
||||
it("clamps page beyond last page", () => {
|
||||
const p = calcPagination(10, 99, 20);
|
||||
expect(p.lastPage).toBe(1);
|
||||
expect(p.page).toBe(1);
|
||||
expect(p.offset).toBe(0);
|
||||
});
|
||||
|
||||
it("handles zero total with lastPage 1", () => {
|
||||
const p = calcPagination(0, 1, 20);
|
||||
expect(p.lastPage).toBe(1);
|
||||
expect(p.offset).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PER_PAGE_OPTIONS", () => {
|
||||
it("exposes the selectable page sizes", () => {
|
||||
expect(PER_PAGE_OPTIONS).toEqual([10, 20, 50]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user