视频播放器仓库

Overlay.test.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import Overlay from './Overlay';
  4. import styles from './Overlay.css';
  5. import PlayArrow from './../Icon/play_arrow.svg';
  6. import Spin from './../Icon/spin.svg';
  7. import Report from './../Icon/report.svg';
  8. describe('Overlay', () => {
  9. let component;
  10. beforeAll(() => {
  11. component = shallow(<Overlay />);
  12. });
  13. it('should accept a className prop and append it to the components class', () => {
  14. const newClassNameString = 'a new className';
  15. expect(component.prop('className'))
  16. .toContain(styles.component);
  17. component.setProps({
  18. className: newClassNameString
  19. });
  20. expect(component.prop('className'))
  21. .toContain(styles.component);
  22. expect(component.prop('className'))
  23. .toContain(newClassNameString);
  24. });
  25. it('shows a PlayArrow icon if paused', () => {
  26. component.setProps({
  27. paused: true
  28. });
  29. expect(component.html())
  30. .toContain(PlayArrow);
  31. });
  32. it('shows Report icon if error regardless of loading or paused state', () => {
  33. component.setProps({
  34. error: true,
  35. loading: true,
  36. paused: true
  37. });
  38. expect(component.html())
  39. .toContain(Report);
  40. });
  41. it('shows Spin icon if loading regardless of paused state', () => {
  42. component.setProps({
  43. loading: true,
  44. paused: true,
  45. error: false
  46. });
  47. expect(component.html())
  48. .toContain(Spin);
  49. });
  50. });