Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support date_nanos type when select time field for creating monitor #954

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { FormikComboBox } from '../../../../components/FormControls';

const MonitorTimeField = ({ dataTypes }) => {
// Default empty option + options from index mappings mapped to ui select form
const dateFields = Array.from(dataTypes.date || []);
const dateFields = Array.from(dataTypes.date || []).concat(
Array.from(dataTypes.date_nanos || [])
);
const options = [].concat(dateFields).map((option) => ({ label: option }));
return (
<FormikComboBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,40 @@ describe('MonitorTimeField', () => {
expect(render(component)).toMatchSnapshot();
});

test.skip('displays no options', () => {
test('displays no options', () => {
const wrapper = mount(
<Formik initialValues={{}} onSubmit={() => {}}>
<MonitorTimeField dataTypes={{}} />
</Formik>
);
// Default blank option
expect(wrapper.find('select').props().children[1].length).toBe(1);
expect(wrapper.find('EuiComboBox').props().options.length).toBe(0);
});

test.skip('displays options', () => {
test('displays options', () => {
const wrapper = mount(
<Formik initialValues={{}} onSubmit={() => {}}>
<MonitorTimeField dataTypes={{ date: ['date1', 'date2', 'date3'] }} />
</Formik>
);
// 3 options + default blank option
expect(wrapper.find('select').props().children[1].length).toBe(4);
// 3 options
expect(wrapper.find('EuiComboBox').props().options.length).toBe(3);
});

test('displays options includes date_nanos', () => {
const wrapper = mount(
<Formik initialValues={{}} onSubmit={() => {}}>
<MonitorTimeField
dataTypes={{ date: ['date1', 'date2', 'date3'], date_nanos: ['date_nanos1'] }}
/>
</Formik>
);
expect(wrapper).toMatchSnapshot();

// 4 options
expect(wrapper.find('EuiComboBox').props().options.length).toBe(4);
expect(wrapper.find('EuiComboBox').props().options).toEqual(
expect.arrayContaining([{ label: 'date_nanos1' }])
);
});
});
Loading