fix: Move collection index validation logic to a context assert function (#2116)
* Abstract validation logic for readability * Add index validation in collections.move * Add tests
This commit is contained in:
@ -162,6 +162,15 @@ describe("#collections.move", () => {
|
||||
expect(body.success).toBe(true);
|
||||
});
|
||||
|
||||
it("should return error when index is not valid", async () => {
|
||||
const { admin, collection } = await seed();
|
||||
const res = await server.post("/api/collections.move", {
|
||||
body: { token: admin.getJwtToken(), id: collection.id, index: "يونيكود" },
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(400);
|
||||
});
|
||||
|
||||
it("if index collision occurs, should updated index of other collection", async () => {
|
||||
const { user, admin, collection } = await seed();
|
||||
const createdCollectionResponse = await server.post(
|
||||
@ -1019,6 +1028,14 @@ describe("#collections.create", () => {
|
||||
expect(body.policies[0].abilities.export).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should error when index is invalid", async () => {
|
||||
const user = await buildUser();
|
||||
const res = await server.post("/api/collections.create", {
|
||||
body: { token: user.getJwtToken(), name: "Test", index: "يونيكود" },
|
||||
});
|
||||
expect(res.status).toEqual(400);
|
||||
});
|
||||
|
||||
it("should allow setting sharing to false", async () => {
|
||||
const { user } = await seed();
|
||||
const res = await server.post("/api/collections.create", {
|
||||
|
Reference in New Issue
Block a user