Core/tests/errors.test.ts
Madeorsk a1691708ae
All checks were successful
/ test (push) Successful in 38s
Apply prettier.
2025-06-23 20:31:34 +02:00

24 lines
778 B
TypeScript

import {describe, expect, it} from "vitest";
import {InvalidTypeValueError, TypeError} from "../src/errors";
import {s} from "../src/library";
describe("errors", () => {
it("tests type error", () => {
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", () => {
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");
});
});