-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Query] Remove es query dependency on format.convert (#103174)
* remove es query dependency on format.convert * fix types * types Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
df8787b
commit 07af5d3
Showing
6 changed files
with
72 additions
and
18 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
src/plugins/data/public/query/filter_manager/lib/get_display_value.test.ts
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,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { stubIndexPattern, phraseFilter } from 'src/plugins/data/common/stubs'; | ||
import { getDisplayValueFromFilter } from './get_display_value'; | ||
|
||
describe('getDisplayValueFromFilter', () => { | ||
it('returns the value if string', () => { | ||
phraseFilter.meta.value = 'abc'; | ||
const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); | ||
expect(displayValue).toBe('abc'); | ||
}); | ||
|
||
it('returns the value if undefined', () => { | ||
phraseFilter.meta.value = undefined; | ||
const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); | ||
expect(displayValue).toBe(''); | ||
}); | ||
|
||
it('calls the value function if proivided', () => { | ||
// The type of value currently doesn't match how it's used. Refactor needed. | ||
phraseFilter.meta.value = jest.fn((x) => { | ||
return 'abc'; | ||
}) as any; | ||
const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); | ||
expect(displayValue).toBe('abc'); | ||
expect(phraseFilter.meta.value).toHaveBeenCalledWith(undefined); | ||
}); | ||
|
||
it('calls the value function if proivided, with formatter', () => { | ||
stubIndexPattern.getFormatterForField = jest.fn().mockReturnValue('banana'); | ||
phraseFilter.meta.value = jest.fn((x) => { | ||
return x + 'abc'; | ||
}) as any; | ||
const displayValue = getDisplayValueFromFilter(phraseFilter, [stubIndexPattern]); | ||
expect(stubIndexPattern.getFormatterForField).toHaveBeenCalledTimes(1); | ||
expect(phraseFilter.meta.value).toHaveBeenCalledWith('banana'); | ||
expect(displayValue).toBe('bananaabc'); | ||
}); | ||
}); |
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