Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takahirohonda/25d6f9d63c9266128dd4a0e6b36ebbd3 to your computer and use it in GitHub Desktop.
Save takahirohonda/25d6f9d63c9266128dd4a0e6b36ebbd3 to your computer and use it in GitHub Desktop.
setting-up-unit-tests-for-react-with-mocha-jsdom-and-enzyme-1
import React from 'react'
import expect from 'expect'
import { shallow, mount } from 'enzyme'
import FormInput from '../form-elements/FormInput'
describe('Form Component', () => {
it('should returns correct label for firstname', () => {
const wrapper = mount(<FormInput
inputType = "firstname"
changeHandler={() => {return null}}
/>)
expect(wrapper.find('label').text()).toEqual('First name');
});
it('should return correct placeholder for firstname', () => {
const wrapper = mount(<FormInput
inputType = "firstname"
changeHandler={() => {return null}}
/>)
const input = wrapper.find('input');
expect(input.prop('placeholder')).toEqual('Enter your first name');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment