27 lines
796 B
TypeScript
27 lines
796 B
TypeScript
import type { UUID } from "@fabric/core";
|
|
import { describe, expectTypeOf, test } from "@fabric/testing";
|
|
import type { PosixDate } from "../../core/index.ts";
|
|
import { Field } from "./fields/index.ts";
|
|
import { Model, type ModelToType } from "./model.ts";
|
|
|
|
describe("CreateModel", () => {
|
|
test("should create a model and it's interface type", () => {
|
|
const User = Model.aggregateFrom("User", {
|
|
name: Field.string(),
|
|
password: Field.string(),
|
|
phone: Field.string({ isOptional: true }),
|
|
});
|
|
type User = ModelToType<typeof User>;
|
|
|
|
expectTypeOf<User>().toEqualTypeOf<{
|
|
id: UUID;
|
|
streamId: UUID;
|
|
streamVersion: bigint;
|
|
name: string;
|
|
password: string;
|
|
phone: string | null;
|
|
deletedAt: PosixDate | null;
|
|
}>();
|
|
});
|
|
});
|