Created
October 5, 2017 01:39
-
-
Save apsicle/830b81beb56f1108417617d4cea20fe4 to your computer and use it in GitHub Desktop.
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 { shallow } from 'enzyme'; | |
import ExpenseForm from '../../components/ExpenseForm.js'; | |
import expenses from '../fixtures/expenses'; | |
test('should render ExpenseForm correctly', () => { | |
const wrapper = shallow(<ExpenseForm />); | |
expect(wrapper).toMatchSnapshot(); | |
}); | |
test('should render ExpenseForm correctly with expense data', () => { | |
const wrapper = shallow(<ExpenseForm expense={expenses[1]}/>); | |
expect(wrapper).toMatchSnapshot(); | |
}) | |
test('should render error for invalid form submission', () => { | |
const wrapper = shallow(<ExpenseForm />); | |
wrapper.find('form').simulate('submit', { | |
preventDefault: () => { } | |
}); | |
expect(wrapper.state('errorState')).length.toBeGreaterThan(0); // I named my property errorState | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment