视频播放器仓库

Captions.test.js 940B

123456789101112131415161718192021222324252627282930313233
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import Captions from './Captions';
  4. import styles from './Captions.css';
  5. describe('Captions', () => {
  6. let component;
  7. beforeAll(() => {
  8. component = shallow(
  9. <Captions ariaLabel="Captions" />
  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('has correct aria-label', () => {
  25. expect(component.find('button').prop('aria-label'))
  26. .toEqual('Captions');
  27. });
  28. });