mirror of
https://github.com/grafana/grafana.git
synced 2026-08-26 13:27:30 -05:00
* fix: monaco loading state * chore: betterer * test: leverage e2e selectors * refactor: prefer HOC to wrap with testid * refactor: add clarity * docs: add clarity * refactor: loading messaging * test: rename vars to improve clarity * test: rename vars to improve clarity
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { createLokiDatasource } from '../../__mocks__/datasource';
|
|
|
|
import MonacoQueryField from './MonacoQueryField';
|
|
import { Props } from './MonacoQueryFieldProps';
|
|
|
|
function renderComponent({
|
|
initialValue = '',
|
|
onRunQuery = jest.fn(),
|
|
onBlur = jest.fn(),
|
|
onChange = jest.fn(),
|
|
}: Partial<Props> = {}) {
|
|
const datasource = createLokiDatasource();
|
|
|
|
render(
|
|
<MonacoQueryField
|
|
datasource={datasource}
|
|
initialValue={initialValue}
|
|
history={[]}
|
|
onRunQuery={onRunQuery}
|
|
onBlur={onBlur}
|
|
onChange={onChange}
|
|
placeholder="Enter a Loki query (run with Shift+Enter)"
|
|
/>
|
|
);
|
|
}
|
|
|
|
describe('MonacoQueryField', () => {
|
|
test('Renders with no errors', async () => {
|
|
renderComponent();
|
|
|
|
const monacoEditor = await screen.findByTestId(selectors.components.ReactMonacoEditor.container);
|
|
expect(monacoEditor).toBeInTheDocument();
|
|
});
|
|
});
|