diff --git a/test/model/findMany.test.ts b/test/model/findMany.test.ts index 79d6b5b4..dfbc2796 100644 --- a/test/model/findMany.test.ts +++ b/test/model/findMany.test.ts @@ -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' @@ -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]) +})