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

35 lines
746 B
TypeScript

import * as t from "..";
test("converts to typescript", () => {
expect(t.toTypescript(t.never)).toEqual("never");
});
test("can't convert to JSON schema by default", () => {
expect(() => {
t.toJSONSchema("huh", t.never);
}).toThrow();
});
test("converts to JSON Schema if errorOnNever is false", () => {
expect(t.toJSONSchema("huh", t.never, {
errorOnNever: false,
})).toEqual({
$schema: t.JSON_SCHEMA_VERSION,
title: "huh",
allOf: [ { type: "string" }, { type: "number" } ],
});
});
// what a test.
test("accepts nothing", () => {
expect(() => {
t.never.assert(5);
}).toThrow();
expect(() => {
t.never.assert("five");
}).toThrow();
expect(() => {
t.never.assert({});
}).toThrow();
});