grafana/public/app/plugins/datasource/loki/components/LokiOptionFields.test.tsx
Ivana Huckova a54e0ff79d
Loki: Add query type and line limit to query editor in dashboard (#29356)
* WIP Add line limit and query type switch toLoki dashboard editor

* Refactor, reuse code for both - Explore and Dashboard

* Üpdate snapshot tests

* Refactor and unify

* Rename test file

* Update test
2020-12-01 20:43:35 +01:00

36 lines
926 B
TypeScript

import React from 'react';
import { render, screen } from '@testing-library/react';
import { LokiOptionFieldsProps, LokiOptionFields } from './LokiOptionFields';
const setup = (propOverrides?: LokiOptionFieldsProps) => {
const queryType = 'range';
const lineLimitValue = '1';
const onLineLimitChange = jest.fn();
const onQueryTypeChange = jest.fn();
const onKeyDownFunc = jest.fn();
const props: any = {
queryType,
lineLimitValue,
onLineLimitChange,
onQueryTypeChange,
onKeyDownFunc,
};
Object.assign(props, propOverrides);
return render(<LokiOptionFields {...props} />);
};
describe('LokiOptionFields', () => {
it('should render step field', () => {
setup();
expect(screen.getByTestId('lineLimitField')).toBeInTheDocument();
});
it('should render query type field', () => {
setup();
expect(screen.getByTestId('queryTypeField')).toBeInTheDocument();
});
});