Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit da57ac1

Browse files
committed
Add a test for block node
1 parent d73b177 commit da57ac1

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

packages/devtools-reps/src/object-inspector/tests/component/__snapshots__/expand.js.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ exports[`ObjectInspector - state does not expand if the user selected some text
1010
▶︎ Proxy { <target>: {}, <handler>: (3) […] }"
1111
`;
1212
13+
exports[`ObjectInspector - state does not throw when expanding a block node 1`] = `
14+
"▶︎ ☲ Block
15+
▶︎ Proxy: Proxy { <target>: {}, <handler>: (3) […] }"
16+
`;
17+
18+
exports[`ObjectInspector - state does not throw when expanding a block node 2`] = `
19+
"▼ ☲ Block
20+
| a: 30
21+
| b: 32
22+
▶︎ Proxy: Proxy { <target>: {}, <handler>: (3) […] }"
23+
`;
24+
1325
exports[`ObjectInspector - state has the expected expandedPaths state when clicking nodes 1`] = `
1426
"▶︎ Object { p0: \\"0\\", p1: \\"1\\", p2: \\"2\\", p3: \\"3\\", p4: \\"4\\", p5: \\"5\\", p6: \\"6\\", p7: \\"7\\", p8: \\"8\\", p9: \\"9\\", … }
1527
▶︎ Proxy { <target>: {}, <handler>: (3) […] }"

packages/devtools-reps/src/object-inspector/tests/component/expand.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const {
1515
formatObjectInspector,
1616
waitForDispatch,
1717
} = require("../test-utils");
18+
const {
19+
createNode,
20+
NODE_TYPES,
21+
} = require("../../utils/node");
1822

1923
function generateDefaults(overrides) {
2024
return Object.assign({
@@ -207,4 +211,44 @@ describe("ObjectInspector - state", () => {
207211
// Clear the selection for other tests.
208212
getSelection().setMockSelection();
209213
});
214+
215+
it("does not throw when expanding a block node", async () => {
216+
const blockNode = createNode(
217+
null,
218+
"Block",
219+
"root-1",
220+
[{
221+
name: "a",
222+
contents: {
223+
value: 30,
224+
}
225+
}, {
226+
name: "b",
227+
contents: {
228+
value: 32,
229+
}
230+
}],
231+
NODE_TYPES.BLOCK
232+
);
233+
const proxyNode = createNode(
234+
null,
235+
"Proxy",
236+
"root-2",
237+
{
238+
value: gripRepStubs.get("testProxy")
239+
}
240+
);
241+
242+
const wrapper = mount(ObjectInspector(generateDefaults({
243+
roots: [blockNode, proxyNode],
244+
})));
245+
246+
expect(formatObjectInspector(wrapper)).toMatchSnapshot();
247+
248+
let nodes = wrapper.find(".node");
249+
const root = nodes.at(0);
250+
root.simulate("click");
251+
252+
expect(formatObjectInspector(wrapper)).toMatchSnapshot();
253+
});
210254
});

0 commit comments

Comments
 (0)