forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.spec.js
More file actions
67 lines (62 loc) · 2.16 KB
/
Copy pathButton.spec.js
File metadata and controls
67 lines (62 loc) · 2.16 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
import React from "react";
import { shallow } from "enzyme";
import CloseButton from "../Button/Close";
import CommandBarButton from "../Button/CommandBarButton";
import PaneToggleButton from "../Button/PaneToggle";
describe("CloseButton", () => {
const spy = jest.fn();
const tooltip = "Close something";
const wrapper = shallow(
<CloseButton buttonClass="error" handleClick={spy} tooltip={tooltip} />
);
it("renders", () => expect(wrapper).toMatchSnapshot());
wrapper.find("button").simulate("click");
it("handleClick is called", () => expect(spy).toHaveBeenCalled());
it("tooltip is passed through", () =>
expect(wrapper.find("button").prop("title")).toEqual(tooltip));
});
describe("CommandBarButton", () => {
it("renders", () => {
expect(
shallow(
<CommandBarButton className="resume" pressed={false}>
<img />
</CommandBarButton>
)
).toMatchSnapshot();
});
});
describe("PaneToggleButton", () => {
const spy = jest.fn();
const wrapper = shallow(
<PaneToggleButton collapsed={false} handleClick={spy} position="start" />
);
it("renders start", () => expect(wrapper).toMatchSnapshot());
it("renders start horizontal", () => {
wrapper.setProps({ horizontal: true });
expect(wrapper).toMatchSnapshot();
});
it("renders start collapsed", () => {
wrapper.setProps({ collapsed: true, horizontal: false });
expect(wrapper).toMatchSnapshot();
});
it("renders end", () => {
wrapper.setProps({ position: "end" });
expect(wrapper).toMatchSnapshot();
});
it("renders end horizontal", () => {
wrapper.setProps({ horizontal: true });
expect(wrapper).toMatchSnapshot();
});
it("renders end collapsed", () => {
wrapper.setProps({ collapsed: true, horizontal: false });
expect(wrapper).toMatchSnapshot();
});
it("handleClick is called", () => {
wrapper.find("CommandBarButton").simulate("click");
expect(spy).toHaveBeenCalledWith("end", true);
});
});