forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix add filter for numeric scripted field (opensearch-project#7022)
* Fix add filter for scripted field Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com> * add unit test Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com> * change from nested ternary to if else Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com> * add more unit tests Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com> * change unit tests Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com> * fix typo Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com> --------- Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
- Loading branch information
1 parent
6a079d3
commit 7c1f8fc
Showing
2 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
src/plugins/data/public/ui/filter_bar/filter_editor/value_input_type.test.tsx
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,80 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { ValueInputType } from './value_input_type'; | ||
|
||
let onChangeMock: any; | ||
|
||
describe('Value input type', () => { | ||
beforeAll(() => { | ||
onChangeMock = jest.fn(); | ||
}); | ||
it('is number', async () => { | ||
const valueInputProps = { | ||
value: 1, | ||
type: 'number', | ||
onChange: onChangeMock, | ||
onBlur: () => {}, | ||
placeholder: '', | ||
}; | ||
const component = mountWithIntl(<ValueInputType {...valueInputProps} />); | ||
expect(component.find('EuiFieldNumber').exists()).toBeTruthy(); | ||
expect(component.find('EuiFieldNumber').prop('value')).toBe(1); | ||
}); | ||
|
||
it('is string', async () => { | ||
const valueInputProps = { | ||
value: 'value', | ||
type: 'string', | ||
onChange: () => {}, | ||
onBlur: () => {}, | ||
placeholder: '', | ||
}; | ||
const component = mountWithIntl(<ValueInputType {...valueInputProps} />); | ||
expect(component.find('EuiFieldText').exists()).toBeTruthy(); | ||
expect(component.find('EuiFieldText').prop('value')).toBe('value'); | ||
}); | ||
|
||
it('is boolean', async () => { | ||
const valueInputProps = { | ||
value: 'true', | ||
type: 'boolean', | ||
onChange: () => {}, | ||
onBlur: () => {}, | ||
placeholder: '', | ||
}; | ||
const component = mountWithIntl(<ValueInputType {...valueInputProps} />); | ||
expect(component.find('EuiSelect').exists()).toBeTruthy(); | ||
expect(component.find('EuiSelect').prop('value')).toBe('true'); | ||
}); | ||
|
||
it('is date', async () => { | ||
const valueInputProps = { | ||
value: 'Jun 18, 2024 @ 12:01:55.000', | ||
type: 'date', | ||
onChange: () => {}, | ||
onBlur: () => {}, | ||
placeholder: '', | ||
}; | ||
const component = mountWithIntl(<ValueInputType {...valueInputProps} />); | ||
expect(component.find('EuiFieldText').exists()).toBeTruthy(); | ||
expect(component.find('EuiFieldText').prop('value')).toBe('Jun 18, 2024 @ 12:01:55.000'); | ||
}); | ||
|
||
it('is ip', async () => { | ||
const valueInputProps = { | ||
value: '127.0.0.1', | ||
type: 'ip', | ||
onChange: () => {}, | ||
onBlur: () => {}, | ||
placeholder: '', | ||
}; | ||
const component = mountWithIntl(<ValueInputType {...valueInputProps} />); | ||
expect(component.find('EuiFieldText').exists()).toBeTruthy(); | ||
expect(component.find('EuiFieldText').prop('value')).toBe('127.0.0.1'); | ||
}); | ||
}); |
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