Files
outline/server/queues/tasks/base/BaseTask.test.ts
T
Tom Moor 4e1d95e59b fix: Store one logo per OAuth client and return a distinct metadata document error
- Logos are stored per client, so a file is only deleted when its own
  client stops using it. This removes the reference count and its race.
- A metadata document that cannot be fetched or is invalid now returns
  invalid_client_metadata with the reason, not a 404. Network errors
  are only logged.
- Move scheduleOptional to BaseTask so that any task can use it.
2026-10-12 00:16:56 -04:00

32 lines
886 B
TypeScript

import type { Job } from "bull";
import { BaseTask } from "./BaseTask";
class TestTask extends BaseTask<{ id: string }> {
public async perform() {
// Not used in these tests
}
}
describe("BaseTask", () => {
describe("scheduleOptional", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("should return the job when it is scheduled", async () => {
const task = new TestTask();
const job = { id: "job" } as Job;
vi.spyOn(task, "schedule").mockResolvedValue(job);
await expect(task.scheduleOptional({ id: "1" })).resolves.toBe(job);
});
it("should not throw when the job cannot be scheduled", async () => {
const task = new TestTask();
vi.spyOn(task, "schedule").mockRejectedValue(new Error("Queue error"));
await expect(task.scheduleOptional({ id: "1" })).resolves.toBeUndefined();
});
});
});