2019-11-11 12:58:19 +00:00
|
|
|
import React from "react";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import TabContainer from ".";
|
2019-09-08 15:54:18 +00:00
|
|
|
|
2019-11-11 12:58:19 +00:00
|
|
|
const array_items = [
|
|
|
|
{
|
|
|
|
key: "tab0",
|
|
|
|
title: "Title1",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<button>BUTTON</button> <button>BUTTON</button>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<button>BUTTON</button> <button>BUTTON</button>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<button>BUTTON</button> <button>BUTTON</button>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "tab1",
|
|
|
|
title: "Title2",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<label>LABEL</label> <label>LABEL</label> <label>LABEL</label>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label>LABEL</label> <label>LABEL</label> <label>LABEL</label>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label>LABEL</label> <label>LABEL</label> <label>LABEL</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "tab2",
|
|
|
|
title: "Title3",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<input></input> <input></input> <input></input>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<input></input> <input></input> <input></input>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<input></input> <input></input> <input></input>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "tab3",
|
|
|
|
title: "Title4",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<button>BUTTON</button> <button>BUTTON</button>{" "}
|
|
|
|
<button>BUTTON</button>{" "}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<button>BUTTON</button> <button>BUTTON</button>{" "}
|
|
|
|
<button>BUTTON</button>{" "}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<button>BUTTON</button> <button>BUTTON</button>{" "}
|
|
|
|
<button>BUTTON</button>{" "}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "tab4",
|
|
|
|
title: "Title5",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<label>LABEL</label> <label>LABEL</label> <label>LABEL</label>{" "}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<label>LABEL</label> <label>LABEL</label> <label>LABEL</label>{" "}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<label>LABEL</label> <label>LABEL</label> <label>LABEL</label>{" "}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
describe("<TabContainer />", () => {
|
|
|
|
it("renders without error", () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<TabContainer>
|
|
|
|
{[
|
2019-09-08 15:54:18 +00:00
|
|
|
{
|
2019-11-11 12:58:19 +00:00
|
|
|
key: "0",
|
|
|
|
title: "Title1",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</>
|
|
|
|
<>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</>
|
|
|
|
<>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</>
|
|
|
|
</div>
|
|
|
|
)
|
2019-09-08 15:54:18 +00:00
|
|
|
}
|
2019-11-11 12:58:19 +00:00
|
|
|
]}
|
|
|
|
</TabContainer>
|
2019-09-08 15:54:18 +00:00
|
|
|
);
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-11-11 12:58:19 +00:00
|
|
|
|
|
|
|
it("TabContainer check Compare dates function", () => {
|
|
|
|
const item = [
|
|
|
|
{
|
|
|
|
key: "0",
|
|
|
|
title: "Title1",
|
|
|
|
content: (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<button>BUTTON</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
];
|
|
|
|
const wrapper = mount(
|
|
|
|
<TabContainer>{array_items}</TabContainer>
|
|
|
|
).instance();
|
|
|
|
wrapper.titleClick(2, item);
|
|
|
|
expect(wrapper.state.activeTab).toEqual(2);
|
|
|
|
});
|
2019-09-08 15:54:18 +00:00
|
|
|
});
|
2019-11-15 07:15:21 +00:00
|
|
|
|
|
|
|
it("TabsContainer not re-render test", () => {
|
|
|
|
const wrapper = mount(<TabContainer>{array_items}</TabContainer>).instance();
|
|
|
|
const shouldUpdate = wrapper.shouldComponentUpdate(wrapper.props, wrapper.state);
|
|
|
|
expect(shouldUpdate).toBe(false);
|
|
|
|
});
|