Skip to content

Commit

Permalink
Extending tests to verify enumType setting with 'object' value.
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetric committed Aug 26, 2024
1 parent 8520216 commit af7b72d
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests/options-behavior/expected/enumTypeObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// This file was auto-generated by prisma-generator-typescript-interfaces

export const Gender = {
Male: "Male",
Female: "Female",
Other: "Other"
};

export type Gender = (typeof Gender)[keyof typeof Gender];

export const DataTest = {
Apple: "Apple",
Banana: "Banana",
Orange: "Orange",
Pear: "Pear"
};

export type DataTest = (typeof DataTest)[keyof typeof DataTest];

export interface Person {
id: number;
name: string;
age: number;
email: string | null;
gender: Gender;
addressId: number;
address?: Address;
friends?: Person[];
friendsOf?: Person[];
data?: Data | null;
}

export interface Address {
id: number;
streetNumber: number;
streetName: string;
city: string;
isBilling: boolean;
people?: Person[];
}

export interface Data {
id: string;
stringField: string;
booleanField: boolean;
intField: number;
bigIntField: bigint;
floatField: number;
decimalField: Decimal;
dateField: Date;
jsonField: JsonValue;
bytesField: Buffer;
enumField: DataTest;
optionalStringField: string | null;
optionalBooleanField: boolean | null;
optionalIntField: number | null;
optionalBigIntField: bigint | null;
optionalFloatField: number | null;
optionalDecimalField: Decimal | null;
optionalDateField: Date | null;
optionalJsonField: JsonValue | null;
optionalBytesField: Buffer | null;
optionalEnumField: DataTest | null;
stringArrayField: string[];
booleanArrayField: boolean[];
intArrayField: number[];
bigIntArrayField: bigint[];
floatArrayField: number[];
decimalArrayField: Decimal[];
dateArrayField: Date[];
jsonArrayField: JsonValue[];
bytesArrayField: Buffer[];
enumArrayField: DataTest[];
personId: number;
person?: Person;
}

type Decimal = { valueOf(): string };

type JsonValue = string | number | boolean | { [key in string]?: JsonValue } | Array<JsonValue> | null;
6 changes: 6 additions & 0 deletions tests/options-behavior/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ generator enumTypeSuffixPrefix {
enumSuffix = "Enum"
}

generator enumTypeObject {
provider = "node --loader ts-node/esm generator.ts"
output = "enumTypeObject.ts"
enumType = "object"
}

generator modelType {
provider = "node --loader ts-node/esm generator.ts"
output = "modelType.ts"
Expand Down

0 comments on commit af7b72d

Please sign in to comment.