Skip to content

Commit 7f337ea

Browse files
test: api and unit test cases for search operator
1 parent 8e5fdde commit 7f337ea

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

test/api/entry-queryables.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ describe('Query Operators API test cases', () => {
142142
expect(query.entries[0].title).toBe('value');
143143
}
144144
});
145+
146+
it('should search for the matching key and return the entry', async () => {
147+
const query = await makeEntries('contenttype_uid').query().search('value2').find<TEntry>();
148+
if (query.entries) {
149+
expect(query.entries[0]._version).toBeDefined();
150+
expect(query.entries[0].locale).toBeDefined();
151+
expect(query.entries[0].uid).toBeDefined();
152+
expect(query.entries[0].title).toBe('value2');
153+
}
154+
});
145155
});
146156

147157
function makeEntries(contentTypeUid = ''): Entries {

test/unit/entry-queryable.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,10 @@ describe('Query Operators API test cases', () => {
6767
expect(query._parameters).toEqual({ tags: ['tag1'] });
6868
}
6969
});
70+
it('should search for the matching key and return the entry', async () => {
71+
const query = contentType.Entry().query().search('entry');
72+
if (query) {
73+
expect(query._queryParams).toEqual({ typeahead: 'entry' });
74+
}
75+
});
7076
});

0 commit comments

Comments
 (0)