Core/tests/errors.test.ts

25 lines
778 B
TypeScript
Raw Normal View History

import {describe, expect, it} from "vitest";
import {InvalidTypeValueError, TypeError} from "../src/errors";
import {s} from "../src/library";
describe("errors", () => {
it("tests type error", () => {
2025-06-23 20:31:34 +02:00
expect(new TypeError(s.property.string().type).message).toBe(
"Error in type StringType",
);
expect(new TypeError(s.property.string().type, "test").message).toBe(
"Error in type StringType: test",
);
});
it("tests invalid type value error", () => {
2025-06-23 20:31:34 +02:00
expect(
new InvalidTypeValueError(s.property.decimal().type, ["value"]).message,
).toBe('Error in type DecimalType: ["value"] is an invalid value');
expect(
new InvalidTypeValueError(s.property.decimal().type, ["value"], "test")
.message,
).toBe("Error in type DecimalType: test");
});
});