Last active
July 24, 2019 10:27
-
-
Save takahirohonda/25d6f9d63c9266128dd4a0e6b36ebbd3 to your computer and use it in GitHub Desktop.
setting-up-unit-tests-for-react-with-mocha-jsdom-and-enzyme-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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