checkboxFancy.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import CheckboxFancy from 'sentry/components/checkboxFancy/checkboxFancy';
  3. describe('CheckboxFancy', function () {
  4. it('renders', function () {
  5. const {container} = render(<CheckboxFancy />);
  6. expect(container).toSnapshot();
  7. });
  8. it('isChecked', function () {
  9. render(<CheckboxFancy isChecked />);
  10. expect(screen.getByRole('checkbox', {checked: true})).toBeInTheDocument();
  11. expect(screen.getByTestId('icon-check-mark')).toBeInTheDocument();
  12. expect(screen.queryByTestId('icon-subtract')).not.toBeInTheDocument();
  13. });
  14. it('isIndeterminate', function () {
  15. render(<CheckboxFancy isIndeterminate />);
  16. expect(screen.getByRole('checkbox')).not.toBeChecked();
  17. expect(screen.queryByTestId('icon-check-mark')).not.toBeInTheDocument();
  18. expect(screen.getByTestId('icon-subtract')).toBeInTheDocument();
  19. });
  20. it('isDisabled', function () {
  21. render(<CheckboxFancy isDisabled />);
  22. expect(screen.getByRole('checkbox')).toHaveAttribute('aria-disabled', 'true');
  23. expect(screen.queryByTestId('icon-check-mark')).not.toBeInTheDocument();
  24. expect(screen.queryByTestId('icon-subtract')).not.toBeInTheDocument();
  25. });
  26. });