Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
meetqy committed Nov 1, 2023
1 parent 47eb444 commit 4c59a56
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions packages/api/test/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,6 @@ describe("image module", () => {
});
expect(res.data).toHaveLength(24);
expect(res.nextCursor).toEqual(`/path/to/image0.jpg`);

const res2 = await caller.image.find({
limit: 24,
cursor: res.nextCursor,
});
expect(res2.data).toHaveLength(1);
expect(res2.nextCursor).toEqual(undefined);
});

it("includes tags, colors, folders", async () => {
Expand Down Expand Up @@ -768,62 +761,12 @@ describe("image module", () => {
});
expect(res.data).toHaveLength(24);
expect(res.nextCursor).toEqual(`/path/to/image0.jpg`);

const res2 = await caller.image.findByFolderId({
id: folder.id,
limit: 24,
cursor: res.nextCursor,
});
expect(res2.data).toHaveLength(1);
expect(res2.nextCursor).toEqual(undefined);
});

it("find image by folder password", async () => {
const folder = await caller.folder.upsert({
name: "folder",
id: "123",
password: "123456",
show: true,
});

for (let i = 0; i < 5; i++) {
await caller.image.upsert({
path: `/path/to/image${i}.jpg`,
name: `image${i}.jpg`,
size: 1024,
ext: "jpg",
width: 800,
height: 600,
mtime: new Date(),
folders: {
connect: ["123"],
},
});
}

await expect(() =>
caller.image.findByFolderId({
id: folder.id,
limit: 24,
orderBy: { name: "desc" },
}),
).rejects.toThrowError("无权限访问该文件夹");

const res2 = await caller.image.findByFolderId({
id: folder.id,
password: "123456",
limit: 24,
orderBy: { name: "desc" },
});

expect(res2.data).toHaveLength(5);
});

it("find image but is'not in trash folder.", async () => {
const folder = await caller.folder.upsert({
name: "folder",
id: "123",
password: "123456",
show: true,
});

Expand All @@ -845,7 +788,6 @@ describe("image module", () => {

const res = await caller.image.findByFolderId({
id: folder.id,
password: "123456",
limit: 24,
orderBy: { name: "desc" },
});
Expand Down

0 comments on commit 4c59a56

Please sign in to comment.