I\'m trying to test a slider component.
This slider compone
Here is an example. React 0.14 warns about rendering document into body. Like what Matt said, we will need to append 'div' in the iframe to prevent such errors.
describe('html tooltip utility class', function() {
let iframe;
let div;
beforeEach(() => {
iframe = document.createElement('iframe');
document.body.appendChild(iframe);
div = document.createElement('div');
});
it('returns true if text overflows', () => {
// jshint ignore:start
let style = {
width: 5
};
let data = 'hello this is a long text.';
iframe.contentDocument.body.appendChild(div);
ReactDOM.render({data}, div);
// jshint ignore:end
let textNode = div.querySelectorAll('div')[0];
expect(HTMLTooltip.showTooltip(textNode)).to.be.true;
});
afterEach(() => {
document.body.removeChild(iframe);
});
});