chore: rectifies test issues

This commit is contained in:
James
2023-09-15 17:12:13 -04:00
parent 92b4490257
commit 5292f41a3b
5 changed files with 100 additions and 28 deletions

View File

@@ -17,6 +17,15 @@ describe('collections-graphql', () => {
const config = await configPromise
const url = `${serverURL}${config.routes.api}${config.routes.graphQL}`
client = new GraphQLClient(url)
// Wait for indexes to be created,
// as we need them to query by point
await new Promise((resolve, reject) => {
payload.db.collections.point.ensureIndexes(function (err) {
if (err) reject(err)
resolve(true)
})
})
})
afterAll(async () => {
@@ -173,12 +182,14 @@ describe('collections-graphql', () => {
}
}`
const response = await client.request(query);
const { docs } = response.Posts;
const docsWithWhereTitleNotEqualPostTitle = docs.filter((post) => post.title === post1.title);
const response = await client.request(query)
const { docs } = response.Posts
const docsWithWhereTitleNotEqualPostTitle = docs.filter(
(post) => post.title === post1.title,
)
expect(docsWithWhereTitleNotEqualPostTitle).toHaveLength(0);
});
expect(docsWithWhereTitleNotEqualPostTitle).toHaveLength(0)
})
it('like', async () => {
const postWithWords = await createPost({ title: 'the quick brown fox' })
@@ -271,10 +282,10 @@ describe('collections-graphql', () => {
}
}`
const response = await client.request(query);
const { docs } = response.Posts;
expect(docs.map(({ id }) => id)).toContain(numPost2.id);
});
const response = await client.request(query)
const { docs } = response.Posts
expect(docs.map(({ id }) => id)).toContain(numPost2.id)
})
it('greater_than_equal', async () => {
const query = `query {