Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { shallow } from 'enzyme';
- import App from './App';
- // Pro Tip: You should write tests from a users point of view
- describe('Counter Component', ()=> {
- it('starts with a counter of 0', ()=>{
- const wrapper = shallow(<App/>);
- const countState = wrapper.find('p').text();
- expect(countState).toEqual('0');
- });
- });
- describe('Counter Component', ()=> {
- it('button increment adds 1 to the value', ()=>{
- const wrapper = shallow(<App/>);
- const btnInc = wrapper.find('.btn-inc')
- btnInc.simulate('click');
- const value = wrapper.find('p').text();
- expect(value).toEqual('1');
- });
- });
- describe('Counter Component', ()=> {
- it('button decrement subtracts 1 from the value', ()=>{
- const wrapper = shallow(<App/>);
- const btnDec = wrapper.find('.btn-dec')
- btnDec.simulate('click');
- const value = wrapper.find('p').text();
- expect(value).toEqual('0');
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement