File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed
packages/openapi-code-generator/src/typescript/common Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change 11import { 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
410describe ( "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} )
You can’t perform that action at this time.
0 commit comments