Skip to content
Permalink
Browse files

More tests

  • Loading branch information...
mkutyba committed Mar 14, 2017
1 parent 4a66507 commit 9362f8c2af1621a807f4b4b5944c86c725f6defe
@@ -7,7 +7,7 @@ class Forms extends Component {
<div>
<h2>Forms</h2>

<ul>
<ul role="navigation">
<li><NavLink to="/forms/form1">Form 1</NavLink></li>
<li><NavLink to="/forms/form2">Form 2</NavLink></li>
</ul>
@@ -18,4 +18,8 @@ class Forms extends Component {
}
}

Forms.propTypes = {
children: React.PropTypes.element.isRequired,
};

export default Forms;
@@ -0,0 +1,47 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Forms from './Forms';
import { shallow } from "enzyme";

describe('Forms', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render((
<Forms>
<span/>
</Forms>
), div);
});

it('contains header', () => {
const wrapper = shallow(
<Forms>
<span/>
</Forms>
);
const header = <h2>Forms</h2>;

expect(wrapper).toContainReact(header);
});

it('contains navigation', () => {
const wrapper = shallow(
<Forms>
<span/>
</Forms>
);

expect(wrapper.find('ul[role="navigation"]')).toBePresent();
});

it('renders children when passed in', () => {
const wrapper = shallow(
<Forms>
<div className="unique" />
</Forms>
);
const child = <div className="unique" />;

expect(wrapper).toContainReact(child);
});
});
@@ -0,0 +1,20 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Home from './Home';
import { shallow } from "enzyme";

describe('Home', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Home />, div);
});

it('contains header', () => {
const wrapper = shallow(
<Home />
);
const header = <h2>Home</h2>;

expect(wrapper).toContainReact(header);
});
});
@@ -0,0 +1,26 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Lawsuit from './Lawsuit';
import { shallow } from "enzyme";

describe('Lawsuit', () => {
const props = {
params: {
lawsuitName: "lawsuit name 1",
}
};

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Lawsuit {...props} />, div);
});

it('contains header with lawsuit name', () => {
const form = shallow(
<Lawsuit {...props} />
);
const header = <h3>lawsuit name 1</h3>;

expect(form).toContainReact(header);
});
});
@@ -7,7 +7,7 @@ class Lawsuits extends Component {
<div>
<h2>Lawsuits</h2>

<ul>
<ul role="navigation">
<li><NavLink to="/lawsuits/lawsuit1">Lawsuit 1</NavLink></li>
<li><NavLink to="/lawsuits/lawsuit2">Lawsuit 2</NavLink></li>
</ul>
@@ -18,4 +18,8 @@ class Lawsuits extends Component {
}
}

Lawsuits.propTypes = {
children: React.PropTypes.element.isRequired,
};

export default Lawsuits;
@@ -0,0 +1,47 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Lawsuits from './Lawsuits';
import { shallow } from "enzyme";

describe('Lawsuits', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render((
<Lawsuits>
<span/>
</Lawsuits>
), div);
});

it('contains header', () => {
const wrapper = shallow(
<Lawsuits>
<span/>
</Lawsuits>
);
const header = <h2>Lawsuits</h2>;

expect(wrapper).toContainReact(header);
});

it('contains navigation', () => {
const wrapper = shallow(
<Lawsuits>
<span/>
</Lawsuits>
);

expect(wrapper.find('ul[role="navigation"]')).toBePresent();
});

it('renders children when passed in', () => {
const wrapper = shallow(
<Lawsuits>
<div className="unique" />
</Lawsuits>
);
const child = <div className="unique" />;

expect(wrapper).toContainReact(child);
});
});

0 comments on commit 9362f8c

Please sign in to comment.
You can’t perform that action at this time.