forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliterals.test.ts
37 lines (31 loc) · 952 Bytes
/
literals.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import assert from "assert";
import { describe, it } from "vitest";
import { emitSchema } from "./utils.js";
describe("literals", () => {
it("handles booleans", async () => {
const schemas = await emitSchema(`
model Test {
a: true,
b: false
}
`);
assert.deepStrictEqual(schemas["Test.json"].properties.a, { type: "boolean", const: true });
assert.deepStrictEqual(schemas["Test.json"].properties.b, { type: "boolean", const: false });
});
it("handles strings", async () => {
const schemas = await emitSchema(`
model Test {
a: "hi",
}
`);
assert.deepStrictEqual(schemas["Test.json"].properties.a, { type: "string", const: "hi" });
});
it("handles numbers", async () => {
const schemas = await emitSchema(`
model Test {
a: 1,
}
`);
assert.deepStrictEqual(schemas["Test.json"].properties.a, { type: "number", const: 1 });
});
});