import { create } from 'react-test-renderer';
import ButtonToggle from './ButtonToggle';
import Icon from './Icon';
describe('', () => {
test('Custom color', () => {
const instance = create(
,
).root;
expect(instance.find((element: any) => element.type === 'div').props.className).toContain(
'transparent',
);
});
test('Disabled state', () => {
const instance = create(
,
).root;
const { className } = instance.find((element: any) => element.type === 'div').props;
expect(className).toContain('disabled');
expect(className).not.toContain('red');
});
test('iconStart', async () => {
const instance = create(
,
).root;
// eslint-disable-next-line testing-library/await-async-query -- False positive due to 'findBy' prefix, findByType does not return a Promise!
const icon = instance.findByType(Icon);
expect(icon.props.icon).toBe('sparkle');
});
test('Default darkGray text color on transparent background', () => {
const instance = create(
,
).root;
expect(
instance.findAll((element: any) => element.type === 'div')[3]?.props.className,
).toContain('default');
});
test('accessibilityControls', () => {
const instance = create(
,
).root;
expect(
instance.find((element: any) => element.type === 'button').props['aria-controls'],
).toContain('another-element');
});
test('accessibilityLabel', () => {
const instance = create(
,
).root;
expect(
instance.find((element: any) => element.type === 'button').props['aria-label'],
).toContain('hello');
});
});