mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-08 08:50:52 +08:00
test: add widget config tests (batch 1)
This commit is contained in:
12
src/widgets/adguard/widget.test.js
Normal file
12
src/widgets/adguard/widget.test.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("adguard widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.mappings?.stats?.endpoint).toBe("stats");
|
||||
});
|
||||
});
|
||||
13
src/widgets/apcups/widget.test.js
Normal file
13
src/widgets/apcups/widget.test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("apcups widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
// apcups talks TCP directly, so it does not use an `{url}/...` API template.
|
||||
expect(widget.api).toBeUndefined();
|
||||
});
|
||||
});
|
||||
12
src/widgets/audiobookshelf/widget.test.js
Normal file
12
src/widgets/audiobookshelf/widget.test.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("audiobookshelf widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.mappings?.libraries?.endpoint).toBe("libraries");
|
||||
});
|
||||
});
|
||||
13
src/widgets/authentik/widget.test.js
Normal file
13
src/widgets/authentik/widget.test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("authentik widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.api).toContain("/api/v3/");
|
||||
expect(widget.mappings?.users?.endpoint).toContain("core/users");
|
||||
});
|
||||
});
|
||||
13
src/widgets/backrest/widget.test.js
Normal file
13
src/widgets/backrest/widget.test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("backrest widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.api).toContain("/v1.Backrest/");
|
||||
expect(widget.mappings?.summary?.endpoint).toBe("GetSummaryDashboard");
|
||||
});
|
||||
});
|
||||
16
src/widgets/bazarr/widget.test.js
Normal file
16
src/widgets/bazarr/widget.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("bazarr widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.api).toContain("apikey={key}");
|
||||
|
||||
const moviesMapping = widget.mappings?.movies;
|
||||
expect(moviesMapping?.endpoint).toBe("movies");
|
||||
expect(moviesMapping?.map?.('{"total":123}')).toEqual({ total: 123 });
|
||||
});
|
||||
});
|
||||
12
src/widgets/calendar/widget.test.js
Normal file
12
src/widgets/calendar/widget.test.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("calendar widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.api).toBe("{url}");
|
||||
});
|
||||
});
|
||||
13
src/widgets/glances/widget.test.js
Normal file
13
src/widgets/glances/widget.test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("glances widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.allowedEndpoints?.test("3/quicklook")).toBe(true);
|
||||
expect(widget.allowedEndpoints?.test("unknown")).toBe(false);
|
||||
});
|
||||
});
|
||||
13
src/widgets/immich/widget.test.js
Normal file
13
src/widgets/immich/widget.test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("immich widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.api).toContain("/api/");
|
||||
expect(widget.mappings?.version?.endpoint).toBe("server-info/version");
|
||||
});
|
||||
});
|
||||
12
src/widgets/unraid/widget.test.js
Normal file
12
src/widgets/unraid/widget.test.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
import widget from "./widget";
|
||||
|
||||
describe("unraid widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
expect(widget.api).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user