import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import { axe } from 'jest-axe'; import 'jest-styled-components'; import 'jest-axe/extend-expect'; import 'regenerator-runtime/runtime'; import { Grommet } from '../../Grommet'; import { RangeInput } from '..'; describe('RangeInput', () => { test('should have no accessibility violations', async () => { const { container } = render( , ); const results = await axe(container); expect(results).toHaveNoViolations(); expect(container.firstChild).toMatchSnapshot(); }); test('renders', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('track themed', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('track themed with color and opacity', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('with min and max offset', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('onFocus', () => { const onFocus = jest.fn(); const { container, getByDisplayValue } = render( , ); fireEvent.focus(getByDisplayValue('5')); expect(onFocus).toHaveBeenCalledTimes(1); expect(container.firstChild).toMatchSnapshot(); }); test('onBlur', () => { const onBlur = jest.fn(); const { container, getByDisplayValue } = render( , ); fireEvent.blur(getByDisplayValue('5')); expect(onBlur).toHaveBeenCalledTimes(1); expect(container.firstChild).toMatchSnapshot(); }); test('onChange', () => { const onChange = jest.fn(); const { container, getByDisplayValue } = render( , ); fireEvent.change(getByDisplayValue('5'), { target: { value: '10', }, }); expect(onChange).toBeCalledTimes(1); expect(container.firstChild).toMatchSnapshot(); }); test('with single color', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('with multi color', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); });