Skip to content

Instantly share code, notes, and snippets.

View sanjsanj's full-sized avatar

Sanjay Purswani sanjsanj

View GitHub Profile
describe('AddTodo component', () => {
...
it('Should have one input', () => {
const component = shallow(<AddTodo />);
expect(component.find('.todo-input').length).toEqual(1);
});
});
import React from 'react';
const AddTodo = () => (
<div>
<input className="todo-input" />
</div>
);
export default AddTodo;
/* global expect, it, describe */
describe('AddTodo component', () => {
...
describe('Add todo button', () => {
it('Should exist', () => {
const component = shallow(<AddTodo />);
expect(component.find('.todo-submit').length).toEqual(1);
});
import React from 'react';
import AddTodo from './components/addTodo/';
const App = () => (
<div>
<h1>Todo list</h1>
<AddTodo />
</div>
);
import React from 'react';
const AddTodo = () => (
<div>
<form>
<input className="todo-input" />
<button type="submit" className="todo-submit">
Add Todo
</button>
/* global expect, it, describe, jest */
...
import { shallow, mount } from 'enzyme';
...
describe('AddTodo component', () => {
...
describe('Add todo button', () => {
import React from 'react';
import PropTypes from 'prop-types';
const AddTodo = ({ submitTodo }) => {
let input;
return (
<div>
<form
onSubmit={(event) => {
/* global expect, it, describe, jest, beforeEach */
import React from 'react';
import { shallow, mount } from 'enzyme';
import AddTodo from '.';
describe('AddTodo component', () => {
let component;
const submitMock = jest.fn();
/* global it, expect */
import React from 'react';
import { shallow } from 'enzyme';
import App from './App';
it('App renders without crashing', () => {
const component = shallow(<App submitTodo={() => {}} />);
expect(component.exists()).toEqual(true);
});
import React from 'react';
import AddTodo from './components/addTodo/';
const App = () => (
<div>
<h1>Todo list</h1>
<AddTodo submitTodo={() => {}} />
</div>
);