test: adds like query partial word match test

This commit is contained in:
James
2022-07-25 16:56:45 -04:00
parent c96985be0c
commit b79ae00603

View File

@@ -357,7 +357,7 @@ describe('collections-rest', () => {
it('like', async () => { it('like', async () => {
const post1 = await createPost({ title: 'prefix-value' }); const post1 = await createPost({ title: 'prefix-value' });
await createPost();
const { status, result } = await client.find<Post>({ const { status, result } = await client.find<Post>({
query: { query: {
title: { title: {
@@ -371,6 +371,22 @@ describe('collections-rest', () => {
expect(result.totalDocs).toEqual(1); expect(result.totalDocs).toEqual(1);
}); });
it('like - partial word match', async () => {
const post = await createPost({ title: 'separate words should partially match' });
const { status, result } = await client.find<Post>({
query: {
title: {
like: 'words partial',
},
},
});
expect(status).toEqual(200);
expect(result.docs).toEqual([post]);
expect(result.totalDocs).toEqual(1);
});
it('exists - true', async () => { it('exists - true', async () => {
const postWithDesc = await createPost({ description: 'exists' }); const postWithDesc = await createPost({ description: 'exists' });
await createPost({ description: undefined }); await createPost({ description: undefined });