This repository has been archived on 2026-03-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

33 lines
714 B
TypeScript

import * as t from "..";
class A {}
class B {}
test("converts to typescript", () => {
expect(t.toTypescript(t.instanceOf(A))).toEqual("A");
});
test("can't convert to JSON Schema", () => {
expect(() => {
t.toJSONSchema("sure", t.instanceOf(class {}))
}).toThrow();
});
test("throws an error on anon classes", () => {
expect(() => {
return t.toTypescript(t.instanceOf(class {}));
}).toThrow();
});
test("accepts values that are an instance of the class", () => {
const check = t.instanceOf(A);
check.assert(new A());
});
test("rejects values that are not an instance of the class", () => {
const check = t.instanceOf(A);
expect(() => {
check.assert(new B());
}).toThrow();
});