From 256743839602516f7d8b73ffdd3a41526292aa81 Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Mon, 27 Mar 2017 17:01:13 -0700 Subject: [PATCH] fix jest tests --- src/index.js | 12 +++++++++++- tests/react/index.test.js | 17 ----------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/index.js b/src/index.js index 39ffd04..f78c561 100644 --- a/src/index.js +++ b/src/index.js @@ -83,9 +83,19 @@ export class Entity extends React.Component { render() { const props = this.props; const elementName = this.isScene ? 'a-scene' : (props.primitive || 'a-entity'); + + // Let through props that are OK to render initially. + let reactProps = {}; + Object.keys(props).forEach(propName => { + if (['className', 'id', 'mixin'].indexOf(propName) !== -1 || + propName.indexOf('data-') === 0) { + reactProps[propName] = props[propName]; + } + }); + return React.createElement( elementName, - Object.assign({ref: this.updateDOM}), + {ref: this.updateDOM, ...reactProps}, props.children); } } diff --git a/tests/react/index.test.js b/tests/react/index.test.js index a35799b..b835b77 100644 --- a/tests/react/index.test.js +++ b/tests/react/index.test.js @@ -34,13 +34,6 @@ describe('Entity', () => { expect(tree.props.mixin).toBe('box'); }); - it('renders with null component', () => { - const tree = renderer.create( - - ).toJSON(); - expect(tree.props.position).toBe(null); - }); - it('renders primitive', () => { const tree = renderer.create( @@ -59,14 +52,4 @@ describe('Scene', () => { expect(tree.type).toBe('a-scene'); expect(tree.children[0].type).toBe('a-entity'); }); - - it('renders ', () => { - const tree = renderer.create( - - - - ).toJSON(); - expect(tree.type).toBe('a-scene'); - expect(tree.props.antialias).toBe('true'); - }); });