mirror of
https://github.com/grafana/grafana.git
synced 2025-09-25 16:54:15 +08:00

Adds a config section with derived fields which is a config that allows you to create a new field based on a regex matcher run on a log message create DataLink to it which is the clickable in the log detail.
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import { ConfigEditor } from './ConfigEditor';
|
|
import { createDefaultConfigOptions } from '../mocks';
|
|
import { DataSourceHttpSettings } from '@grafana/ui';
|
|
import { DerivedFields } from './DerivedFields';
|
|
|
|
describe('ConfigEditor', () => {
|
|
it('should render without error', () => {
|
|
mount(<ConfigEditor onOptionsChange={() => {}} options={createDefaultConfigOptions()} />);
|
|
});
|
|
|
|
it('should render the right sections', () => {
|
|
const wrapper = mount(<ConfigEditor onOptionsChange={() => {}} options={createDefaultConfigOptions()} />);
|
|
expect(wrapper.find(DataSourceHttpSettings).length).toBe(1);
|
|
expect(wrapper.find({ label: 'Maximum lines' }).length).toBe(1);
|
|
expect(wrapper.find(DerivedFields).length).toBe(1);
|
|
});
|
|
|
|
it('should pass correct data to onChange', () => {
|
|
const onChangeMock = jest.fn();
|
|
const wrapper = mount(<ConfigEditor onOptionsChange={onChangeMock} options={createDefaultConfigOptions()} />);
|
|
const inputWrapper = wrapper.find({ label: 'Maximum lines' }).find('input');
|
|
(inputWrapper.getDOMNode() as any).value = 42;
|
|
inputWrapper.simulate('change');
|
|
expect(onChangeMock.mock.calls[0][0].jsonData.maxLines).toBe('42');
|
|
});
|
|
});
|