-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
uuid.test.ts
66 lines (63 loc) · 1.5 KB
/
uuid.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { DMMFClass, makeDocument } from '../runtime'
import { getDMMF } from '../generation/getDMMF'
const datamodel = `datasource my_db {
provider = "postgres"
url = env("POSTGRES_URL")
}
model User {
id String @default(cuid()) @id
name String
hobbies String[]
}
`
describe('at least one validation', () => {
let dmmf
beforeAll(async () => {
dmmf = new DMMFClass(await getDMMF({ datamodel }))
})
test('string first', () => {
const select = {
data: {
hobbies: {
set: [
'sample 1 string',
'7fb1aef9-5250-4cf6-92c7-b01f53862822',
'sample 3 string',
'575e0b28-81fa-43e0-8f05-708a98d55c14',
'sample 5 string',
],
},
name: 'name',
},
}
const document = makeDocument({
dmmf,
select,
rootTypeName: 'mutation',
rootField: 'createOneUser',
})
expect(() => document.validate(select, false)).not.toThrow()
})
test('uuid first', () => {
const select = {
data: {
hobbies: {
set: [
'7fb1aef9-5250-4cf6-92c7-b01f53862822',
'sample 3 string',
'575e0b28-81fa-43e0-8f05-708a98d55c14',
'sample 5 string',
],
},
name: 'name',
},
}
const document = makeDocument({
dmmf,
select,
rootTypeName: 'mutation',
rootField: 'createOneUser',
})
expect(() => document.validate(select, false)).not.toThrow()
})
})