Add local background removal and mask tools
This commit is contained in:
37
src/tools/background-remover/run.test.ts
Normal file
37
src/tools/background-remover/run.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { backgroundRemoverPlugin } from "./index";
|
||||
import { runBackgroundRemover } from "./run";
|
||||
import type { BackgroundRemoverOptions } from "./remove";
|
||||
import type { ToolContext } from "../../core/plugins/plugin-types";
|
||||
|
||||
const mockContext: ToolContext = {
|
||||
signal: new AbortController().signal,
|
||||
reportProgress: vi.fn(),
|
||||
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
|
||||
};
|
||||
|
||||
const options: BackgroundRemoverOptions = { quality: "small", useGpu: true };
|
||||
|
||||
describe("Background Remover Plugin", () => {
|
||||
it("should have correct manifest", () => {
|
||||
expect(backgroundRemoverPlugin.manifest.id).toBe("background-remover");
|
||||
expect(backgroundRemoverPlugin.manifest.category).toBe("image");
|
||||
expect(backgroundRemoverPlugin.manifest.input.type).toBe("files");
|
||||
expect(backgroundRemoverPlugin.manifest.output.type).toBe("files");
|
||||
});
|
||||
|
||||
it("should run in a worker with wasm capability", () => {
|
||||
expect(backgroundRemoverPlugin.capabilities?.worker).toBe(true);
|
||||
expect(backgroundRemoverPlugin.capabilities?.persistentWorker).toBe(true);
|
||||
expect(backgroundRemoverPlugin.capabilities?.wasm).toBe(true);
|
||||
expect(backgroundRemoverPlugin.capabilities?.customUi).toBe(true);
|
||||
expect(backgroundRemoverPlugin.worker).toBeDefined();
|
||||
expect(backgroundRemoverPlugin.customUi).toBeDefined();
|
||||
});
|
||||
|
||||
it("should throw if no image is provided", async () => {
|
||||
await expect(
|
||||
runBackgroundRemover({ files: [] }, options, mockContext)
|
||||
).rejects.toThrow("No image provided.");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user