Skip to content

Commit 148e244

Browse files
committed
fix: tests
1 parent 86edb5f commit 148e244

5 files changed

Lines changed: 92 additions & 124 deletions

File tree

packages/openapi-code-generator/src/typescript/common/import-builder.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("typescript/common/import-builder", () => {
2323
builder.addSingle("Cat", "./models.ts", false)
2424
builder.addSingle("Dog", "./models.ts", false)
2525

26-
expect(builder.toString()).toBe("import {Cat, Dog} from './models'")
26+
expect(builder.toString()).toBe("import {Cat, Dog} from './models.ts'")
2727
})
2828

2929
it("can import a whole module, and individual exports", () => {
@@ -42,31 +42,31 @@ describe("typescript/common/import-builder", () => {
4242

4343
builder.addSingle("Cat", "./foo/models.ts", false)
4444

45-
expect(builder.toString()).toBe("import {Cat} from './models'")
45+
expect(builder.toString()).toBe("import {Cat} from './models.ts'")
4646
})
4747

4848
it("parent directory", () => {
4949
const builder = new ImportBuilder({filename: "./foo/example.ts"})
5050

5151
builder.addSingle("Cat", "./models.ts", false)
5252

53-
expect(builder.toString()).toBe("import {Cat} from '../models'")
53+
expect(builder.toString()).toBe("import {Cat} from '../models.ts'")
5454
})
5555

5656
it("child directory", () => {
5757
const builder = new ImportBuilder({filename: "./example.ts"})
5858

5959
builder.addSingle("Cat", "./foo/models.ts", false)
6060

61-
expect(builder.toString()).toBe("import {Cat} from './foo/models'")
61+
expect(builder.toString()).toBe("import {Cat} from './foo/models.ts'")
6262
})
6363

6464
it("sibling directory", () => {
6565
const builder = new ImportBuilder({filename: "./foo/example.ts"})
6666

6767
builder.addSingle("Cat", "./bar/models.ts", false)
6868

69-
expect(builder.toString()).toBe("import {Cat} from '../bar/models'")
69+
expect(builder.toString()).toBe("import {Cat} from '../bar/models.ts'")
7070
})
7171
})
7272

@@ -77,7 +77,9 @@ describe("typescript/common/import-builder", () => {
7777
builder.addSingle("Cat", "./models.ts", false)
7878
builder.addSingle("Dog", "./models.ts", true)
7979

80-
expect(builder.toString()).toBe("import {Cat, type Dog} from './models'")
80+
expect(builder.toString()).toBe(
81+
"import {Cat, type Dog} from './models.ts'",
82+
)
8183
})
8284

