/usr/share/grafana/public/app/plugins/datasource/loki/components
import { render, screen } from '@testing-library/react'; import { LokiOptionFieldsProps, LokiOptionFields, preprocessMaxLines } from './LokiOptionFields'; const setup = () => { const lineLimitValue = '1'; const query = { refId: '1', expr: 'query' }; const onChange = jest.fn(); const onRunQuery = jest.fn(); const props: LokiOptionFieldsProps = { lineLimitValue, query, onChange, onRunQuery, }; return props; }; describe('Line Limit Field', () => { it('should render a line limit field', () => { const props = setup(); render(<LokiOptionFields {...props} />); expect(screen.getByRole('spinbutton')).toBeInTheDocument(); }); it('should have a default value of 1', () => { const props = setup(); render(<LokiOptionFields {...props} />); expect(screen.getByRole('spinbutton')).toHaveValue(1); }); it('displays the expected line limit value', () => { const props = setup(); render(<LokiOptionFields {...props} lineLimitValue="123" />); expect(screen.getByRole('spinbutton')).toHaveValue(123); }); }); describe('preprocessMaxLines', () => { test.each([ { inputValue: '', expected: undefined }, { inputValue: 'abc', expected: undefined }, { inputValue: '-1', expected: undefined }, { inputValue: '1', expected: 1 }, { inputValue: '100', expected: 100 }, ])('should return correct max lines value', ({ inputValue, expected }) => { expect(preprocessMaxLines(inputValue)).toBe(expected); }); });
.
Edit
..
Edit
AnnotationsQueryEditor.tsx
Edit
LokiCheatSheet.test.tsx
Edit
LokiCheatSheet.tsx
Edit
LokiContextUi.test.tsx
Edit
LokiContextUi.tsx
Edit
LokiLabelBrowser.test.tsx
Edit
LokiLabelBrowser.tsx
Edit
LokiOptionFields.test.tsx
Edit
LokiOptionFields.tsx
Edit
LokiQueryEditor.test.tsx
Edit
LokiQueryEditor.tsx
Edit
LokiQueryEditorByApp.test.tsx
Edit
LokiQueryEditorByApp.tsx
Edit
LokiQueryEditorForAlerting.tsx
Edit
LokiQueryField.test.tsx
Edit
LokiQueryField.tsx
Edit
VariableQueryEditor.test.tsx
Edit
VariableQueryEditor.tsx
Edit
monaco-query-field
Edit
stats.test.ts
Edit
stats.ts
Edit
types.ts
Edit