2023-04-26 15:17:23 +00:00
|
|
|
import { render, screen, act } from '@testing-library/react';
|
|
|
|
import { TelemetryApproval } from './telemetry-approval';
|
|
|
|
|
|
|
|
describe('TelemetryApproval', () => {
|
|
|
|
it('click on checkbox should be properly handled', () => {
|
2023-05-02 21:01:33 +00:00
|
|
|
const helpText = 'My help text';
|
|
|
|
render(<TelemetryApproval helpText={helpText} />);
|
2023-04-26 15:17:23 +00:00
|
|
|
expect(screen.getByRole('checkbox')).toHaveAttribute(
|
|
|
|
'data-state',
|
|
|
|
'unchecked'
|
|
|
|
);
|
|
|
|
act(() => {
|
|
|
|
screen.getByRole('checkbox').click();
|
|
|
|
});
|
|
|
|
expect(screen.getByRole('checkbox')).toHaveAttribute(
|
|
|
|
'data-state',
|
|
|
|
'checked'
|
|
|
|
);
|
2023-05-02 21:01:33 +00:00
|
|
|
expect(screen.getByText('Share usage data')).toBeInTheDocument();
|
|
|
|
expect(screen.getByText(helpText)).toBeInTheDocument();
|
2023-04-26 15:17:23 +00:00
|
|
|
});
|
|
|
|
});
|