scoreBar.spec.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. import {shallow} from 'enzyme';
  3. import ScoreBar from 'app/components/scoreBar';
  4. describe('ScoreBar', function() {
  5. let sandbox;
  6. beforeEach(function() {
  7. sandbox = sinon.sandbox.create();
  8. });
  9. afterEach(function() {
  10. sandbox.restore();
  11. });
  12. it('renders', function() {
  13. let wrapper = shallow(<ScoreBar size={60} thickness={2} score={3} />);
  14. expect(wrapper).toMatchSnapshot();
  15. });
  16. it('renders vertically', function() {
  17. let wrapper = shallow(<ScoreBar size={60} thickness={2} vertical score={2} />);
  18. expect(wrapper).toMatchSnapshot();
  19. });
  20. it('renders with score = 0', function() {
  21. let wrapper = shallow(<ScoreBar size={60} thickness={2} score={0} />);
  22. expect(wrapper).toMatchSnapshot();
  23. });
  24. it('renders with score > max score', function() {
  25. let wrapper = shallow(<ScoreBar size={60} thickness={2} score={10} />);
  26. expect(wrapper).toMatchSnapshot();
  27. });
  28. it('renders with < 0 score', function() {
  29. let wrapper = shallow(<ScoreBar size={60} thickness={2} score={-2} />);
  30. expect(wrapper).toMatchSnapshot();
  31. });
  32. it('has custom palette', function() {
  33. let wrapper = shallow(
  34. <ScoreBar
  35. vertical
  36. size={60}
  37. thickness={2}
  38. score={7}
  39. palette={['white', 'red', 'red', 'pink', 'pink', 'purple', 'purple', 'black']}
  40. />
  41. );
  42. expect(wrapper).toMatchSnapshot();
  43. });
  44. });