SHARE
TWEET

Untitled

a guest Jun 12th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import App from './App';
  4.  
  5. // Pro Tip: You should write tests from a users point of view
  6.  
  7.  
  8. describe('Counter Component', ()=> {
  9.   it('starts with a counter of 0', ()=>{
  10.     const wrapper = shallow(<App/>);
  11.    
  12.     const countState = wrapper.find('p').text();
  13.     expect(countState).toEqual('0');
  14.   });
  15. });
  16.  
  17. describe('Counter Component', ()=> {
  18.   it('button increment adds 1 to the value', ()=>{
  19.     const wrapper = shallow(<App/>);
  20.  
  21.     const btnInc = wrapper.find('.btn-inc')
  22.     btnInc.simulate('click');
  23.     const value = wrapper.find('p').text();
  24.     expect(value).toEqual('1');
  25.   });
  26. });
  27.  
  28. describe('Counter Component', ()=> {
  29.   it('button decrement subtracts 1 from the value', ()=>{
  30.     const wrapper = shallow(<App/>);
  31.  
  32.     const btnDec = wrapper.find('.btn-dec')
  33.     btnDec.simulate('click');
  34.     const value = wrapper.find('p').text();
  35.     expect(value).toEqual('0');
  36.   });
  37. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top