mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* 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>
36 lines
931 B
TypeScript
36 lines
931 B
TypeScript
import React from 'react';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { PromExploreExtraFieldProps, PromExploreExtraField } from './PromExploreExtraField';
|
|
|
|
const setup = (propOverrides?: PromExploreExtraFieldProps) => {
|
|
const queryType = 'range';
|
|
const stepValue = '1';
|
|
const onStepChange = jest.fn();
|
|
const onQueryTypeChange = jest.fn();
|
|
const onKeyDownFunc = jest.fn();
|
|
|
|
const props: any = {
|
|
queryType,
|
|
stepValue,
|
|
onStepChange,
|
|
onQueryTypeChange,
|
|
onKeyDownFunc,
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
return render(<PromExploreExtraField {...props} />);
|
|
};
|
|
|
|
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();
|
|
});
|
|
});
|