Skip to content

Commit

Permalink
test(findMany): add failing test for querying by null
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Feb 5, 2022
1 parent d32f154 commit bd133cf
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/model/findMany.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { datatype } from 'faker'
import { factory, primaryKey } from '../../src'
import { factory, primaryKey, nullable } from '../../src'
import { OperationErrorType } from '../../src/errors/OperationError'
import { getThrownError } from '../testUtils'

Expand Down Expand Up @@ -76,3 +76,26 @@ test('returns an empty array when not found matching entities', () => {
})
expect(users).toHaveLength(0)
})

test('queries with null as criteria', () => {
const db = factory({
user: {
id: String,
organizationId: nullable((): string | null => null),
},
})

const john = db.user.create({ id: 'john' })
db.user.create({ id: 'katy', organizationId: 'org-1' })
const clark = db.user.create({ id: 'clark' })

const users = db.user.findMany({
where: {
organizationId: {
equals: null,
},
},
})

expect(users).toEqual([john, clark])
})

0 comments on commit bd133cf

Please sign in to comment.