Commit dbc8a837 authored by Martin Fahl's avatar Martin Fahl

makes most tests run again

parent 34317e21
......@@ -3,11 +3,11 @@ import ReactDOM from 'react-dom';
import { App } from './App';
import renderer from "react-test-renderer";
jest.mock("../../container/InventoryList/InventoryList.js", () => ({
InventoryList: () => <div name="InventoryList" />
jest.mock("../../container/InventoryList/InventoryListContainer.js", () => ({
InventoryListContainer: () => <div name="InventoryListContainer" />
}));
jest.mock("../../presentational/Navbar/Navbar.js", () => ({
jest.mock("../Navbar/Navbar.js", () => ({
Navbar: () => <div name="Navbar" />
}));
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Filter should render as expected 1`] = `
<form
className="form-inline"
>
<form>
<div
className="md-form my-0"
>
......
import React from "react";
import InventoryList from "./InventoryList";
import renderer from "react-test-renderer";
import { shallow } from "enzyme";
jest.mock("../Filter/Filter", () => ({
Filter: () => <div name="Filter" />
}));
jest.mock("../../container/Item/Item", () => ({
Item: () => <div name="Item" />
}));
describe("InventoryList", () => {
it("should render as expected", () => {
const itemList = [{
id: 2,
name: "test",
amount: 1}];
const inventoryListComponent = renderer
.create(<InventoryList items={itemList} />)
.toJSON();
expect(inventoryListComponent).toMatchSnapshot();
});
});
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`InventoryList should render as expected 1`] = `
<div
className="container"
>
<div
className="row justify-content-md-center justify-content-center mx-auto"
>
<div
className="col-sm-12 col-md-8 col-lg-6"
>
<div
className="card mt-4 mb-4 mx-auto"
>
<div
className="card-body"
>
<div
name="Filter"
/>
<ul
className="list-group"
>
<div
name="Item"
/>
</ul>
</div>
</div>
</div>
</div>
</div>
`;
......@@ -8,126 +8,11 @@ exports[`Navbar should render as expected 1`] = `
className="navbar-brand"
href="#"
>
<svg
height="30"
style={
Object {
"enableBackground": "new 0 0 696 94",
"height": "27",
"marginTop": "26",
}
}
version="1.1"
viewBox="0 0 696 94"
x="0px"
xmlns="http://www.w3.org/2000/svg"
y="0px"
>
<g
id="Ebene_2"
>
</g>
<g
id="Ebene_1"
>
<g>
<path
className="st0"
d="M143.5,18.9c11.4,0,17.5,5.2,19.8,12.6c0.7,1.8,0.1,2.6-1.5,3.2l-3.3,1c-1.7,0.8-2.5,0.2-3.2-1.5 c-1.7-5.2-5.3-7.9-12.2-7.9c-8.2,0-12.2,4.1-12.2,11.1v14.2c0,7,4.1,11.2,12.2,11.2c6.8,0,10.6-2.9,12.3-8.2 c0.8-1.8,1.4-2.1,3.2-1.5l3.3,0.9c1.7,0.7,2.3,1.4,1.6,3.2c-3,8.4-9.4,13-20.6,13c-13.9,0-20.5-7.2-20.5-19V37.8 C122.5,26.1,129.2,18.9,143.5,18.9z"
/>
<path
className="st0"
d="M201.5,18.9c13.5,0,21.1,6.9,21.1,18v15.3c0,11.1-7.6,17.9-21.1,17.9c-13.2,0-21-6.9-21-17.9V36.9 C180.4,25.7,188.2,18.9,201.5,18.9z M201.5,26.5c-7.9,0-12.7,3.9-12.7,10.3v15.4c0,6.5,4.8,10.3,12.7,10.3c8,0,12.8-3.9,12.8-10.3 V36.8C214.3,30.4,209.5,26.5,201.5,26.5z"
/>
<path
className="st0"
d="M259.7,18.9c5.8,0,10.7,1.4,13.2,2.1V6.3c0-1.7,0.6-2.3,2.3-2.3h3.9c1.6,0,2.2,0.6,2.2,2.3v55.8 c0,3.1-0.7,3.9-3.7,5.2c-3.7,1.4-8.8,2.9-16.8,2.9c-13.8,0-20.1-6.9-20.1-18.9V38.1C240.6,25.8,246.9,18.9,259.7,18.9z M261.3,26.6c-8.5,0-12.2,4-12.2,11.7V51c0,7.5,4.1,11.5,12.4,11.5c4.1,0,7.6-0.7,10.1-1.5c1.2-0.5,1.3-0.8,1.3-1.8V28.7 C270.7,28,266.6,26.6,261.3,26.6z"
/>
<path
className="st0"
d="M321.7,18.9c14.5,0,21.2,8.4,21.2,19.4v5.5c0,2-0.8,3.3-3.5,3.3h-30.6v4.5c0,7.1,4.3,11.3,12.6,11.3 c6.7,0,10.7-2.5,13.1-6.5c1.1-1.6,2-1.8,3.7-0.8l2.5,1.3c1.7,0.8,1.9,2.1,0.8,3.7c-3.3,5.7-9.4,9.7-20.2,9.7 c-14.7,0-20.9-8.1-20.9-19.5V39C300.5,26.3,307.8,18.9,321.7,18.9z M321.7,26c-8.5,0-12.9,4.5-12.9,11.8v2.7h25.7v-2.7 C334.6,30.5,330.3,26,321.7,26z"
/>
<path
className="st0"
d="M379.2,18.9c11.4,0,17.5,5.2,19.8,12.6c0.7,1.8,0.1,2.6-1.5,3.2l-3.3,1c-1.7,0.8-2.5,0.2-3.2-1.5 c-1.7-5.2-5.3-7.9-12.2-7.9c-8.2,0-12.2,4.1-12.2,11.1v14.2c0,7,4.1,11.2,12.2,11.2c6.8,0,10.6-2.9,12.3-8.2 c0.7-1.8,1.4-2.1,3.2-1.5l3.3,0.9c1.7,0.7,2.3,1.4,1.6,3.2c-3,8.4-9.4,13-20.6,13c-13.9,0-20.5-7.2-20.5-19V37.8 C358.1,26.1,364.9,18.9,379.2,18.9z"
/>
<path
className="st0"
d="M437.1,18.9c14.5,0,21.2,8.4,21.2,19.4v5.5c0,2-0.8,3.3-3.5,3.3h-30.6v4.5c0,7.1,4.3,11.3,12.6,11.3 c6.7,0,10.7-2.5,13.1-6.5c1.1-1.6,2-1.8,3.7-0.8l2.5,1.3c1.7,0.8,1.9,2.1,0.8,3.7c-3.3,5.7-9.4,9.7-20.2,9.7 c-14.7,0-20.9-8.1-20.9-19.5V39C415.9,26.3,423.2,18.9,437.1,18.9z M437.1,26c-8.5,0-12.9,4.5-12.9,11.8v2.7H450v-2.7 C450,30.5,445.7,26,437.1,26z"
/>
<path
className="st0"
d="M498.6,18.9c13.2,0,19.1,7,19.1,18.6v29c0,1.7-0.6,2.3-2.3,2.3h-3.9c-1.7,0-2.3-0.6-2.3-2.3V37.8 c0-7.4-3.7-11.2-11.7-11.2c-4.6,0-8.3,0.8-10.9,1.7c-0.9,0.4-1.1,0.9-1.1,1.7v36.6c0,1.7-0.6,2.3-2.3,2.3h-3.9 c-1.6,0-2.2-0.6-2.2-2.3V27.3c0-2.9,0.7-4,3.6-5.3C484.3,20.6,489.8,18.9,498.6,18.9z"
/>
<path
className="st0"
d="M551.1,6.3v14h12.3c1.6,0,2.2,0.6,2.2,2.3v3.3c0,1.7-0.6,2.3-2.2,2.3h-12.3V50c0,10.2,3,12.2,12.1,12.2 c1.8,0,2.3,0.5,2.3,2.3v3.4c0,1.7-0.6,2.2-2.3,2.3c-14.9,0.4-20.5-4.2-20.5-19.9V28.1h-7.8c-1.7,0-2.3-0.6-2.3-2.3v-3.3 c0-1.7,0.6-2.3,2.3-2.3h7.8v-14c0-1.7,0.5-2.3,2.2-2.3h3.9C550.5,4.1,551.1,4.6,551.1,6.3z"
/>
<path
className="st0"
d="M605.8,18.9c1.7,0,2.3,0.6,2.3,2.3v3.2c0,1.7-0.6,2.3-2.3,2.3h-3.3c-4.6,0-8.1,0.7-10.8,1.6 c-1.2,0.5-1.3,1-1.3,1.9v36.5c0,1.7-0.6,2.3-2.3,2.3h-3.9c-1.6,0-2.2-0.6-2.2-2.3V27.1c0-2.9,0.7-4,3.6-5.3 c3.5-1.3,8.9-2.7,17.2-2.9H605.8z"
/>
<path
className="st0"
d="M632.5,22.6v44c0,1.7-0.6,2.3-2.3,2.3h-3.9c-1.7,0-2.3-0.6-2.3-2.3v-44c0-1.7,0.6-2.3,2.3-2.3h3.9 C631.9,20.3,632.5,20.9,632.5,22.6z"
/>
<path
className="st0"
d="M673,18.9c11.4,0,17.5,5.2,19.8,12.6c0.7,1.8,0.1,2.6-1.5,3.2l-3.3,1c-1.7,0.8-2.5,0.2-3.2-1.5 c-1.7-5.2-5.3-7.9-12.2-7.9c-8.2,0-12.2,4.1-12.2,11.1v14.2c0,7,4.1,11.2,12.2,11.2c6.8,0,10.6-2.9,12.3-8.2 c0.8-1.8,1.4-2.1,3.2-1.5l3.3,0.9c1.7,0.7,2.3,1.4,1.6,3.2c-3,8.4-9.4,13-20.6,13c-13.9,0-20.5-7.2-20.5-19V37.8 C651.9,26.1,658.7,18.9,673,18.9z"
/>
</g>
<linearGradient
gradientUnits="userSpaceOnUse"
id="SVGID_1_"
x1="13.6201"
x2="85.463"
y1="83.297"
y2="11.4541"
>
<stop
offset="5.000000e-02"
style={
Object {
"stopColor": "#00AED2",
}
}
/>
<stop
offset="1"
style={
Object {
"stopColor": "#87FFC5",
}
}
/>
</linearGradient>
<path
className="st1"
d="M52.7,79c-0.8-0.8-2.1-0.9-3.1-0.2c-4.4,3-9.4,4.3-13.8,4.3c-14,0-25.4-11.6-25-25.6 C11.1,43.8,22.6,33,36.2,33h26.8c2.6,0,4.9,1.8,5.2,4.4c0.4,3.1-2,5.7-5,5.7l-27.1,0c-7.3,0-13.6,5.7-13.9,13 c-0.3,7.7,5.9,14.1,13.5,14.1h26.9c18.4,0,33.7-14.5,34.1-32.9C97.2,18.5,82,3.2,63.3,3.2c-5.7,0-12.9,1.4-19.4,6.2 c-1.2,0.9-1.3,2.6-0.3,3.6l2.8,2.8c0.8,0.8,2.1,0.9,3.1,0.2c4.4-3,9.4-4.3,13.8-4.3c14,0,25.4,11.6,25,25.6 C88,50.9,76.5,61.7,62.8,61.7l-26.8,0c-2.6,0-4.9-1.8-5.2-4.4c-0.4-3.1,2-5.7,5-5.7h27.1c7.3,0,13.6-5.7,13.9-13 c0.3-7.7-5.9-14.1-13.5-14.1l-26.9,0C18,24.6,2.6,39.1,2.3,57.4C1.9,76.2,17.1,91.6,35.8,91.6c5.7,0,12.9-1.4,19.4-6.2 c1.2-0.9,1.3-2.6,0.3-3.6L52.7,79z"
/>
</g>
</svg>
<img
alt="codecentric"
height="60"
src="CC_RGB_onBlack.png"
/>
</a>
<a
className="navbar-brand"
......
import React from "react";
import { InventoryList } from "./InventoryList";
import renderer from "react-test-renderer";
import { shallow } from "enzyme";
jest.mock("../../presentational/Filter/Filter", () => ({
Filter: () => <div name="Filter" />
}));
jest.mock("../Item/Item", () => ({
Item: () => <div name="Item" />
}));
describe("InventoryList", () => {
it("should render as expected", () => {
const itemList = ["just", "a", "test"];
const inventoryListComponent = renderer
.create(<InventoryList itemList={itemList} />)
.toJSON();
expect(inventoryListComponent).toMatchSnapshot();
});
it("should hold a filter in state. Initial with value === ''", () => {
const itemList = ["just", "a", "test"];
const inventoryListComponent = shallow(
<InventoryList itemList={itemList} />
);
expect(inventoryListComponent.state("filterTerm")).toEqual("");
});
it("should update the filterTerm in state when updateFilter is called.", () => {
const itemList = ["just", "a", "test"];
const inventoryListComponent = shallow(
<InventoryList itemList={itemList} />
);
const newFilterTerm = "new filter term";
expect(inventoryListComponent.state("filterTerm")).toEqual("");
inventoryListComponent
.instance()
.updateFilter({ target: { value: newFilterTerm } });
expect(inventoryListComponent.state("filterTerm")).toEqual(newFilterTerm);
});
});
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`InventoryList should render as expected 1`] = `
Array [
<div
name="Filter"
/>,
<div
name="Item"
/>,
<div
name="Item"
/>,
<div
name="Item"
/>,
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Item should render as expected 1`] = `
<div
className="row"
<li
className="list-group-item"
>
Water
</div>
<div
className="row"
>
<div
className="col-4 col-md-6"
>
Water
</div>
<div
className="col-8 col-md-6"
>
<span
className="badge secondary badge-secondary ml-1 mr-1"
onClick={[Function]}
>
<i
aria-hidden="true"
className="fa fa-plus-square"
/>
</span>
<span
className="badge default badge-default badge-pill ml-1 mr-1"
>
0
</span>
<span
className="badge secondary badge-secondary ml-1 mr-1"
onClick={[Function]}
>
<i
aria-hidden="true"
className="fa fa-minus-square"
/>
</span>
<span
className="badge danger badge-danger ml-1 mr-1"
onClick={undefined}
>
<i
aria-hidden="true"
className="fa fa-trash"
/>
</span>
</div>
</div>
</li>
`;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment