Skip to content

Commit

Permalink
isolate the use emptyAsUndefined test
Browse files Browse the repository at this point in the history
  • Loading branch information
samthuang committed Apr 10, 2023
1 parent f2cddf2 commit 2f90098
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ describe('editable columns', () => {
expect(form).toMatch('name="number"')
})

test("includes optional relational fields with an emptyAs('undefined')", async () => {
expect(form).toMatch("emptyAs={'undefined'}")
})

test('includes DateTime fields', async () => {
expect(form).toMatch('name="otherTime"')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ model Post {
metadata Json
hugeNumber BigInt @default(9007199254740992)
favorites Favorite[]
exclude ExcludeDefault[]
tag Tag[]
}

model User {
Expand Down Expand Up @@ -64,6 +64,11 @@ model ExcludeDefault {
updatedTime DateTime @updatedAt
nowTime DateTime @default(now())
otherTime DateTime
post Post? @relation(fields: [postId], references: [id])
postId Int?
}

model Tag {
id Int @id @default(autoincrement())
name String @unique
post Post? @relation(fields: [postId], references: [id])
postId Int?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
globalThis.__dirname = __dirname
import path from 'path'

// Load mocks
import '../../../../lib/test'

import { getDefaultArgs } from '../../../../lib'
import { yargsDefaults as defaults } from '../../helpers'
import * as scaffold from '../scaffold'

jest.mock('execa')

describe('relational form field', () => {
let files
let form

beforeAll(async () => {
files = await scaffold.files({
...getDefaultArgs(defaults),
model: 'Tag',
tests: true,
nestScaffoldByModel: true,
})
form =
files[
path.normalize(
'/path/to/project/web/src/components/Tag/TagForm/TagForm.js'
)
]
})

test("includes optional relational fields with an emptyAs('undefined')", async () => {
expect(form).toMatch("emptyAs={'undefined'}")
})
})

0 comments on commit 2f90098

Please sign in to comment.