-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from social-native/fix/range-filter
Fix/range filter
- Loading branch information
Showing
10 changed files
with
184 additions
and
37 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
__tests__/integration/filters/boolean_filter/set_filter.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {setUp} from '../utils'; | ||
import waitForExpect from 'wait-for-expect'; | ||
|
||
describe('Filters', () => { | ||
describe('setFilter', () => { | ||
it('calls client search with filter that was set', async () => { | ||
const {manager, client} = setUp(); | ||
await manager.getFieldNamesAndTypes(); | ||
|
||
manager.filters.boolean.setFilter('boolean_field', {state: true}); | ||
|
||
expect(client.search).toHaveBeenCalledWith({ | ||
_source: {}, | ||
aggs: {}, | ||
query: {bool: {should: [{term: {boolean_field: true}}]}}, | ||
size: 10, | ||
sort: ['_score', '_doc'], | ||
track_scores: true | ||
}); | ||
}); | ||
|
||
it('adds existing filters to the search request when set', async () => { | ||
const {manager, client} = setUp(); | ||
|
||
await manager.getFieldNamesAndTypes(); | ||
|
||
manager.filters.boolean.setFilter('boolean_field', {state: true}); | ||
manager.filters.range.setFilter('double_field', {greaterThan: 0, lessThanEqual: 10}); | ||
|
||
await waitForExpect(() => { | ||
expect(manager._sideEffectQueue.length).toEqual(0); | ||
}); | ||
|
||
expect(client.search).toHaveBeenCalledWith({ | ||
query: { | ||
bool: { | ||
should: [ | ||
{term: {boolean_field: true}}, | ||
{range: {double_field: {gt: 0, lte: 10}}} | ||
] | ||
} | ||
}, | ||
aggs: {}, | ||
_source: {}, | ||
size: 0, | ||
track_scores: false, | ||
sort: ['_score', '_doc'] | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {setUp} from '../utils'; | ||
|
||
describe('Suggestion', () => { | ||
describe('Prefix', () => { | ||
describe('setSuggestion', () => { | ||
it.skip('calls client search with all search info', async () => { | ||
const {manager, client} = setUp(); | ||
await manager.getFieldNamesAndTypes(); | ||
manager.suggestions.prefix.setSearch('text_field', 'test_prefix_search'); | ||
|
||
expect(client.search).toHaveBeenCalledWith(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters