Skip to content

Commit

Permalink
add unit test for wrapped entity
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Mar 27, 2017
1 parent b92638a commit 44bee27
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/browser/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ suite('aframe-react', () => {
});
});

test('renders entity wrapped in React component', done => {
class Camera extends React.Component {
render() {
return (
<Entity id='cameraContainer'>
<Entity id='camera' camera>
<Entity id='cursor'
cursor={{fuse: true, fuseTimeout: 3000}}
raycaster={{objects: '.foo'}}
geometry={{primitive: 'plane'}}/>
</Entity>
</Entity>
);
}
}
ReactDOM.render(<Scene><Camera/></Scene>, div);
div.querySelector('a-scene').addEventListener('loaded', () => {
assert.ok(div.querySelector('#camera').getAttribute('camera'), 'Has camera');
assert.ok(div.querySelector('#cursor').getAttribute('cursor'), 'Has cursor');
assert.ok(div.querySelector('#cursor').getAttribute('raycaster'), 'Has raycaster');
done();
});
});

test('does not flush props to DOM', done => {
ReactDOM.render(<Scene><Entity position={{x: 1, y: 2, z: 3}}/></Scene>, div);
div.querySelector('a-scene').addEventListener('loaded', () => {
Expand Down

0 comments on commit 44bee27

Please sign in to comment.