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 Jan 26, 2022
1 parent 7a06f1c commit 92b43dd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/model/findMany.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { datatype } from 'faker'
import { nullable } from 'lib/nullable'
import { factory, primaryKey } from '../../src'
import { OperationErrorType } from '../../src/errors/OperationError'
import { getThrownError } from '../testUtils'
Expand Down Expand Up @@ -76,3 +77,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 92b43dd

Please sign in to comment.