You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

  1. import React from 'react';
  2. import Avatar from '../../../app/javascript/mastodon/components/avatar';
  3. import { expect } from 'chai';
  4. import { render } from 'enzyme';
  5. import { fromJS } from 'immutable';
  6. describe('<Avatar />', () => {
  7. const account = fromJS({
  8. username: 'alice',
  9. acct: 'alice',
  10. display_name: 'Alice',
  11. avatar: '/animated/alice.gif',
  12. avatar_static: '/static/alice.jpg',
  13. });
  14. const size = 100;
  15. const animated = render(<Avatar account={account} animate size={size} />);
  16. const still = render(<Avatar account={account} size={size} />);
  17. // Autoplay
  18. xit('renders a div element with the given src as background', () => {
  19. expect(animated.find('div')).to.have.style('background-image', `url(${account.get('avatar')})`);
  20. });
  21. xit('renders a div element of the given size', () => {
  22. ['width', 'height'].map((attr) => {
  23. expect(animated.find('div')).to.have.style(attr, `${size}px`);
  24. });
  25. });
  26. // Still
  27. xit('renders a div element with the given static src as background if not autoplay', () => {
  28. expect(still.find('div')).to.have.style('background-image', `url(${account.get('avatar_static')})`);
  29. });
  30. xit('renders a div element of the given size if not autoplay', () => {
  31. ['width', 'height'].map((attr) => {
  32. expect(still.find('div')).to.have.style(attr, `${size}px`);
  33. });
  34. });
  35. // TODO add autoplay test if possible
  36. });