Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import { shallow } from 'enzyme';
  2. import React from 'react';
  3. import testId from '../../main/tests/testIdSelector';
  4. import ButtonsContainer from '../ButtonsContainer';
  5.  
  6. type ShallowComponentType = ShallowWrapper<any, any, ButtonsContainer>;
  7.  
  8. describe('ButtonsContainer', () => {
  9. let component: any;
  10.  
  11. beforeEach(() => {
  12. component = createComponent();
  13. });
  14.  
  15. it('should initially have the left button visible', () => {
  16. expect(component.instance().state.leftButtonVisible).toBeTruthy();
  17. });
  18.  
  19. describe('given visible left button', () => {
  20. describe('when switching to right button visible', () => {
  21. beforeEach(() => {
  22. component.instance().updateVisibleButton();
  23. });
  24.  
  25. it('should hide the left button', () => {
  26. expect(component.instance().state.leftButtonVisible).toBeFalsy();
  27. });
  28.  
  29. it('should display the right button', () => {
  30. expect(component.instance().state.rightButtonVisible).toBeTruthy();
  31. });
  32. });
  33. });
  34.  
  35. function createComponent(state?: any): ShallowComponentType {
  36. const wrapper = shallow<ButtonsContainer>(<ButtonsContainer />);
  37. wrapper.setState(state);
  38.  
  39. return wrapper;
  40. }
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement