mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* Create sorting button and functionality * Set up logs ordering * Add tests * Refactor * Refactor * Replace new button with old * Move SortOrder enum to grafana/data * Update SortOrder in test * Update context based on sort order of logs * Update used method for panel, update tests * Rename prop to logsSortOrder * Memoize resuults * Add title too button * Add disablinng of button for 1sec * Update wordiing * Update packages/grafana-data/src/utils/logs.ts Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> * Update packages/grafana-data/src/utils/logs.ts Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> * Update test by reordering logs * Clear timers, add button flipping title Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import { ExploreId } from '../../../types/explore';
|
|
import { SortOrder } from 'app/core/utils/richHistory';
|
|
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: null,
|
|
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 datasources' })).toHaveLength(1);
|
|
});
|
|
|
|
it('should not render select datasource if activeDatasourceOnly is true', () => {
|
|
const wrapper = setup({ activeDatasourceOnly: true });
|
|
expect(wrapper.find({ 'aria-label': 'Filter datasources' })).toHaveLength(0);
|
|
});
|
|
});
|
|
});
|