grafana/public/app/features/explore/RichHistory/RichHistorySettingsTab.test.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* 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
2022-04-22 14:33:13 +01:00

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');
});
});