This repository has been archived by the owner on Sep 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a prop to have ObjectInspector inline.
- Loading branch information
Showing
4 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
|
||
.tree { | ||
overflow: auto; | ||
} | ||
|
||
.tree.inline { | ||
display: inline-block; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/devtools-reps/src/object-inspector/tests/component/__snapshots__/classnames.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ObjectInspector - classnames has the expected class 1`] = ` | ||
<ObjectInspector | ||
autoExpandDepth={0} | ||
getObjectProperties={[Function]} | ||
loadObjectProperties={[Function]} | ||
roots={ | ||
Array [ | ||
Object { | ||
"contents": Object { | ||
"value": 42, | ||
}, | ||
"name": "root", | ||
"path": "root", | ||
}, | ||
] | ||
} | ||
/> | ||
`; | ||
|
||
exports[`ObjectInspector - classnames has the inline class when inline prop is true 1`] = ` | ||
<ObjectInspector | ||
autoExpandDepth={0} | ||
getObjectProperties={[Function]} | ||
inline={true} | ||
loadObjectProperties={[Function]} | ||
roots={ | ||
Array [ | ||
Object { | ||
"contents": Object { | ||
"value": 42, | ||
}, | ||
"name": "root", | ||
"path": "root", | ||
}, | ||
] | ||
} | ||
/> | ||
`; | ||
|
||
exports[`ObjectInspector - classnames has the nowrap class when disableWrap prop is true 1`] = ` | ||
<ObjectInspector | ||
autoExpandDepth={0} | ||
disableWrap={true} | ||
getObjectProperties={[Function]} | ||
loadObjectProperties={[Function]} | ||
roots={ | ||
Array [ | ||
Object { | ||
"contents": Object { | ||
"value": 42, | ||
}, | ||
"name": "root", | ||
"path": "root", | ||
}, | ||
] | ||
} | ||
/> | ||
`; |
54 changes: 54 additions & 0 deletions
54
packages/devtools-reps/src/object-inspector/tests/component/classnames.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const { mount } = require("enzyme"); | ||
const React = require("react"); | ||
const { createFactory } = React; | ||
const ObjectInspector = createFactory(require("../../index")); | ||
|
||
function generateDefaults(overrides) { | ||
return Object.assign({ | ||
autoExpandDepth: 0, | ||
roots: [{ | ||
path: "root", | ||
name: "root", | ||
contents: {value: 42} | ||
}], | ||
getObjectProperties: () => {}, | ||
loadObjectProperties: () => {}, | ||
}, overrides); | ||
} | ||
|
||
describe("ObjectInspector - classnames", () => { | ||
it("has the expected class", () => { | ||
const props = generateDefaults(); | ||
const oi = ObjectInspector(props); | ||
const wrapper = mount(oi); | ||
|
||
expect(wrapper.hasClass("tree")).toBeTruthy(); | ||
expect(wrapper.hasClass("inline")).toBeFalsy(); | ||
expect(wrapper.hasClass("nowrap")).toBeFalsy(); | ||
expect(oi).toMatchSnapshot(); | ||
}); | ||
|
||
it("has the nowrap class when disableWrap prop is true", () => { | ||
const props = generateDefaults({ | ||
disableWrap: true, | ||
}); | ||
const oi = ObjectInspector(props); | ||
const wrapper = mount(oi); | ||
expect(wrapper.hasClass("nowrap")).toBeTruthy(); | ||
expect(oi).toMatchSnapshot(); | ||
}); | ||
|
||
it("has the inline class when inline prop is true", () => { | ||
const props = generateDefaults({ | ||
inline: true, | ||
}); | ||
const oi = ObjectInspector(props); | ||
const wrapper = mount(oi); | ||
expect(wrapper.hasClass("inline")).toBeTruthy(); | ||
expect(oi).toMatchSnapshot(); | ||
}); | ||
}); |