updated test case for user defined primary key
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
import { Entity } from "data/entities";
|
import { Entity } from "data/entities";
|
||||||
import { NumberField, TextField } from "data/fields";
|
import { NumberField, TextField, PrimaryField } from "data/fields";
|
||||||
|
|
||||||
describe("[data] Entity", async () => {
|
describe("[data] Entity", async () => {
|
||||||
const entity = new Entity("test", [
|
const entity = new Entity("test", [
|
||||||
@@ -47,4 +47,16 @@ describe("[data] Entity", async () => {
|
|||||||
entity.addField(field);
|
entity.addField(field);
|
||||||
expect(entity.getField("new_field")).toBe(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
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user