mirror of
https://github.com/outline/outline.git
synced 2026-11-29 00:29:36 +03:00
- 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.
32 lines
886 B
TypeScript
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();
|
|
});
|
|
});
|
|
});
|