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

Commit cb8548f

Browse files
committed
Replace Object.assign with the spread operator in reps tests.
1 parent c5cbfea commit cb8548f

File tree

13 files changed

+55
-38
lines changed

13 files changed

+55
-38
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("Array", () => {
2121

2222
it("renders empty array as expected", () => {
2323
const object = [];
24-
const renderRep = props => shallow(Rep(Object.assign({ object }, props)));
24+
const renderRep = props => shallow(Rep({ object, ...props }));
2525

2626
const defaultOutput = "[]";
2727
expect(renderRep({ mode: undefined }).text()).toBe(defaultOutput);
@@ -32,7 +32,7 @@ describe("Array", () => {
3232

3333
it("renders basic array as expected", () => {
3434
const object = [1, "foo", {}];
35-
const renderRep = props => shallow(Rep(Object.assign({ object }, props)));
35+
const renderRep = props => shallow(Rep({ object, ...props }));
3636

3737
const defaultOutput = `[ 1, "foo", {} ]`;
3838
expect(renderRep({ mode: undefined }).text()).toBe(defaultOutput);
@@ -43,7 +43,7 @@ describe("Array", () => {
4343

4444
it("renders array with more than SHORT mode maximum props as expected", () => {
4545
const object = Array(maxLengthMap.get(MODE.SHORT) + 1).fill("foo");
46-
const renderRep = props => shallow(Rep(Object.assign({ object }, props)));
46+
const renderRep = props => shallow(Rep({ object, ...props }));
4747

4848
const defaultShortOutput =
4949
`[ ${Array(maxLengthMap.get(MODE.SHORT)).fill("\"foo\"").join(", ")}, … ]`;
@@ -57,7 +57,7 @@ describe("Array", () => {
5757

5858
it("renders array with more than LONG mode maximum props as expected", () => {
5959
const object = Array(maxLengthMap.get(MODE.LONG) + 1).fill("foo");
60-
const renderRep = props => shallow(Rep(Object.assign({ object }, props)));
60+
const renderRep = props => shallow(Rep({ object, ...props }));
6161

6262
const defaultShortOutput =
6363
`[ ${Array(maxLengthMap.get(MODE.SHORT)).fill("\"foo\"").join(", ")}, … ]`;
@@ -71,7 +71,7 @@ describe("Array", () => {
7171
it("renders recursive array as expected", () => {
7272
const object = [1];
7373
object.push(object);
74-
const renderRep = props => shallow(Rep(Object.assign({ object }, props)));
74+
const renderRep = props => shallow(Rep({ object, ...props }));
7575

7676
const defaultOutput = "[ 1, […] ]";
7777
expect(renderRep({ mode: undefined }).text()).toBe(defaultOutput);
@@ -87,7 +87,7 @@ describe("Array", () => {
8787
p3: "s3",
8888
p4: "s4"
8989
}];
90-
const renderRep = props => shallow(Rep(Object.assign({ object }, props)));
90+
const renderRep = props => shallow(Rep({ object, ...props }));
9191

9292
const defaultOutput = "[ {…} ]";
9393
expect(renderRep({ mode: undefined }).text()).toBe(defaultOutput);

packages/devtools-reps/src/reps/tests/comment-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("CommentNode", () => {
3434

3535
it("renders as expected", () => {
3636
const object = stubs.get("Comment");
37-
const renderRep = props => shallow(CommentNode.rep(Object.assign({object}, props)));
37+
const renderRep = props => shallow(CommentNode.rep({object, ...props}));
3838

3939
let component = renderRep({mode: undefined});
4040
expect(component.text())

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("Event - keyboard event", () => {
4040
});
4141

4242
it("renders with expected text", () => {
43-
const renderRep = props => shallow(Event.rep(Object.assign({object}, props)));
43+
const renderRep = props => shallow(Event.rep({object, ...props}));
4444
expect(renderRep().text()).toEqual(
4545
"keyup { target: body, key: \"Control\", charCode: 0, … }");
4646
expect(renderRep({mode: MODE.LONG}).text()).toEqual(
@@ -56,7 +56,7 @@ describe("Event - keyboard event with modifiers", () => {
5656
});
5757

5858
it("renders with expected text", () => {
59-
const renderRep = props => shallow(Event.rep(Object.assign({object}, props)));
59+
const renderRep = props => shallow(Event.rep({object, ...props}));
6060
expect(renderRep({mode: MODE.LONG}).text()).toEqual(
6161
"keyup Meta-Shift { target: body, key: \"M\", charCode: 0, keyCode: 77 }");
6262
});
@@ -70,7 +70,7 @@ describe("Event - message event", () => {
7070
});
7171

7272
it("renders with expected text", () => {
73-
const renderRep = props => shallow(Event.rep(Object.assign({object}, props)));
73+
const renderRep = props => shallow(Event.rep({object, ...props}));
7474
expect(renderRep().text()).toEqual(
7575
"message { target: Window, isTrusted: false, data: \"test data\", … }");
7676
expect(renderRep({mode: MODE.LONG}).text()).toEqual(
@@ -82,7 +82,7 @@ describe("Event - message event", () => {
8282

8383
describe("Event - mouse event", () => {
8484
const object = stubs.get("testMouseEvent");
85-
const renderRep = props => shallow(Event.rep(Object.assign({object}, props)));
85+
const renderRep = props => shallow(Event.rep({object, ...props}));
8686

8787
const grips = getSelectableInInspectorGrips(object);
8888
expect(grips.length).toBe(1, "the stub has one node grip");

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
expectActorAttribute
1414
} = require("./test-helpers");
1515
const renderRep = (object, props) => {
16-
return shallow(Func.rep(Object.assign({object}, props)));
16+
return shallow(Func.rep({object, ...props}));
1717
};
1818

1919
describe("Function - Named", () => {
@@ -264,8 +264,11 @@ describe("Function - Jump to definition", () => {
264264
});
265265

266266
it("does not render an icon when the object has no location", () => {
267-
const object = Object.assign({}, stubs.get("getRandom"));
268-
delete object.location;
267+
const object = {
268+
...stubs.get("getRandom"),
269+
location: null,
270+
};
271+
269272
const renderedComponent = renderRep(object, {
270273
onViewSourceInDebugger: () => {}
271274
});
@@ -275,7 +278,9 @@ describe("Function - Jump to definition", () => {
275278
});
276279

277280
it("does not render an icon when the object has no url location", () => {
278-
const object = Object.assign({}, stubs.get("getRandom"));
281+
const object = {
282+
...stubs.get("getRandom"),
283+
};
279284
object.location.url = null;
280285
const renderedComponent = renderRep(object, {
281286
onViewSourceInDebugger: () => {}
@@ -286,7 +291,7 @@ describe("Function - Jump to definition", () => {
286291
});
287292

288293
it("does not render an icon when function was declared in console input", () => {
289-
const object = Object.assign({}, stubs.get("EvaledInDebuggerFunction"));
294+
const object = stubs.get("EvaledInDebuggerFunction");
290295
const renderedComponent = renderRep(object, {
291296
onViewSourceInDebugger: () => {}
292297
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ const {
1818
const { maxLengthMap } = GripArray;
1919

2020
function shallowRenderRep(object, props = {}) {
21-
return shallow(GripArray.rep(Object.assign({
21+
return shallow(GripArray.rep({
2222
object,
23-
}, props)));
23+
...props,
24+
}));
2425
}
2526

2627
describe("GripArray - basic", () => {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ const nodeStubs = require("../stubs/element-node");
2020
const gripArrayStubs = require("../stubs/grip-array");
2121

2222
const renderRep = (object, mode, props) => {
23-
return shallow(GripMapEntry.rep(Object.assign({
24-
object,
25-
mode,
26-
}, props)));
23+
return shallow(GripMapEntry.rep({
24+
object,
25+
mode,
26+
...props,
27+
}));
2728
};
2829

2930
describe("GripMapEntry - simple", () => {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ const {
1919
const {maxLengthMap} = GripMap;
2020

2121
function shallowRenderRep(object, props = {}) {
22-
return shallow(GripMap.rep(Object.assign({
22+
return shallow(GripMap.rep({
2323
object,
24-
}, props)));
24+
...props,
25+
}));
2526
}
2627

2728
describe("GripMap - empty map", () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { Obj } = REPS;
1111
const { MODE } = require("../constants");
1212

1313
const renderComponent = (object, props) => {
14-
return shallow(Obj.rep(Object.assign({ object }, props)));
14+
return shallow(Obj.rep({ object, ...props}));
1515
};
1616

1717
describe("Object - Basic", () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const {
1818
} = require("./test-helpers");
1919

2020
const renderRep = (object, props) => {
21-
return shallow(PromiseRep.rep(Object.assign({object}, props)));
21+
return shallow(PromiseRep.rep({object, ...props}));
2222
};
2323

2424
describe("Promise - Pending", () => {

packages/devtools-reps/src/reps/tests/string-with-url.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ const { Rep } = REPS;
99
const { getGripLengthBubbleText } = require("./test-helpers");
1010

1111
const renderRep = (string, props) => mount(
12-
Rep(Object.assign({
12+
Rep({
1313
object: string,
1414
omitLinkHref: false,
15-
}, props))
15+
...props,
16+
})
1617
);
1718

1819
describe("test String with URL", () => {

0 commit comments

Comments
 (0)