Skip to content

Instantly share code, notes, and snippets.

@apsicle
Created October 5, 2017 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apsicle/830b81beb56f1108417617d4cea20fe4 to your computer and use it in GitHub Desktop.
Save apsicle/830b81beb56f1108417617d4cea20fe4 to your computer and use it in GitHub Desktop.
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