8385
it("formats all-type named imports as 'import type {A, B}'", () => {
@@ -146,7 +148,7 @@ describe("typescript/common/import-builder", () => {
146148
expect(builder.toString(code)).toBe(
147149
[
148150
"import Lodash from 'lodash'",
149-
"import {Cat, type Dog} from './models'",
151+
"import {Cat, type Dog} from './models.ts'",
150152
].join("\n"),
151153
)
152154
})

packages/openapi-code-generator/src/typescript/common/schema-builders/joi-schema-builder.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe.each(testVersions)(
4242
const {code, schemas} = await getActual("components/schemas/SimpleObject")
4343

4444
expect(code).toMatchInlineSnapshot(`
45-
"import { s_SimpleObject } from "./unit-test.schemas"
45+
"import { s_SimpleObject } from "./unit-test.schemas.ts"
4646
4747
const x = s_SimpleObject.required()"
4848
`)
@@ -73,7 +73,7 @@ describe.each(testVersions)(
7373
)
7474

7575
expect(code).toMatchInlineSnapshot(`
76-
"import { s_ObjectWithComplexProperties } from "./unit-test.schemas"
76+
"import { s_ObjectWithComplexProperties } from "./unit-test.schemas.ts"
7777
7878
const x = s_ObjectWithComplexProperties.required()"
7979
`)
@@ -126,7 +126,7 @@ describe.each(testVersions)(
126126
const {code, schemas} = await getActual("components/schemas/OneOf")
127127

128128
expect(code).toMatchInlineSnapshot(`
129-
"import { s_OneOf } from "./unit-test.schemas"
129+
"import { s_OneOf } from "./unit-test.schemas.ts"
130130
131131
const x = s_OneOf.required()"
132132
`)
@@ -154,7 +154,7 @@ describe.each(testVersions)(
154154
const {code, schemas} = await getActual("components/schemas/AnyOf")
155155

156156
expect(code).toMatchInlineSnapshot(`
157-
"import { s_AnyOf } from "./unit-test.schemas"
157+
"import { s_AnyOf } from "./unit-test.schemas.ts"
158158
159159
const x = s_AnyOf.required()"
160160
`)
@@ -174,7 +174,7 @@ describe.each(testVersions)(
174174
const {code, schemas} = await getActual("components/schemas/AllOf")
175175

176176
expect(code).toMatchInlineSnapshot(`
177-
"import { s_AllOf } from "./unit-test.schemas"
177+
"import { s_AllOf } from "./unit-test.schemas.ts"
178178
179179
const x = s_AllOf.required()"
180180
`)
@@ -207,7 +207,7 @@ describe.each(testVersions)(
207207
const {code, schemas} = await getActual("components/schemas/Recursive")
208208

209209
expect(code).toMatchInlineSnapshot(`
210-
"import { s_Recursive } from "./unit-test.schemas"
210+
"import { s_Recursive } from "./unit-test.schemas.ts"
211211
212212
const x = joi.link("#s_Recursive.required()")"
213213
`)
@@ -228,7 +228,7 @@ describe.each(testVersions)(
228228
const {code, schemas} = await getActual("components/schemas/Ordering")
229229

230230
expect(code).toMatchInlineSnapshot(`
231-
"import { s_Ordering } from "./unit-test.schemas"
231+
"import { s_Ordering } from "./unit-test.schemas.ts"
232232
233233
const x = s_Ordering.required()"
234234
`)
@@ -266,7 +266,7 @@ describe.each(testVersions)(
266266
const {code, schemas} = await getActual("components/schemas/Enums")
267267

268268
expect(code).toMatchInlineSnapshot(`
269-
"import { s_Enums } from "./unit-test.schemas"
269+
"import { s_Enums } from "./unit-test.schemas.ts"
270270
271271
const x = s_Enums.required()"
272272
`)
@@ -293,7 +293,7 @@ describe.each(testVersions)(
293293
)
294294

295295
expect(code).toMatchInlineSnapshot(`
296-
"import { s_AdditionalPropertiesBool } from "./unit-test.schemas"
296+
"import { s_AdditionalPropertiesBool } from "./unit-test.schemas.ts"
297297
298298
const x = s_AdditionalPropertiesBool.required()"
299299
`)
@@ -315,7 +315,7 @@ describe.each(testVersions)(
315315
)
316316

317317
expect(code).toMatchInlineSnapshot(`
318-
"import { s_AdditionalPropertiesUnknownEmptySchema } from "./unit-test.schemas"
318+
"import { s_AdditionalPropertiesUnknownEmptySchema } from "./unit-test.schemas.ts"
319319
320320
const x = s_AdditionalPropertiesUnknownEmptySchema.required()"
321321
`)
@@ -337,7 +337,7 @@ describe.each(testVersions)(
337337
)
338338

339339
expect(code).toMatchInlineSnapshot(`
340-
"import { s_AdditionalPropertiesUnknownEmptyObjectSchema } from "./unit-test.schemas"
340+
"import { s_AdditionalPropertiesUnknownEmptyObjectSchema } from "./unit-test.schemas.ts"
341341
342342
const x = s_AdditionalPropertiesUnknownEmptyObjectSchema.required()"
343343
`)
@@ -359,7 +359,7 @@ describe.each(testVersions)(
359359
)
360360

361361
expect(code).toMatchInlineSnapshot(`
362-
"import { s_AdditionalPropertiesSchema } from "./unit-test.schemas"
362+
"import { s_AdditionalPropertiesSchema } from "./unit-test.schemas.ts"
363363
364364
const x = s_AdditionalPropertiesSchema.required()"
365365
`)
@@ -388,7 +388,7 @@ describe.each(testVersions)(
388388
)
389389

390390
expect(code).toMatchInlineSnapshot(`
391-
"import { s_AdditionalPropertiesMixed } from "./unit-test.schemas"
391+
"import { s_AdditionalPropertiesMixed } from "./unit-test.schemas.ts"
392392
393393
const x = s_AdditionalPropertiesMixed.required()"
394394
`)

packages/openapi-code-generator/src/typescript/common/schema-builders/zod-v3-schema-builder.spec.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe.each(testVersions)(
3939
const {code, schemas} = await getActual("components/schemas/SimpleObject")
4040

4141
expect(code).toMatchInlineSnapshot(`
42-
"import { s_SimpleObject } from "./unit-test.schemas"
42+
"import { s_SimpleObject } from "./unit-test.schemas.ts"
4343
4444
const x = s_SimpleObject"
4545
`)
@@ -65,7 +65,7 @@ describe.each(testVersions)(
6565
)
6666

6767
expect(code).toMatchInlineSnapshot(`
68-
"import { s_ObjectWithComplexProperties } from "./unit-test.schemas"
68+
"import { s_ObjectWithComplexProperties } from "./unit-test.schemas.ts"
6969
7070
const x = s_ObjectWithComplexProperties"
7171
`)
@@ -105,7 +105,7 @@ describe.each(testVersions)(
105105
const {code, schemas} = await getActual("components/schemas/OneOf")
106106

107107
expect(code).toMatchInlineSnapshot(`
108-
"import { s_OneOf } from "./unit-test.schemas"
108+
"import { s_OneOf } from "./unit-test.schemas.ts"
109109
110110
const x = s_OneOf"
111111
`)
@@ -125,7 +125,7 @@ describe.each(testVersions)(
125125
const {code, schemas} = await getActual("components/schemas/AnyOf")
126126

127127
expect(code).toMatchInlineSnapshot(`
128-
"import { s_AnyOf } from "./unit-test.schemas"
128+
"import { s_AnyOf } from "./unit-test.schemas.ts"
129129
130130
const x = s_AnyOf"
131131
`)
@@ -141,7 +141,7 @@ describe.each(testVersions)(
141141
const {code, schemas} = await getActual("components/schemas/AllOf")
142142

143143
expect(code).toMatchInlineSnapshot(`
144-
"import { s_AllOf } from "./unit-test.schemas"
144+
"import { s_AllOf } from "./unit-test.schemas.ts"
145145
146146
const x = s_AllOf"
147147
`)
@@ -162,14 +162,14 @@ describe.each(testVersions)(
162162
const {code, schemas} = await getActual("components/schemas/Recursive")
163163

164164
expect(code).toMatchInlineSnapshot(`
165-
"import { s_Recursive } from "./unit-test.schemas"
165+
"import { s_Recursive } from "./unit-test.schemas.ts"
166166
167167
const x = z.lazy(() => s_Recursive)"
168168
`)
169169

170170
expect(schemas).toMatchInlineSnapshot(`
171171
"import { z } from "zod/v3"
172-
import type { t_Recursive } from "./unit-test.types"
172+
import type { t_Recursive } from "./unit-test.types.ts"
173173
174174
export const s_Recursive: z.ZodType<t_Recursive, z.ZodTypeDef, unknown> =
175175
z.object({ child: z.lazy(() => s_Recursive.optional()) })"
@@ -180,7 +180,7 @@ describe.each(testVersions)(
180180
const {code, schemas} = await getActual("components/schemas/Ordering")
181181

182182
expect(code).toMatchInlineSnapshot(`
183-
"import { s_Ordering } from "./unit-test.schemas"
183+
"import { s_Ordering } from "./unit-test.schemas.ts"
184184
185185
const x = s_Ordering"
186186
`)
@@ -206,7 +206,7 @@ describe.each(testVersions)(
206206
const {code, schemas} = await getActual("components/schemas/Enums")
207207

208208
expect(code).toMatchInlineSnapshot(`
209-
"import { s_Enums } from "./unit-test.schemas"
209+
"import { s_Enums } from "./unit-test.schemas.ts"
210210
211211
const x = s_Enums"
212212
`)
@@ -231,7 +231,7 @@ describe.each(testVersions)(
231231
)
232232

233233
expect(code).toMatchInlineSnapshot(`
234-
"import { s_AdditionalPropertiesBool } from "./unit-test.schemas"
234+
"import { s_AdditionalPropertiesBool } from "./unit-test.schemas.ts"
235235
236236
const x = s_AdditionalPropertiesBool"
237237
`)
@@ -249,7 +249,7 @@ describe.each(testVersions)(
249249
)
250250

251251
expect(code).toMatchInlineSnapshot(`
252-
"import { s_AdditionalPropertiesUnknownEmptySchema } from "./unit-test.schemas"
252+
"import { s_AdditionalPropertiesUnknownEmptySchema } from "./unit-test.schemas.ts"
253253
254254
const x = s_AdditionalPropertiesUnknownEmptySchema"
255255
`)
@@ -267,7 +267,7 @@ describe.each(testVersions)(
267267
)
268268

269269
expect(code).toMatchInlineSnapshot(`
270-
"import { s_AdditionalPropertiesUnknownEmptyObjectSchema } from "./unit-test.schemas"
270+
"import { s_AdditionalPropertiesUnknownEmptyObjectSchema } from "./unit-test.schemas.ts"
271271
272272
const x = s_AdditionalPropertiesUnknownEmptyObjectSchema"
273273
`)
@@ -287,7 +287,7 @@ describe.each(testVersions)(
287287
)
288288

289289
expect(code).toMatchInlineSnapshot(`
290-
"import { s_AdditionalPropertiesSchema } from "./unit-test.schemas"
290+
"import { s_AdditionalPropertiesSchema } from "./unit-test.schemas.ts"
291291
292292
const x = s_AdditionalPropertiesSchema"
293293
`)
@@ -309,7 +309,7 @@ describe.each(testVersions)(
309309
)
310310

311311
expect(code).toMatchInlineSnapshot(`
312-
"import { s_AdditionalPropertiesMixed } from "./unit-test.schemas"
312+
"import { s_AdditionalPropertiesMixed } from "./unit-test.schemas.ts"
313313
314314
const x = s_AdditionalPropertiesMixed"
315315
`)
@@ -825,7 +825,8 @@ describe.each(testVersions)(
825825
}
826826

827827
function inlineStaticSchemas(code: string) {
828-
const importRegex = /import { ([^}]+) } from "\.\/unit-test\.schemas"\n/
828+
const importRegex =
829+
/import {([^}]+)} from "\.\/unit-test\.schemas.ts"\n/
829830

830831
const match = code.match(importRegex)?.[1]
831832

@@ -854,7 +855,7 @@ describe.each(testVersions)(
854855
const {code} = await getActualFromModel({...base})
855856

856857
expect(code).toMatchInlineSnapshot(`
857-
"import { PermissiveBoolean } from "./unit-test.schemas"
858+
"import { PermissiveBoolean } from "./unit-test.schemas.ts"
858859
859860
const x = PermissiveBoolean"
860861
`)

0 commit comments

Comments
 (0)