forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourcesTree.spec.js
More file actions
84 lines (71 loc) · 2.1 KB
/
Copy pathSourcesTree.spec.js
File metadata and controls
84 lines (71 loc) · 2.1 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from "react";
import { shallow } from "enzyme";
import SourcesTree from "../../components/PrimaryPanes/SourcesTree";
import * as I from "immutable";
function generateDefaults(overrides) {
return {
autoExpandAll: true,
selectLocation: jest.fn(),
setExpandedState: jest.fn(),
sources: I.Map({
"server1.conn13.child1/39": createMockSource(
"server1.conn13.child1/39",
"http://mdn.com/one.js"
),
"server1.conn13.child1/40": createMockSource(
"server1.conn13.child1/40",
"http://mdn.com/two.js"
),
"server1.conn13.child1/41": createMockSource(
"server1.conn13.child1/41",
"http://mdn.com/three.js"
)
}),
debuggeeUrl: "http://mdn.com",
projectRoot: "",
...overrides
};
}
function render(overrides = {}) {
const props = generateDefaults(overrides);
const component = shallow(<SourcesTree.WrappedComponent {...props} />);
component.instance().shouldComponentUpdate = () => true;
return { component, props };
}
function createMockSource(id, url) {
return I.Map({
id: id,
url: url,
isPrettyPrinted: false,
isWasm: false,
sourceMapURL: null,
isBlackBoxed: false,
loadedState: "unloaded"
});
}
describe("SourcesTree", () => {
it("Should show the tree with nothing expanded", async () => {
const { component } = render();
expect(component).toMatchSnapshot();
});
describe("When loading initial source", () => {
it("Shows the tree with one.js, two.js and three.js expanded", async () => {
const { component, props } = render({});
await component.setProps({
...props,
expanded: ["one.js", "two.js", "three.js"]
});
expect(component).toMatchSnapshot();
});
});
describe("After changing expanded nodes", () => {
it("Shows the tree with four.js, five.js and six.js expanded", async () => {
const { component, props } = render({});
await component.setProps({
...props,
expanded: ["four.js", "five.js", "six.js"]
});
expect(component).toMatchSnapshot();
});
});
});