2022-04-06 10:26:33 -05:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-04-12 11:55:39 -05:00
|
|
|
import { RichHistorySettingsTab, RichHistorySettingsProps } from './RichHistorySettingsTab';
|
2020-03-17 17:24:27 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2022-04-12 11:55:39 -05:00
|
|
|
return render(<RichHistorySettingsTab {...props} />);
|
2020-03-17 17:24:27 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('RichHistorySettings', () => {
|
|
|
|
it('should render component with correct retention period', () => {
|
2022-04-06 10:26:33 -05:00
|
|
|
setup();
|
|
|
|
expect(screen.queryByText('2 weeks')).toBeInTheDocument();
|
2020-03-17 17:24:27 -05:00
|
|
|
});
|
2022-04-06 10:26:33 -05:00
|
|
|
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');
|
2020-03-17 17:24:27 -05:00
|
|
|
});
|
|
|
|
});
|