mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-25 05:25:52 -07:00
add coverage
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
@@ -8,4 +8,13 @@ describe("gitea widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
});
|
||||
|
||||
it("splits issues and pull requests", () => {
|
||||
const result = widget.mappings.issues.map(
|
||||
Buffer.from(JSON.stringify([{ id: 1, pull_request: {} }, { id: 2 }, { id: 3 }])),
|
||||
);
|
||||
|
||||
expect(result.pulls.map((i) => i.id)).toEqual([1]);
|
||||
expect(result.issues.map((i) => i.id)).toEqual([2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
@@ -8,4 +8,12 @@ describe("miniflux widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
});
|
||||
|
||||
it("sums read and unread counters", () => {
|
||||
const result = widget.mappings.counters.map(
|
||||
Buffer.from(JSON.stringify({ reads: { 1: 2, 2: 3 }, unreads: { 1: 4, 2: 1 } })),
|
||||
);
|
||||
|
||||
expect(result).toEqual({ read: 5, unread: 5 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,4 +33,27 @@ describe("radarr widget config", () => {
|
||||
|
||||
expect(queue.map((entry) => entry.movieId)).toEqual([2, 1]);
|
||||
});
|
||||
|
||||
it("maps movie counts and titles", () => {
|
||||
const movies = widget.mappings.movie.map(
|
||||
Buffer.from(
|
||||
JSON.stringify([
|
||||
{ id: 1, title: "A", monitored: true, hasFile: false, isAvailable: true },
|
||||
{ id: 2, title: "B", monitored: true, hasFile: true },
|
||||
{ id: 3, title: "C", monitored: true, hasFile: false, isAvailable: false },
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
expect(movies).toEqual({
|
||||
wanted: 1,
|
||||
have: 1,
|
||||
missing: 2,
|
||||
all: [
|
||||
{ title: "A", id: 1 },
|
||||
{ title: "B", id: 2 },
|
||||
{ title: "C", id: 3 },
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
@@ -8,4 +8,12 @@ describe("unmanic widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
});
|
||||
|
||||
it("counts total and active workers", () => {
|
||||
const result = widget.mappings.workers.map(
|
||||
Buffer.from(JSON.stringify({ workers_status: [{ idle: true }, { idle: false }, { idle: false }] })),
|
||||
);
|
||||
|
||||
expect(result).toEqual({ total_workers: 3, active_workers: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user