revert test case, refactor getPrimaryField in Entity
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
|
|||||||
import { PrimaryField } from "data/fields";
|
import { PrimaryField } from "data/fields";
|
||||||
|
|
||||||
describe("[data] PrimaryField", async () => {
|
describe("[data] PrimaryField", async () => {
|
||||||
const field = new PrimaryField("primary");
|
const field = new PrimaryField("primary", { fillable: false });
|
||||||
|
|
||||||
test("name", async () => {
|
test("name", async () => {
|
||||||
expect(field.name).toBe("primary");
|
expect(field.name).toBe("primary");
|
||||||
@@ -24,7 +24,7 @@ describe("[data] PrimaryField", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("isFillable", async () => {
|
test("isFillable", async () => {
|
||||||
expect(field.isFillable()).toBe(true);
|
expect(field.isFillable()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("isHidden", async () => {
|
test("isHidden", async () => {
|
||||||
@@ -36,7 +36,7 @@ describe("[data] PrimaryField", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("transformPersist/Retrieve", async () => {
|
test("transformPersist/Retrieve", async () => {
|
||||||
expect(field.transformPersist(1)).resolves.toBe(1);
|
expect(field.transformPersist(1)).rejects.toThrow();
|
||||||
expect(field.transformRetrieve(1)).toBe(1);
|
expect(field.transformRetrieve(1)).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ export class Entity<
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPrimaryField(): PrimaryField {
|
getPrimaryField(): PrimaryField {
|
||||||
return this.fields[0] as PrimaryField;
|
return this.fields.find((field) => field.type === "primary") as PrimaryField;
|
||||||
}
|
}
|
||||||
|
|
||||||
id(): PrimaryField {
|
id(): PrimaryField {
|
||||||
|
|||||||
Reference in New Issue
Block a user