Skip to content
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
31 changes: 31 additions & 0 deletions src/browser/ui/__tests__/ReactMount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ describe('ReactMount', function() {
var React = require('React');
var ReactMount = require('ReactMount');
var ReactTestUtils = require('ReactTestUtils');
var WebComponents = undefined;

try {
WebComponents = require('WebComponents');
} catch(e) {
/* leave WebComponents undefined */
}

describe('constructAndRenderComponentByID', function() {
it('throws if given an id for a component that doesn\'t exist', function() {
Expand Down Expand Up @@ -157,4 +164,28 @@ describe('ReactMount', function() {
'Rendering components directly into document.body is discouraged'
);
});

(WebComponents === undefined ? xit : it)
('should allow mounting/unmounting to document fragment container', function() {
var shadowRoot;
var proto = Object.create(HTMLElement.prototype, {
createdCallback: {
value: function() {
var query = encodeURIComponent(this.innerHTML);
var url = "https://www.google.com/search?q=" + query + "&btnI";
shadowRoot = this.createShadowRoot();
React.render(<div>Hi, from within a WC!</div>, shadowRoot);
expect(shadowRoot.firstChild.tagName).toBe('DIV')
React.render(<span>Hi, from within a WC!</span>, shadowRoot);
expect(shadowRoot.firstChild.tagName).toBe('SPAN')
}
}
});
proto.unmount = function() {
React.unmountComponentAtNode(shadowRoot);
}
document.registerElement('x-foo', {prototype: proto});
var element = document.createElement('x-foo');
element.unmount();
});
});
Loading