Skip to content

Commit

Permalink
Add any as a possible optionalWords value
Browse files Browse the repository at this point in the history
  • Loading branch information
bidoubiwa committed Aug 2, 2022
1 parent e2ba985 commit c40122c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type Crop = {
export const enum OptionalWords {
NONE = 'none',
LAST = 'last',
ANY = 'any',
}

export type SearchParams = Query &
Expand Down
14 changes: 14 additions & 0 deletions tests/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ describe.each([
expect(response.hits.length).toEqual(1)
})

test(`${permission} key: Basic phrase searchwith optionalWords at any`, async () => {
const client = await getClient(permission)
const response = await client
.index(index.uid)
.search('french book', { optionalWords: OptionalWords.ANY })

expect(response).toHaveProperty('hits', expect.any(Array))
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 20)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
expect(response).toHaveProperty('query', 'french book')
expect(response.hits.length).toEqual(6)
})

test(`${permission} key: search with options`, async () => {
const client = await getClient(permission)
const response = await client
Expand Down

0 comments on commit c40122c

Please sign in to comment.