Skip to content

Commit

Permalink
test: add test for #256
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoidjk committed Jun 1, 2017
1 parent 7ef40ba commit 756dcc8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Range.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import React from 'react';
import { render, mount } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import Range from '../src/Range';
import createSliderWithTooltip from '../src/createSliderWithTooltip';

const RangeWithTooltip = createSliderWithTooltip(Range);

describe('Range', () => {
it('should render Range with correct DOM structure', () => {
Expand Down Expand Up @@ -75,4 +78,17 @@ describe('Range', () => {
expect(wrapper.instance().getSlider().state.bounds.length).toBe(2);
expect(wrapper.find('.rc-slider-handle').length).toBe(2);
});

// https://github.com/react-component/slider/pull/256
it('should handle mutli handle mouseEnter correctly', () => {
const wrapper = mount(<RangeWithTooltip min={0} max={1000} defaultValue={[50, 55]} />);
wrapper.find('.rc-slider-handle').at(0).simulate('mouseEnter');
expect(wrapper.state().visibles[0]).toBe(true);
wrapper.find('.rc-slider-handle').at(1).simulate('mouseEnter');
expect(wrapper.state().visibles[1]).toBe(true);
wrapper.find('.rc-slider-handle').at(0).simulate('mouseLeave');
expect(wrapper.state().visibles[0]).toBe(false);
wrapper.find('.rc-slider-handle').at(1).simulate('mouseLeave');
expect(wrapper.state().visibles[1]).toBe(false);
});
});

0 comments on commit 756dcc8

Please sign in to comment.