Skip to content

Instantly share code, notes, and snippets.

@mtheoryx
Created January 14, 2017 19:36
Show Gist options
  • Save mtheoryx/fde7ad11c1c677b132aa2372e550e110 to your computer and use it in GitHub Desktop.
Save mtheoryx/fde7ad11c1c677b132aa2372e550e110 to your computer and use it in GitHub Desktop.
import React from 'react';
import { shallow } from 'enzyme';
// Subject Under Test
import App from './App';
const app = shallow(<App />);
test('Renders nested components', () => {
expect(app.find('Header').length).toEqual(1);
expect(app.find('Intro').length).toEqual(1);
expect(app.find('Students').length).toEqual(1);
expect(app.find('Summary').length).toEqual(1);
});
test('Can add a student', () => {
const add = app.find('Students').first();
const mockNewStudent = {
name: 'Jimmy Johns',
grade: 65
};
add.props().addStudent(mockNewStudent);
const addStudent = jest.fn();
expect(addStudent).toBeCalled();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment