feat: expose and display duplicates
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import { handleGetDupes } from "../../app/api/assets/[id]/dupes/handlers";
|
||||
|
||||
describe("handleGetDupes", () => {
|
||||
test("returns empty list when hash is missing", async () => {
|
||||
let call = 0;
|
||||
const db = async () => {
|
||||
call += 1;
|
||||
return [] as unknown[];
|
||||
};
|
||||
|
||||
const result = await handleGetDupes({
|
||||
params: { id: "00000000-0000-0000-0000-000000000000" },
|
||||
db,
|
||||
});
|
||||
expect(result.status).toBe(200);
|
||||
expect(result.body).toEqual({ items: [] });
|
||||
expect(call).toBe(1);
|
||||
});
|
||||
|
||||
test("returns dupes excluding the asset id", async () => {
|
||||
const calls: unknown[] = [];
|
||||
const db = async () => {
|
||||
calls.push(true);
|
||||
if (calls.length === 1) {
|
||||
return [{ bucket: "photos", sha256: "hash" }];
|
||||
}
|
||||
return [
|
||||
{
|
||||
id: "11111111-1111-1111-1111-111111111111",
|
||||
media_type: "image",
|
||||
status: "ready",
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const result = await handleGetDupes({
|
||||
params: { id: "00000000-0000-0000-0000-000000000000" },
|
||||
db,
|
||||
});
|
||||
expect(result.status).toBe(200);
|
||||
expect(result.body).toEqual({
|
||||
items: [
|
||||
{
|
||||
id: "11111111-1111-1111-1111-111111111111",
|
||||
media_type: "image",
|
||||
status: "ready",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(calls.length).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user