From c09a186f8c60c1516be04866a2bcf60e7d361afe Mon Sep 17 00:00:00 2001 From: Shishant Biswas Date: Wed, 22 Apr 2026 11:21:57 +0530 Subject: [PATCH] updated test case for user defined primary key --- app/__test__/data/specs/Entity.spec.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/__test__/data/specs/Entity.spec.ts b/app/__test__/data/specs/Entity.spec.ts index 220b6880..75b6e8c5 100644 --- a/app/__test__/data/specs/Entity.spec.ts +++ b/app/__test__/data/specs/Entity.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; import { Entity } from "data/entities"; -import { NumberField, TextField } from "data/fields"; +import { NumberField, TextField, PrimaryField } from "data/fields"; describe("[data] Entity", async () => { const entity = new Entity("test", [ @@ -47,4 +47,16 @@ describe("[data] Entity", async () => { entity.addField(field); expect(entity.getField("new_field")).toBe(field); }); + + test("custom primary", async () => { + const customPrimaryEntity = new Entity("custom", [ + new PrimaryField("custom", { format: "uuid" }), + new TextField("name"), + ]); + + expect(customPrimaryEntity.getPrimaryField().name).toEqual("custom"); + expect(customPrimaryEntity.getPrimaryField().format).toEqual("uuid"); + expect(customPrimaryEntity.getSelect()).toEqual(["custom", "name"]); + expect(customPrimaryEntity.getField("id")).toBeUndefined(); // no auto id + }); });