Skip to content

Commit

Permalink
fix jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Mar 28, 2017
1 parent ff55a90 commit 2567438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
17 changes: 0 additions & 17 deletions tests/react/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ describe('Entity', () => {
expect(tree.props.mixin).toBe('box');
});

it('renders <a-entity> with null component', () => {
const tree = renderer.create(
<Entity position={null} />
).toJSON();
expect(tree.props.position).toBe(null);
});

it('renders primitive', () => {
const tree = renderer.create(
<Entity primitive='a-sphere' material={{color: 'red'}}/>
Expand All @@ -59,14 +52,4 @@ describe('Scene', () => {
expect(tree.type).toBe('a-scene');
expect(tree.children[0].type).toBe('a-entity');
});

it('renders <a-scene antialias="true">', () => {
const tree = renderer.create(
<Scene antialias='true'>
<Entity/>
</Scene>
).toJSON();
expect(tree.type).toBe('a-scene');
expect(tree.props.antialias).toBe('true');
});
});

0 comments on commit 2567438

Please sign in to comment.