mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { mount } from 'enzyme';
|
|
import React from 'react';
|
|
|
|
import { SortOrder } from 'app/core/utils/richHistory';
|
|
|
|
import { ExploreId } from '../../../types/explore';
|
|
|
|
import { RichHistoryStarredTab, Props } from './RichHistoryStarredTab';
|
|
|
|
jest.mock('../state/selectors', () => ({ getExploreDatasources: jest.fn() }));
|
|
|
|
const setup = (propOverrides?: Partial<Props>) => {
|
|
const props: Props = {
|
|
queries: [],
|
|
sortOrder: SortOrder.Ascending,
|
|
activeDatasourceOnly: false,
|
|
datasourceFilters: [],
|
|
exploreId: ExploreId.left,
|
|
onChangeSortOrder: jest.fn(),
|
|
onSelectDatasourceFilters: jest.fn(),
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
const wrapper = mount(<RichHistoryStarredTab {...props} />);
|
|
return wrapper;
|
|
};
|
|
|
|
describe('RichHistoryStarredTab', () => {
|
|
describe('sorter', () => {
|
|
it('should render sorter', () => {
|
|
const wrapper = setup();
|
|
expect(wrapper.find({ 'aria-label': 'Sort queries' })).toHaveLength(1);
|
|
});
|
|
});
|
|
|
|
describe('select datasource', () => {
|
|
it('should render select datasource if activeDatasourceOnly is false', () => {
|
|
const wrapper = setup();
|
|
expect(wrapper.find({ 'aria-label': 'Filter queries for data sources(s)' }).exists()).toBeTruthy();
|
|
});
|
|
|
|
it('should not render select datasource if activeDatasourceOnly is true', () => {
|
|
const wrapper = setup({ activeDatasourceOnly: true });
|
|
expect(wrapper.find({ 'aria-label': 'Filter queries for data sources(s)' }).exists()).toBeFalsy();
|
|
});
|
|
});
|
|
});
|