Skip to content

Commit

Permalink
test(client): filter isSet
Browse files Browse the repository at this point in the history
  • Loading branch information
millsp committed Mar 24, 2022
1 parent 120fad8 commit 52f6ed3
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 55 deletions.
@@ -1,7 +1,6 @@
export function commentOptionalPropDataA(id: string) {
return {
id: id,
country: 'France',
content: {
set: {
text: 'Hello World',
Expand Down
@@ -1,7 +1,6 @@
export function commentRequiredListDataA(id: string) {
return {
id: id,
country: 'France',
contents: {
set: {
text: 'Hello World',
Expand Down
@@ -1,7 +1,6 @@
export function commentRequiredPropDataA(id: string) {
return {
id: id,
country: 'France',
content: {
set: {
text: 'Hello World',
Expand Down
@@ -1,4 +1,5 @@
import { getTestClient } from '../../../../../utils/getTestClient'
import { commentOptionalPropDataA } from '../__helpers__/build-data/commentOptionalPropDataA'

const describeIf = (condition: boolean) => (condition ? describe : describe.skip)

Expand All @@ -17,21 +18,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findFirst > optional', () => {

beforeEach(async () => {
await prisma.commentOptionalProp.deleteMany({ where: { id } })
await prisma.commentOptionalProp.create({
data: {
id,
country: 'France',
content: {
set: {
text: 'Hello World',
upvotes: {
vote: true,
userId: '10',
},
},
},
},
})
await prisma.commentOptionalProp.create({ data: commentOptionalPropDataA(id) })
})

afterEach(async () => {
Expand All @@ -57,7 +44,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findFirst > optional', () => {
},
],
},
country: France,
country: null,
id: 7aaaaaaaaaaaaaaaaaaaaaaa,
}
`)
Expand Down Expand Up @@ -113,9 +100,20 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findFirst > optional', () => {
},
],
},
country: France,
country: null,
id: 7aaaaaaaaaaaaaaaaaaaaaaa,
}
`)
})

/**
* Filter isSet
*/
test('filter isSet', async () => {
const comment = await prisma.commentOptionalProp.findFirst({
where: { id, country: { isSet: true } },
})

expect(comment).toMatchInlineSnapshot(`null`)
})
})
Expand Up @@ -51,7 +51,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > list', () => {
],
},
],
country: France,
country: null,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
Expand Down Expand Up @@ -141,7 +141,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > list', () => {
],
},
],
country: France,
country: null,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
Expand Down Expand Up @@ -173,7 +173,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > list', () => {
],
},
],
country: France,
country: null,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
Expand All @@ -192,24 +192,24 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > list', () => {
})

expect(comment).toMatchInlineSnapshot(`
Array [
Object {
contents: Array [
Object {
text: Hello World,
upvotes: Array [
Object {
userId: 10,
vote: true,
},
],
},
],
country: France,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
`)
Array [
Object {
contents: Array [
Object {
text: Hello World,
upvotes: Array [
Object {
userId: 10,
vote: true,
},
],
},
],
country: null,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
`)
})

/**
Expand Down Expand Up @@ -237,7 +237,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > list', () => {
],
},
],
country: France,
country: null,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
Expand Down Expand Up @@ -359,7 +359,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > list', () => {
],
},
],
country: France,
country: null,
id: 9bbbbbbbbbbbbbbbbbbbbbbb,
},
]
Expand Down
Expand Up @@ -49,7 +49,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > optional', () => {
},
],
},
country: France,
country: null,
id: 8aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -126,7 +126,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > optional', () => {
},
],
},
country: France,
country: null,
id: 8aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -156,7 +156,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > optional', () => {
},
],
},
country: France,
country: null,
id: 8aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -186,7 +186,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > optional', () => {
},
],
},
country: France,
country: null,
id: 8aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -233,7 +233,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > optional', () => {
},
],
},
country: France,
country: null,
id: 8aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -263,10 +263,42 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > optional', () => {
},
],
},
country: France,
country: null,
id: 8aaaaaaaaaaaaaaaaaaaaaaa,
},
]
`)
})

/**
* Filter isSet
*/
test('filter isSet', async () => {
const comment = await prisma.commentOptionalProp.findFirst({
where: {
OR: [{ id: id1 }, { id: id2 }],
country: { isSet: true },
},
})

expect(comment).toMatchInlineSnapshot(`
Object {
content: Object {
text: Goodbye World,
upvotes: Array [
Object {
userId: 11,
vote: false,
},
Object {
userId: 12,
vote: true,
},
],
},
country: France,
id: 1ddddddddddddddddddddddd,
}
`)
})
})
Expand Up @@ -49,7 +49,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > required', () => {
},
],
},
country: France,
country: null,
id: 3aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -126,7 +126,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > required', () => {
},
],
},
country: France,
country: null,
id: 3aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -156,7 +156,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > required', () => {
},
],
},
country: France,
country: null,
id: 3aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -186,7 +186,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > required', () => {
},
],
},
country: France,
country: null,
id: 3aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -233,7 +233,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > required', () => {
},
],
},
country: France,
country: null,
id: 3aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down Expand Up @@ -263,7 +263,7 @@ describeIf(!process.env.TEST_SKIP_MONGODB)('findMany > required', () => {
},
],
},
country: France,
country: null,
id: 3aaaaaaaaaaaaaaaaaaaaaaa,
},
]
Expand Down

0 comments on commit 52f6ed3

Please sign in to comment.