mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -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
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { RichHistorySettingsTab, RichHistorySettingsProps } from './RichHistorySettingsTab';
|
|
|
|
const setup = (propOverrides?: Partial<RichHistorySettingsProps>) => {
|
|
const props: RichHistorySettingsProps = {
|
|
retentionPeriod: 14,
|
|
starredTabAsFirstTab: true,
|
|
activeDatasourceOnly: false,
|
|
onChangeRetentionPeriod: jest.fn(),
|
|
toggleStarredTabAsFirstTab: jest.fn(),
|
|
toggleactiveDatasourceOnly: jest.fn(),
|
|
deleteRichHistory: jest.fn(),
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
return render(<RichHistorySettingsTab {...props} />);
|
|
};
|
|
|
|
describe('RichHistorySettings', () => {
|
|
it('should render component with correct retention period', () => {
|
|
setup();
|
|
expect(screen.queryByText('2 weeks')).toBeInTheDocument();
|
|
});
|
|
it('should render component with correctly checked starredTabAsFirstTab and uncheched toggleActiveDatasourceOnly settings', () => {
|
|
setup();
|
|
const checkboxes = screen.getAllByRole('checkbox');
|
|
expect(checkboxes.length).toBe(2);
|
|
expect(checkboxes[0]).toHaveAttribute('checked');
|
|
expect(checkboxes[1]).not.toHaveAttribute('checked');
|
|
});
|
|
});
|