Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import React from 'react';
  2. import { Info } from './info';
  3. import { assert } from 'chai';
  4. import { shallow } from 'enzyme';
  5. import Sinon from 'sinon';
  6.  
  7. const infoMessage = 'Something important here';
  8.  
  9. describe('Info pure', function () {
  10. it('Renders "show info" and calls toggle on click', function () {
  11. const spy = Sinon.spy();
  12. const wrapper = shallow(
  13. <Info on={false} toggle={spy}>
  14. {infoMessage}
  15. </Info>
  16. );
  17. assert.isOk(wrapper);
  18. assert.notInclude(wrapper.html(), infoMessage);
  19. wrapper.find('#toggleInfo').simulate('click');
  20. assert.isTrue(spy.called);
  21. });
  22.  
  23. it('Renders info and "Hide info" button and calls toggle on click', function () {
  24. const spy = Sinon.spy();
  25. const wrapper = shallow(
  26. <Info on={true} toggle={spy}>
  27. {infoMessage}
  28. </Info>
  29. );
  30. assert.isOk(wrapper);
  31. assert.include(wrapper.html(), infoMessage);
  32. wrapper.find('#toggleInfo').simulate('click');
  33. assert.isTrue(spy.called);
  34. });
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement