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
|
import { _CollapsibleSection as CollapsibleSection } from "content-src/components/CollapsibleSection/CollapsibleSection";
import { ErrorBoundary } from "content-src/components/ErrorBoundary/ErrorBoundary";
import { mount } from "enzyme";
import React from "react";
const DEFAULT_PROPS = {
id: "cool",
className: "cool-section",
title: "Cool Section",
prefName: "collapseSection",
collapsed: false,
eventSource: "foo",
document: {
addEventListener: () => {},
removeEventListener: () => {},
visibilityState: "visible",
},
dispatch: () => {},
Prefs: { values: { featureConfig: {} } },
};
describe("CollapsibleSection", () => {
let wrapper;
function setup(props = {}) {
const customProps = Object.assign({}, DEFAULT_PROPS, props);
wrapper = mount(
<CollapsibleSection {...customProps}>foo</CollapsibleSection>
);
}
beforeEach(() => setup());
it("should render the component", () => {
assert.ok(wrapper.exists());
});
it("should render an ErrorBoundary with class section-body-fallback", () => {
assert.equal(
wrapper.find(ErrorBoundary).first().prop("className"),
"section-body-fallback"
);
});
describe("without collapsible pref", () => {
let dispatch;
beforeEach(() => {
dispatch = sinon.stub();
setup({ collapsed: undefined, dispatch });
});
it("should render the section uncollapsed", () => {
assert.isFalse(
wrapper.find(".collapsible-section").first().hasClass("collapsed")
);
});
it("should not render the arrow if no collapsible pref exists for the section", () => {
assert.lengthOf(wrapper.find(".click-target .collapsible-arrow"), 0);
});
});
describe("icon", () => {
it("no icon should be shown", () => {
assert.lengthOf(wrapper.find(".icon"), 0);
});
});
});
|