From b46ece276e5397cd53680ab6881b720219f113d4 Mon Sep 17 00:00:00 2001 From: Shishant Biswas Date: Fri, 4 Sep 2026 20:38:06 +0530 Subject: [PATCH] add: test cases for `insertMany` and update `insertOne` for `id` check --- app/__test__/data/specs/Mutator.spec.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/__test__/data/specs/Mutator.spec.ts b/app/__test__/data/specs/Mutator.spec.ts index c4014c89..50bc810d 100644 --- a/app/__test__/data/specs/Mutator.spec.ts +++ b/app/__test__/data/specs/Mutator.spec.ts @@ -4,7 +4,7 @@ import { Entity, EntityManager } from "data/entities"; import { ManyToOneRelation, OneToOneRelation, - RelationField, + type RelationField, RelationMutator, } from "data/relations"; import { NumberField, TextField } from "data/fields"; @@ -41,6 +41,24 @@ describe("[data] Mutator (base)", async () => { // but expect additional fields to be present expect((res.data as any).not_fillable).toBeDefined(); + expect((res.data as any).id).toBeDefined(); + }); + + test("insertMany", async () => { + expect(em.mutator(entity).getValidatedData(payload, "create")).resolves.toEqual(payload); + const res = await em.mutator(entity).insertMany([ + { label: "item 1", count: 1 }, + { label: "item 2", count: 2 }, + { label: "item 3", count: 3 }, + { label: "item 4", count: 4 }, + ]); + + expect(res.data.length).toBe(4); + res.data.forEach((entry) => { + expect((entry as any).id).toBeDefined(); + expect((entry as any).label).toStartWith("item "); + expect(entry.count).toBeNumber(); + }); }); test("updateOne", async () => {