-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathcounter.test.js
More file actions
36 lines (34 loc) · 1.29 KB
/
counter.test.js
File metadata and controls
36 lines (34 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import React from "react";
import {mount } from "enzyme";
import ReactDOM from "react-dom";
import {Provider} from "react-redux";
import store from "../store";
import CounterButtonContainer from "../containers/CounterButtonContainer";
import CounterContainer from "../containers/CounterContainer";
let wrapper = null;
beforeAll(()=>{
wrapper = mount(<Provider store={store}><div><CounterButtonContainer /><CounterContainer /></div></Provider>);
})
beforeEach(() => {
store.getState().currentCount = 0;
});
describe("CounterButtonContainer", () => {
it("Increase button increases the currentCount to 4 and shows in Counter", () => {
var increaseButton = wrapper.find("button").at(0);
increaseButton.simulate("click");
increaseButton.simulate("click");
increaseButton.simulate("click");
increaseButton.simulate("click");
var div = wrapper.find("div").at(2);
expect(div.text()).toBe("Counter: 4");
});
it("Decrease button decreases the currentCount to -4 and shows in Counter", () => {
var increaseButton = wrapper.find("button").at(1);
increaseButton.simulate("click");
increaseButton.simulate("click");
increaseButton.simulate("click");
increaseButton.simulate("click");
var div = wrapper.find("div").at(2);
expect(div.text()).toBe("Counter: -4");
});
});