Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from pronebird/fix/issue-3
Browse files Browse the repository at this point in the history
Make sure we do not create DOM element when insertDefaultUI is false
  • Loading branch information
aiham authored Mar 16, 2017
2 parents 9ee4d18 + a0a50be commit a55595b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/OTPublisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ export default class OTPublisher extends Component {
if (!this.props.session) {
return;
}

let properties = this.props.properties || {};
let container;

if(properties.insertDefaultUI !== false) {
container = document.createElement('div');
container.setAttribute('class', 'OTPublisherContainer');
findDOMNode(this).appendChild(container);
}

let container = document.createElement('div');
container.setAttribute('class', 'OTPublisherContainer');
findDOMNode(this).appendChild(container);

let publisher = OT.initPublisher(container, this.props.properties);
let publisher = OT.initPublisher(container, properties);
publisher.on('streamCreated', this.streamCreatedHandler);

if (
Expand Down
13 changes: 13 additions & 0 deletions test/OTPublisher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ describe('OTPublisher', () => {
]);
});

describe('configuration', () => {
beforeEach(() => {
session.connection = {};
});

it('should not render the publisher container element when default UI is disabled', () => {
const wrapper = mount(<OTPublisher session={session} properties={{ insertDefaultUI: false }} />);
const divContainer = wrapper.render().find('div.OTPublisherContainer');
expect(divContainer.length).toBe(0);
});

});

describe('connected session', () => {
let wrapper;

Expand Down

0 comments on commit a55595b

Please sign in to comment.