office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
26 lines (24 loc) • 1.4 kB
JavaScript
define(["require", "exports", 'react', 'react-addons-test-utils', './ColorPicker'], function (require, exports, React, ReactTestUtils, ColorPicker_1) {
"use strict";
var expect = chai.expect;
describe('ColorPicker', function () {
it('Props are correctly parsed', function () {
var component = ReactTestUtils.renderIntoDocument(React.createElement(ColorPicker_1.ColorPicker, {color: '#FFFFFF'}));
expect(component.state.color.hex).to.equal('ffffff');
});
it('Reacts to props changes', function () {
var component = ReactTestUtils.renderIntoDocument(React.createElement(ColorPicker_1.ColorPicker, {color: '#FFFFFF'}));
component.componentWillReceiveProps({ color: '#AEAEAE' });
expect(component.state.color.hex).to.equal('aeaeae');
});
it('onColorChange is called', function () {
var color = '#FFFFFF';
var component = ReactTestUtils.renderIntoDocument(React.createElement(ColorPicker_1.ColorPicker, {color: color, onColorChanged: function (str) { return color = str; }}));
var newColor = '#AEAEAE';
component.componentWillReceiveProps({ color: newColor });
expect(component.state.color.hex).to.equal('aeaeae');
expect(color).to.equal(newColor);
});
});
});
//# sourceMappingURL=ColorPicker.test.js.map