Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make correct output for number children in debug #149

Merged
merged 1 commit into from
Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function propsString(node) {
}

export function debugNode(node, indentLength = 2) {
if (typeof node === 'string' || typeof node === 'number') return escape(node);
if (!node) return '';
if (typeof node === 'string') return escape(node);

const children = compact(childrenOfNode(node).map(n => debugNode(n, indentLength)));
const type = typeName(node);
Expand Down
23 changes: 22 additions & 1 deletion src/__tests__/Debug-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ describe('debug', () => {
);
});

it('should render number children properly', () => {
expect(debugNode(
<div>
{-1}
{0}
{1}
</div>
)).to.equal(
`<div>
-1
0
1
</div>`
);
});

it('renders html entities properly', () => {
expect(debugNode(
<div>&gt;</div>
Expand All @@ -124,7 +140,12 @@ describe('debug', () => {

it('should not render falsy children ', () => {
expect(debugNode(
<div id="foo">{false}</div>
<div id="foo">
{false}
{null}
{undefined}
{''}
</div>
)).to.equal(
`<div id="foo" />`
);
Expand Down