2025-03-30 11:33:22 +02:00
|
|
|
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",
|
|
|
|
);
|
2025-03-30 11:33:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
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");
|
2025-03-30 11:33:22 +02:00
|
|
|
});
|
|
|
|
});
|