UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

89 lines (87 loc) 4.24 kB
define(["require", "exports", 'react', 'react-addons-test-utils', './Callout', '../../common/DirectionalHint'], function (require, exports, React, ReactTestUtils, Callout_1, DirectionalHint_1) { "use strict"; var expect = chai.expect; describe('Callout', function () { it('Callout target id strings does not throw exception', function () { var threwException = false; var exception; try { ReactTestUtils.renderIntoDocument(React.createElement("div", null, React.createElement("button", {id: 'target', style: { top: '10px', left: '10px', height: '0', width: '0px' }}, " target "), React.createElement(Callout_1.Callout, {target: '#target', directionalHint: DirectionalHint_1.DirectionalHint.topLeftEdge}, React.createElement("div", null, "Content") ))); } catch (e) { exception = e; threwException = true; } expect(threwException).to.be.false; }); it('Callout target MouseEvents does not throw exception', function () { var mouseEvent = document.createEvent('MouseEvent'); var eventTarget = document.createElement('div'); mouseEvent.initMouseEvent('click', false, false, window, 0, 0, 0, 0, 0, false, false, false, false, 1, eventTarget); var threwException = false; try { ReactTestUtils.renderIntoDocument(React.createElement("div", null, React.createElement(Callout_1.Callout, {target: eventTarget, directionalHint: DirectionalHint_1.DirectionalHint.topLeftEdge}, React.createElement("div", null, "Content") ) )); } catch (e) { threwException = true; } expect(threwException).to.be.false; }); it('Callout target HTMLElements does not throw exception', function () { var targetElement = document.createElement('div'); document.body.appendChild(targetElement); var threwException = false; try { ReactTestUtils.renderIntoDocument(React.createElement("div", null, React.createElement(Callout_1.Callout, {target: targetElement, directionalHint: DirectionalHint_1.DirectionalHint.topLeftEdge}, React.createElement("div", null, "Content") ) )); } catch (e) { threwException = true; } expect(threwException).to.be.false; }); // Once this has been deprecated completely in v1.0 this is no longer needed. it('Callout targetElement HTMLElements does not throw exception', function () { var targetElement = document.createElement('div'); document.body.appendChild(targetElement); var threwException = false; try { ReactTestUtils.renderIntoDocument(React.createElement("div", null, React.createElement(Callout_1.Callout, {targetElement: targetElement, directionalHint: DirectionalHint_1.DirectionalHint.topLeftEdge}, React.createElement("div", null, "Content") ) )); } catch (e) { threwException = true; } expect(threwException).to.be.false; }); it('Callout without target does not throw exception', function () { var threwException = false; try { ReactTestUtils.renderIntoDocument(React.createElement("div", null, React.createElement(Callout_1.Callout, {directionalHint: DirectionalHint_1.DirectionalHint.topLeftEdge}, React.createElement("div", null, "Content") ) )); } catch (e) { threwException = true; } expect(threwException).to.be.false; }); }); }); //# sourceMappingURL=Callout.test.js.map