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

Commit 2e44d97

Browse files
nchevobbejuliandescottes
authored andcommitted
Add a Rep test for Generators
1 parent b39a79d commit 2e44d97

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/devtools-reps/src/reps/stubs/grip.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,4 +977,22 @@ stubs.set(`{test: "http://example.com/ some other text"}`, {
977977
}
978978
});
979979

980+
stubs.set("Generator", {
981+
"type": "object",
982+
"actor": "server1.conn2.child1/obj33",
983+
"class": "Generator",
984+
"extensible": true,
985+
"frozen": false,
986+
"sealed": false,
987+
"ownPropertyLength": 0,
988+
"preview": {
989+
"kind": "Object",
990+
"ownProperties": {},
991+
"ownSymbols": [],
992+
"ownPropertiesLength": 0,
993+
"ownSymbolsLength": 0,
994+
"safeGetterValues": {}
995+
}
996+
});
997+
980998
module.exports = stubs;

packages/devtools-reps/src/reps/tests/grip.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,22 @@ describe("Grip - Without preview", () => {
553553
});
554554
});
555555

556+
describe("Grip - Generator object", () => {
557+
// Test object:
558+
// `function* genFunc() { var a = 5; while (a < 10) { yield a++; } }; genFunc();`
559+
const object = stubs.get("Generator");
560+
561+
it("correctly selects Grip Rep", () => {
562+
expect(getRep(object)).toBe(Grip.rep);
563+
});
564+
565+
it("renders as expected", () => {
566+
const renderRep = (props) => shallowRenderRep(object, props);
567+
const defaultOutput = "Generator { }";
568+
569+
expect(renderRep({ mode: undefined }).text()).toBe(defaultOutput);
570+
expect(renderRep({ mode: MODE.TINY }).text()).toBe("Generator");
571+
expect(renderRep({ mode: MODE.SHORT }).text()).toBe(defaultOutput);
572+
expect(renderRep({ mode: MODE.LONG }).text()).toBe(defaultOutput);
573+
});
574+
});

0 commit comments

Comments
 (0)