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

Commit 01dc51a

Browse files
authored
Merge pull request #466 from devtools-html/grip-jest
Move Grip rep mochitest to jest
2 parents f68f80f + fbe6dca commit 01dc51a

File tree

4 files changed

+1053
-1290
lines changed

4 files changed

+1053
-1290
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ GripRep.propTypes = {
3535

3636
function GripRep(props) {
3737
let {
38-
mode,
38+
mode = MODE.SHORT,
3939
object,
4040
} = props;
4141

@@ -47,7 +47,7 @@ function GripRep(props) {
4747
);
4848
}
4949

50-
let propsArray = safePropIterator(props, object, (mode === MODE.LONG) ? 10 : 3);
50+
let propsArray = safePropIterator(props, object, maxLengthMap.get(mode));
5151

5252
return (
5353
span({className: "objectBox objectBox-object"},
@@ -69,7 +69,7 @@ function getTitle(props, object) {
6969
}
7070

7171
function safePropIterator(props, object, max) {
72-
max = (typeof max === "undefined") ? 3 : max;
72+
max = (typeof max === "undefined") ? maxLengthMap.get(MODE.SHORT) : max;
7373
try {
7474
return propIterator(props, object, max);
7575
} catch (err) {
@@ -249,10 +249,15 @@ function supportsObject(object, type) {
249249
return (object.preview && object.preview.ownProperties);
250250
}
251251

252+
const maxLengthMap = new Map();
253+
maxLengthMap.set(MODE.SHORT, 3);
254+
maxLengthMap.set(MODE.LONG, 10);
255+
252256
// Grip is used in propIterator and has to be defined here.
253257
let Grip = {
254258
rep: wrapRender(GripRep),
255259
supportsObject,
260+
maxLengthMap,
256261
};
257262

258263
// Exports from this module

0 commit comments

Comments
 (0)