test: improve expects

This commit is contained in:
Dan Ribbens
2023-09-13 13:04:06 -04:00
parent bb16ce965c
commit 33e50f7d6b
2 changed files with 13 additions and 4 deletions

View File

@@ -289,7 +289,15 @@ describe('collections-rest', () => {
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 { doc } = await client.create({ slug: customIdSlug, data: { id: customId, name: 'custom-id-name' } });
const { result } = await client.find({ slug: customIdSlug, query: { id: { like: 'custom' } } });