Skip to content

Commit

Permalink
#148 Autoplay and stop on hover causes a warning.
Browse files Browse the repository at this point in the history
- Added tests for the internal state isMouseEntered and tests for enabeling and disabeling the auto play function on mouse enter / leave.
  • Loading branch information
Alex Buis authored and Alex Buis committed Jul 4, 2017
1 parent 2ba4249 commit ccf032d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/__tests__/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,34 @@ describe("Slider", function() {
});
});

describe('Mouse enter/leave', () => {
describe('onMouseEnter', () => {
it('should set isMouseEntered to true', () => {
componentInstance.stopOnHover();
expect(componentInstance.state.isMouseEntered).toBe(true);
});

it('should stop auto play when hovering', () => {
componentInstance.clearAutoPlay = jest.genMockFunction();
componentInstance.stopOnHover();
expect(componentInstance.clearAutoPlay.mock.calls.length).toBe(1);
});
});

describe('onMouseLeave', () => {
it('should set isMouseEntered to false', () => {
componentInstance.startOnLeave();
expect(componentInstance.state.isMouseEntered).toBe(false);
});

it('should start auto play again after hovering', () => {
componentInstance.autoPlay = jest.genMockFunction();
componentInstance.startOnLeave();
expect(componentInstance.autoPlay.mock.calls.length).toBe(1);
});
});
});

describe('Swiping', () => {
describe('onSwipeStart', () => {
it('should set swiping to true', () => {
Expand Down

0 comments on commit ccf032d

Please sign in to comment.