mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* updated * Experimenting with event bus with legacy support * Before switch to emitter * EventBus & Emitter unification * Everything using new EventBus * Making progress * Fixing merge issues * Final merge issues * Updated * Updates * Fix * Updated * Update * Update * Rename methods to publish and subscribe * Ts fixes * Updated * updated * fixing doc warnigns * removed unused file
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import { QueryRow, QueryRowProps } from './QueryRow';
|
|
import { shallow } from 'enzyme';
|
|
import { ExploreId } from 'app/types/explore';
|
|
import { EventBusExtended } from '@grafana/data';
|
|
import { DataSourceApi, TimeRange, AbsoluteTimeRange, PanelData } from '@grafana/data';
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const props: QueryRowProps = {
|
|
exploreId: ExploreId.left,
|
|
index: 1,
|
|
exploreEvents: {} as EventBusExtended,
|
|
changeQuery: jest.fn(),
|
|
datasourceInstance: {} as DataSourceApi,
|
|
highlightLogsExpressionAction: jest.fn() as any,
|
|
history: [],
|
|
query: {
|
|
refId: 'A',
|
|
},
|
|
modifyQueries: jest.fn(),
|
|
range: {} as TimeRange,
|
|
absoluteRange: {} as AbsoluteTimeRange,
|
|
removeQueryRowAction: jest.fn() as any,
|
|
runQueries: jest.fn(),
|
|
queryResponse: {} as PanelData,
|
|
latency: 1,
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
const wrapper = shallow(<QueryRow {...props} />);
|
|
return wrapper;
|
|
};
|
|
|
|
const QueryEditor = () => <div />;
|
|
|
|
describe('QueryRow', () => {
|
|
describe('if datasource does not have Explore query fields ', () => {
|
|
it('it should render QueryEditor if datasource has it', () => {
|
|
const wrapper = setup({ datasourceInstance: { components: { QueryEditor } } });
|
|
expect(wrapper.find(QueryEditor)).toHaveLength(1);
|
|
});
|
|
it('it should not render QueryEditor if datasource does not have it', () => {
|
|
const wrapper = setup({ datasourceInstance: { components: {} } });
|
|
expect(wrapper.find(QueryEditor)).toHaveLength(0);
|
|
});
|
|
});
|
|
});
|