SlideShow.test.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. import React from 'react';
  2. import SlideShow from '../components/SlideShow/';
  3. import { mount } from 'enzyme';
  4. describe('<SlideShow />', () => {
  5. it('The SlideShow has 5 slides', () => {
  6. const SlideShowWindow = mount(<SlideShow />);
  7. expect(SlideShowWindow.find('.slide').length).toBe(5);
  8. });
  9. it('Clicking on buttons does not change the center position', () => {
  10. const SlideShowWindow = mount(<SlideShow />);
  11. expect(SlideShowWindow.find('.slide').at(2).hasClass('center')).toBe(true);
  12. SlideShowWindow.find('button.right').simulate('click');
  13. expect(SlideShowWindow.find('.slide').at(2).hasClass('center')).toBe(true);
  14. SlideShowWindow.find('button.left').simulate('click');
  15. expect(SlideShowWindow.find('.slide').at(2).hasClass('center')).toBe(true);
  16. });
  17. it('Clicking on buttons add z-index style to the corresponding box', () => {
  18. const SlideShowWindow = mount(<SlideShow />);
  19. SlideShowWindow.find('button.left').simulate('click');
  20. expect(SlideShowWindow.find('.slide4').props().style.zIndex).toBeTruthy();
  21. expect(SlideShowWindow.find('.slide0').props().style.zIndex).toBeFalsy();
  22. SlideShowWindow.find('button.right').simulate('click');
  23. expect(SlideShowWindow.find('.slide0').props().style.zIndex).toBeTruthy();
  24. expect(SlideShowWindow.find('.slide4').props().style.zIndex).toBeFalsy();
  25. });
  26. });