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

Commit 7532780

Browse files
weilongenchevobbe
authored andcommitted
Modify the title for ObjectWithText rep.
Fix #684
1 parent d9b0ac0 commit 7532780

File tree

4 files changed

+54
-11
lines changed

4 files changed

+54
-11
lines changed

packages/devtools-reps/src/reps/object-with-text.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const {
1111
wrapRender,
1212
} = require("./rep-utils");
1313

14+
const String = require("./string").rep;
15+
1416
const dom = require("react-dom-factories");
1517
const { span } = dom;
1618

@@ -24,11 +26,14 @@ ObjectWithText.propTypes = {
2426
function ObjectWithText(props) {
2527
let grip = props.object;
2628
return (
27-
span({
28-
"data-link-actor-id": grip.actor,
29-
className: "objectBox objectBox-" + getType(grip)
30-
},
31-
span({className: "objectPropValue"}, getDescription(grip))
29+
span(
30+
{
31+
"data-link-actor-id": grip.actor,
32+
className: "objectTitle objectBox objectBox-" + getType(grip)
33+
},
34+
getType(grip),
35+
" ",
36+
getDescription(grip)
3237
)
3338
);
3439
}
@@ -38,7 +43,9 @@ function getType(grip) {
3843
}
3944

4045
function getDescription(grip) {
41-
return "\"" + grip.preview.text + "\"";
46+
return String({
47+
object: grip.preview.text,
48+
});
4249
}
4350

4451
// Registration

packages/devtools-reps/src/reps/stubs/object-with-text.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
const stubs = new Map();
6-
stubs.set("ObjectWithText", {
6+
stubs.set("ShadowRule", {
77
"type": "object",
88
"class": "CSSStyleRule",
99
"actor": "server1.conn3.obj273",
@@ -17,4 +17,19 @@ stubs.set("ObjectWithText", {
1717
}
1818
});
1919

20+
stubs.set("CSSMediaRule", {
21+
"type": "object",
22+
"actor": "server2.conn8.child17/obj30",
23+
"class": "CSSMediaRule",
24+
"extensible": true,
25+
"frozen": false,
26+
"sealed": false,
27+
"ownPropertyLength": 0,
28+
"preview": {
29+
"kind": "ObjectWithText",
30+
"text": "(min-height: 680px), screen and (orientation: portrait)"
31+
}
32+
33+
});
34+
2035
module.exports = stubs;

packages/devtools-reps/src/reps/tests/object-with-text.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const {
1515
const stubs = require("../stubs/object-with-text");
1616
const { ObjectWithText, Rep } = REPS;
1717

18-
describe("Object with text", () => {
19-
const gripStub = stubs.get("ObjectWithText");
18+
describe("Object with text - CSSStyleRule", () => {
19+
const gripStub = stubs.get("ShadowRule");
2020

2121
// Test that correct rep is chosen
2222
it("selects ObjectsWithText Rep", () => {
@@ -29,7 +29,28 @@ describe("Object with text", () => {
2929
object: gripStub
3030
}));
3131

32-
expect(renderedComponent.text()).toEqual("\".Shadow\"");
32+
expect(renderedComponent.text()).toEqual("CSSStyleRule \".Shadow\"");
3333
expectActorAttribute(renderedComponent, gripStub.actor);
3434
});
3535
});
36+
37+
describe("Object with text - CSSMediaRule", () => {
38+
const gripStub = stubs.get("CSSMediaRule");
39+
40+
// Test that correct rep is chosen
41+
it("selects ObjectsWithText Rep", () => {
42+
expect(getRep(gripStub)).toEqual(ObjectWithText.rep);
43+
});
44+
45+
// Test rendering
46+
it("renders with the correct text content", () => {
47+
const renderedComponent = shallow(Rep({
48+
object: gripStub
49+
}));
50+
51+
const S = "CSSMediaRule \"(min-height: 680px), screen and (orientation: portrait)\"";
52+
expect(renderedComponent.text()).toEqual(S);
53+
expectActorAttribute(renderedComponent, gripStub.actor);
54+
});
55+
});
56+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ describe("Object - noGrip prop", () => {
253253

254254
it("ObjectWithText grip", () => {
255255
const stubs = require("../stubs/object-with-text");
256-
expect(getRep(stubs.get("ObjectWithText"), undefined, true)).toBe(Obj.rep);
256+
expect(getRep(stubs.get("ShadowRule"), undefined, true)).toBe(Obj.rep);
257257
});
258258

259259
it("ObjectWithURL grip", () => {

0 commit comments

Comments
 (0)