Skip to content

Commit 9cc01d5

Browse files
authored
chore: type coverage test (#1831)
1 parent 5f15fe0 commit 9cc01d5

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/integration/tests/enhancements/json/typing.test.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,58 @@ async function main() {
171171
const u2 = await db.user.findMany();
172172
console.log(u2[0].profile.address?.city);
173173
await db.user.create({ data: { profile: { age: 20 } } });
174+
}
175+
`,
176+
},
177+
],
178+
}
179+
);
180+
});
181+
182+
it('type coverage', async () => {
183+
await loadSchema(
184+
`
185+
type Profile {
186+
boolean Boolean
187+
bigint BigInt
188+
int Int
189+
float Float
190+
decimal Decimal
191+
string String
192+
bytes Bytes
193+
dateTime DateTime
194+
json Json
195+
}
196+
197+
model User {
198+
id Int @id @default(autoincrement())
199+
profile Profile @json
200+
@@allow('all', true)
201+
}
202+
`,
203+
{
204+
provider: 'postgresql',
205+
pushDb: false,
206+
compile: true,
207+
extraSourceFiles: [
208+
{
209+
name: 'main.ts',
210+
content: `
211+
import type { Profile } from '.zenstack/models';
212+
import { Prisma } from '@prisma/client';
213+
214+
async function main() {
215+
const profile: Profile = {
216+
boolean: true,
217+
bigint: BigInt(9007199254740991),
218+
int: 100,
219+
float: 1.23,
220+
decimal: new Prisma.Decimal(1.2345),
221+
string: 'string',
222+
bytes: new Uint8Array([0, 1, 2, 3]),
223+
dateTime: new Date(),
224+
json: { a: 1 },
225+
}
174226
}
175227
`,
176228
},

0 commit comments

Comments
 (0)