2019-01-03 16:00:55 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { render, mount } from 'enzyme';
|
|
|
|
import { renderToJson } from 'enzyme-to-json';
|
|
|
|
import { Slider } from '../src';
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
describe('Slider', function () {
|
2019-01-03 16:00:55 +03:00
|
|
|
it('renders correctly', () => {
|
|
|
|
const wrapper = render(<Slider />);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders with props', () => {
|
|
|
|
const wrapper = render(
|
|
|
|
<Slider
|
|
|
|
label="Hi"
|
|
|
|
min={1}
|
|
|
|
max={10}
|
|
|
|
value={5}
|
|
|
|
step={1}
|
|
|
|
disabled
|
|
|
|
onChange={() => {}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle the change event', () => {
|
|
|
|
const onChange = jest.fn();
|
|
|
|
const wrapper = mount(<Slider value={1} autoFocus onChange={onChange} />);
|
|
|
|
|
|
|
|
wrapper.find('input').simulate('change');
|
|
|
|
expect(onChange).toBeCalled();
|
|
|
|
expect(onChange).toBeCalledWith(1);
|
|
|
|
});
|
|
|
|
});
|