mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus/Explore: Update position of fields in editor (#27816)
* Update position of buttons * Refactor, add tests * Pass onKeydown func * Update public/app/plugins/datasource/prometheus/components/PromQueryField.tsx Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
@@ -1,28 +1,35 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { PromExploreExtraField, PromExploreExtraFieldProps } from './PromExploreExtraField';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { PromExploreExtraFieldProps, PromExploreExtraField } from './PromExploreExtraField';
|
||||
|
||||
const setup = (propOverrides?: PromExploreExtraFieldProps) => {
|
||||
const label = 'Prometheus Explore Extra Field';
|
||||
const value = '123';
|
||||
const onChangeFunc = jest.fn();
|
||||
const queryType = 'range';
|
||||
const stepValue = '1';
|
||||
const onStepChange = jest.fn();
|
||||
const onQueryTypeChange = jest.fn();
|
||||
const onKeyDownFunc = jest.fn();
|
||||
|
||||
const props: any = {
|
||||
label,
|
||||
value,
|
||||
onChangeFunc,
|
||||
queryType,
|
||||
stepValue,
|
||||
onStepChange,
|
||||
onQueryTypeChange,
|
||||
onKeyDownFunc,
|
||||
};
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
return shallow(<PromExploreExtraField {...props} />);
|
||||
return render(<PromExploreExtraField {...props} />);
|
||||
};
|
||||
|
||||
describe('PrometheusExploreExtraField', () => {
|
||||
it('should render component', () => {
|
||||
const wrapper = setup();
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
describe('PromExploreExtraField', () => {
|
||||
it('should render step field', () => {
|
||||
setup();
|
||||
expect(screen.getByTestId('stepField')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render query type field', () => {
|
||||
setup();
|
||||
expect(screen.getByTestId('queryTypeField')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user