test: improve expects
This commit is contained in:
@@ -173,8 +173,9 @@ describe('collections-graphql', () => {
|
|||||||
|
|
||||||
const response = await client.request(query);
|
const response = await client.request(query);
|
||||||
const { docs } = response.Posts;
|
const { docs } = response.Posts;
|
||||||
|
const docsWithWhereTitleNotEqualPostTitle = docs.filter((post) => post.title === post1.title);
|
||||||
|
|
||||||
expect(docs[0]).toMatchObject({ id: post2.id, title: post2.title });
|
expect(docsWithWhereTitleNotEqualPostTitle).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('like', async () => {
|
it('like', async () => {
|
||||||
@@ -261,14 +262,14 @@ describe('collections-graphql', () => {
|
|||||||
docs {
|
docs {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
const response = await client.request(query);
|
const response = await client.request(query);
|
||||||
const { docs } = response.Posts;
|
const { docs } = response.Posts;
|
||||||
|
expect(docs.map(({ id }) => id)).toContain(numPost2.id);
|
||||||
expect(docs).toContainEqual(expect.objectContaining({ id: numPost2.id }));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('greater_than_equal', async () => {
|
it('greater_than_equal', async () => {
|
||||||
|
|||||||
@@ -289,7 +289,15 @@ describe('collections-rest', () => {
|
|||||||
expect(foundDoc.id).toEqual(doc.id);
|
expect(foundDoc.id).toEqual(doc.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should query', async () => {
|
it('should query - equals', async () => {
|
||||||
|
const customId = `custom-${randomBytes(32).toString('hex').slice(0, 12)}`;
|
||||||
|
const { doc } = await client.create({ slug: customIdSlug, data: { id: customId, name: 'custom-id-name' } });
|
||||||
|
const { result } = await client.find({ slug: customIdSlug, query: { id: { equals: customId } } });
|
||||||
|
|
||||||
|
expect(result.docs.map(({ id }) => id)).toContain(doc.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should query - like', async () => {
|
||||||
const customId = `custom-${randomBytes(32).toString('hex').slice(0, 12)}`;
|
const customId = `custom-${randomBytes(32).toString('hex').slice(0, 12)}`;
|
||||||
const { doc } = await client.create({ slug: customIdSlug, data: { id: customId, name: 'custom-id-name' } });
|
const { doc } = await client.create({ slug: customIdSlug, data: { id: customId, name: 'custom-id-name' } });
|
||||||
const { result } = await client.find({ slug: customIdSlug, query: { id: { like: 'custom' } } });
|
const { result } = await client.find({ slug: customIdSlug, query: { id: { like: 'custom' } } });
|
||||||
|
|||||||
Reference in New Issue
Block a user