Skip to content

Commit 9878b18

Browse files
committed
Add Label component test
1 parent a3b46f2 commit 9878b18

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

webapp/__tests__/Label.spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from "react";
2+
import Label from "../javascript/components/Label";
3+
import { configure } from "enzyme";
4+
import Adapter from "enzyme-adapter-react-16";
5+
import { shallow, mount, render } from "enzyme";
6+
import { Provider } from "react-redux";
7+
import configureStore from "redux-mock-store";
8+
9+
const mockStore = configureStore();
10+
configure({ adapter: new Adapter() });
11+
let store, wrapper;
12+
const initialState = { label: { name: "Expensive Process", value: 32 } };
13+
14+
beforeEach(() => {
15+
store = mockStore(initialState);
16+
wrapper = mount(
17+
<Provider store={store}>
18+
<Label />
19+
</Provider>
20+
);
21+
});
22+
23+
describe("Label is correctly rendered", () => {
24+
it("Correctly renders name", () => {
25+
expect(
26+
wrapper.contains(
27+
<span className="label-name">{initialState.label.name}</span>
28+
)
29+
).toBe(true);
30+
});
31+
it("Correctly renders value", () => {
32+
expect(
33+
wrapper.contains(
34+
<span className="label-value">{initialState.label.value}</span>
35+
)
36+
).toBe(true);
37+
});
38+
});

0 commit comments

Comments
 (0)