视频播放器仓库

Fullscreen.test.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import Fullscreen from './Fullscreen';
  4. import styles from './Fullscreen.css';
  5. describe('Fullscreen', () => {
  6. let component;
  7. beforeAll(() => {
  8. component = shallow(
  9. <Fullscreen ariaLabel="Fullscreen" />
  10. );
  11. });
  12. it('should accept a className prop and append it to the components class', () => {
  13. const newClassNameString = 'a new className';
  14. expect(component.prop('className'))
  15. .toContain(styles.component);
  16. component.setProps({
  17. className: newClassNameString
  18. });
  19. expect(component.prop('className'))
  20. .toContain(styles.component);
  21. expect(component.prop('className'))
  22. .toContain(newClassNameString);
  23. });
  24. it('triggers \'onClick\' prop when the button is clicked', () => {
  25. const spy = jest.fn();
  26. component.setProps({
  27. onClick: spy
  28. });
  29. expect(spy)
  30. .not.toHaveBeenCalled();
  31. component.find('button').simulate('click');
  32. expect(spy)
  33. .toHaveBeenCalled();
  34. });
  35. it('has correct aria-label', () => {
  36. expect(component.find('button').prop('aria-label'))
  37. .toEqual('Fullscreen');
  38. });
  39. });