test: conditional geojson
This commit is contained in:
@@ -1,20 +1,13 @@
|
||||
import { randomBytes } from 'crypto'
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
import type { Relation } from './config'
|
||||
import type { ErrorOnHook, Post } from './payload-types'
|
||||
import type { Relation } from './config';
|
||||
import type { ErrorOnHook, Post } from './payload-types';
|
||||
|
||||
import payload from '../../packages/payload/src'
|
||||
import { mapAsync } from '../../packages/payload/src/utilities/mapAsync'
|
||||
import { initPayloadTest } from '../helpers/configHelpers'
|
||||
import { RESTClient } from '../helpers/rest'
|
||||
import config, {
|
||||
customIdNumberSlug,
|
||||
customIdSlug,
|
||||
errorOnHookSlug,
|
||||
pointSlug,
|
||||
relationSlug,
|
||||
slug,
|
||||
} from './config'
|
||||
import payload from '../../packages/payload/src';
|
||||
import { mapAsync } from '../../packages/payload/src/utilities/mapAsync';
|
||||
import { initPayloadTest } from '../helpers/configHelpers';
|
||||
import { RESTClient } from '../helpers/rest';
|
||||
import config, { customIdNumberSlug, customIdSlug, errorOnHookSlug, pointSlug, relationSlug, slug, } from './config';
|
||||
|
||||
let client: RESTClient
|
||||
|
||||
@@ -25,12 +18,14 @@ describe('collections-rest', () => {
|
||||
|
||||
// Wait for indexes to be created,
|
||||
// as we need them to query by point
|
||||
if (payload.db.name === 'mongoose') {
|
||||
await new Promise((resolve, reject) => {
|
||||
payload.db.collections[pointSlug].ensureIndexes(function (err) {
|
||||
if (err) reject(err)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -116,11 +111,12 @@ describe('collections-rest', () => {
|
||||
})
|
||||
|
||||
const description = 'updated'
|
||||
const { status, docs } = await client.updateMany<Post>({
|
||||
const { status, docs, errors } = await client.updateMany({
|
||||
where: { title: { equals: 'title' } },
|
||||
data: { description },
|
||||
})
|
||||
|
||||
expect(errors).toHaveLength(0);
|
||||
expect(status).toEqual(200)
|
||||
expect(docs[0].title).toEqual('title') // Check was not modified
|
||||
expect(docs[0].description).toEqual(description)
|
||||
@@ -870,6 +866,7 @@ describe('collections-rest', () => {
|
||||
})
|
||||
})
|
||||
|
||||
if (['mongoose'].includes(process.env.PAYLOAD_DATABASE)) {
|
||||
describe('near', () => {
|
||||
const point = [10, 20]
|
||||
const [lat, lng] = point
|
||||
@@ -1026,6 +1023,7 @@ describe('collections-rest', () => {
|
||||
expect(result.docs).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
it('or', async () => {
|
||||
const post1 = await createPost({ title: 'post1' })
|
||||
|
||||
Reference in New Issue
Block a user