Skip to content

Commit

Permalink
Added e2e test for --inferStringEnumKeysFromValues
Browse files Browse the repository at this point in the history
  • Loading branch information
codan84 committed May 15, 2024
1 parent 0312e9c commit 9d4bf02
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions test/__snapshots__/test/test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,33 @@ Generated by [AVA](https://avajs.dev).
| [{foo: [4, 6]}];␊
`

## enum.5.js

> Expected output to match snapshot for e2e test: enum.5.js

`/* eslint-disable */␊
/**␊
* This file was automatically generated by json-schema-to-typescript.␊
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,␊
* and run json-schema-to-typescript to regenerate this file.␊
*/␊
export interface Enum {␊
stringEnum: StringEnum;␊
impliedStringEnum: "a" | "b" | "c";␊
booleanEnum: true;␊
impliedBooleanEnum: true;␊
integerEnum: -1 | 0 | 1;␊
impliedIntegerEnum: -1 | 0 | 1;␊
}␊
export const enum StringEnum {␊
a = "a",␊
b = "b",␊
c = "c"␊
}␊
`

## enum.js

> Expected output to match snapshot for e2e test: enum.js
Expand Down
Binary file modified test/__snapshots__/test/test.ts.snap
Binary file not shown.
46 changes: 46 additions & 0 deletions test/e2e/enum.5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export const input = {
title: 'Enum',
type: 'object',
definitions: {
enumFromDefinition: {
type: 'string',
enum: ['a', 'b', 'c'],
},
},
properties: {
stringEnum: {
type: 'string',
enum: ['a', 'b', 'c'],
},
impliedStringEnum: {
enum: ['a', 'b', 'c'],
},
booleanEnum: {
type: 'boolean',
enum: [true],
},
impliedBooleanEnum: {
enum: [true],
},
integerEnum: {
type: 'integer',
enum: [-1, 0, 1],
},
impliedIntegerEnum: {
enum: [-1, 0, 1],
}
},
required: [
'stringEnum',
'impliedStringEnum',
'booleanEnum',
'impliedBooleanEnum',
'integerEnum',
'impliedIntegerEnum'
],
additionalProperties: false,
}

export const options = {
inferStringEnumKeysFromValues: true
}

0 comments on commit 9d4bf02

Please sign in to comment.