Skip to content

Commit 40b62f6

Browse files
committed
test: add tests
1 parent 2d7d0b0 commit 40b62f6

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

packages/openapi-code-generator/src/typescript/common/type-utils.spec.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import {describe, expect} from "@jest/globals"
2-
import {intersect, object, objectProperty, union} from "./type-utils"
2+
import {
3+
constStatement,
4+
intersect,
5+
object,
6+
objectProperty,
7+
union,
8+
} from "./type-utils"
39

410
describe("typescript/common/type-utils", () => {
511
describe("union", () => {
@@ -123,5 +129,33 @@ describe("typescript/common/type-utils", () => {
123129

124130
expect(actual).toBe('{\n"foo": string\n}')
125131
})
132+
133+
it("returns an object with multiple properties", () => {
134+
const property1 = objectProperty({
135+
name: "foo",
136+
type: "string",
137+
isReadonly: false,
138+
isRequired: true,
139+
})
140+
141+
const property2 = objectProperty({
142+
name: "bar",
143+
type: "number",
144+
isReadonly: false,
145+
isRequired: false,
146+
})
147+
148+
const actual = object(property1, property2)
149+
150+
expect(actual).toBe('{\n"foo": string,\n"bar"?: number\n}')
151+
})
152+
})
153+
154+
describe("constStatement", () => {
155+
it("returns a const statement ", () => {
156+
const actual = constStatement("MY_CONST", "z.number()")
157+
158+
expect(actual).toBe("const MY_CONST = z.number()")
159+
})
126160
})
127161
})

0 commit comments

Comments
 (0)