react-color
Advanced tools
Comparing version 2.13.0 to 2.13.1
@@ -15,4 +15,8 @@ 'use strict'; | ||
var _enzyme = require('enzyme'); | ||
var _color = require('../../helpers/color'); | ||
var _color2 = _interopRequireDefault(_color); | ||
var _Alpha = require('./Alpha'); | ||
@@ -22,2 +26,4 @@ | ||
var _common = require('../common'); | ||
var _AlphaPointer = require('./AlphaPointer'); | ||
@@ -41,2 +47,16 @@ | ||
test('Alpha onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Alpha2.default, _extends({}, _color.red, { width: 20, height: 200, onChange: changeSpy }))); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var alphaCommon = tree.find(_common.Alpha); | ||
alphaCommon.at(0).childAt(2).simulate('mouseDown', { | ||
pageX: 100, | ||
pageY: 10 | ||
}); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Alpha renders vertically', function () { | ||
@@ -43,0 +63,0 @@ var tree = _reactTestRenderer2.default.create(_react2.default.createElement(_Alpha2.default, _extends({}, _color.red, { width: 20, height: 200, direction: 'vertical' }))).toJSON(); |
@@ -23,13 +23,29 @@ 'use strict'; | ||
var _color = require('../../helpers/color'); | ||
var _color2 = _interopRequireDefault(_color); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* global test, expect */ | ||
test('Block renders correctly', function () { | ||
var tree = _reactTestRenderer2.default.create(_react2.default.createElement(_Block2.default, null)).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); /* global test, expect */ | ||
test('Block onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Block2.default, { onChange: changeSpy })); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Block with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Block2.default, { onSwatchHover: hoverSpy })); | ||
@@ -36,0 +52,0 @@ expect(hoverSpy).toHaveBeenCalledTimes(0); |
@@ -121,2 +121,4 @@ 'use strict'; | ||
value: function render() { | ||
var _this2 = this; | ||
var styles = (0, _reactcss2.default)({ | ||
@@ -313,3 +315,5 @@ 'default': { | ||
'div', | ||
{ style: styles.icon, onClick: this.toggleViews, ref: 'icon' }, | ||
{ style: styles.icon, onClick: this.toggleViews, ref: function ref(icon) { | ||
return _this2.icon = icon; | ||
} }, | ||
_react2.default.createElement( | ||
@@ -325,3 +329,5 @@ 'svg', | ||
_react2.default.createElement('path', { | ||
ref: 'iconUp', | ||
ref: function ref(iconUp) { | ||
return _this2.iconUp = iconUp; | ||
}, | ||
fill: '#333', | ||
@@ -331,3 +337,5 @@ d: 'M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z' | ||
_react2.default.createElement('path', { | ||
ref: 'iconDown', | ||
ref: function ref(iconDown) { | ||
return _this2.iconDown = iconDown; | ||
}, | ||
fill: '#333', | ||
@@ -334,0 +342,0 @@ d: 'M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15Z' |
'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* global test, expect */ | ||
var _react = require('react'); | ||
@@ -13,2 +15,6 @@ | ||
var _color2 = _interopRequireDefault(_color); | ||
var _enzyme = require('enzyme'); | ||
var _Chrome = require('./Chrome'); | ||
@@ -30,6 +36,6 @@ | ||
var _common = require('../common'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// import canvas from 'canvas' | ||
test('Chrome renders correctly', function () { | ||
@@ -40,2 +46,22 @@ var tree = _reactTestRenderer2.default.create(_react2.default.createElement(_Chrome2.default, _color.red)).toJSON(); | ||
test('Chrome onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Chrome2.default, _extends({}, _color.red, { onChange: changeSpy }))); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
// check the Alpha component | ||
var alphaCommon = tree.find(_common.Alpha); | ||
alphaCommon.at(0).childAt(2).simulate('mouseDown', { | ||
pageX: 100, | ||
pageY: 10 | ||
}); | ||
expect(changeSpy).toHaveBeenCalledTimes(1); | ||
// TODO: check the Hue component | ||
// TODO: check the ChromeFields | ||
// TODO: check Saturation | ||
}); | ||
// test('Chrome renders on server correctly', () => { | ||
@@ -48,4 +74,2 @@ // const tree = renderer.create( | ||
/* global test, expect */ | ||
test('ChromeFields renders correctly', function () { | ||
@@ -52,0 +76,0 @@ var tree = _reactTestRenderer2.default.create(_react2.default.createElement(_ChromeFields2.default, _color.red)).toJSON(); |
@@ -23,13 +23,29 @@ 'use strict'; | ||
var _color = require('../../helpers/color'); | ||
var _color2 = _interopRequireDefault(_color); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* global test, expect */ | ||
test('Circle renders correctly', function () { | ||
var tree = _reactTestRenderer2.default.create(_react2.default.createElement(_Circle2.default, null)).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); /* global test, expect */ | ||
test('Circle onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Circle2.default, { onChange: changeSpy })); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Circle with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Circle2.default, { onSwatchHover: hoverSpy })); | ||
@@ -36,0 +52,0 @@ expect(hoverSpy).toHaveBeenCalledTimes(0); |
@@ -53,3 +53,3 @@ 'use strict'; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = Alpha.__proto__ || Object.getPrototypeOf(Alpha)).call.apply(_ref2, [this].concat(args))), _this), _this.handleChange = function (e, skip) { | ||
var change = alpha.calculateChange(e, skip, _this.props, _this.refs.container); | ||
var change = alpha.calculateChange(e, skip, _this.props, _this.container); | ||
change && _this.props.onChange && _this.props.onChange(change, e); | ||
@@ -76,2 +76,4 @@ }, _this.handleMouseDown = function (e) { | ||
value: function render() { | ||
var _this2 = this; | ||
var rgb = this.props.rgb; | ||
@@ -141,3 +143,5 @@ var styles = (0, _reactcss2.default)({ | ||
style: styles.container, | ||
ref: 'container', | ||
ref: function ref(container) { | ||
return _this2.container = container; | ||
}, | ||
onMouseDown: this.handleMouseDown, | ||
@@ -144,0 +148,0 @@ onTouchMove: this.handleChange, |
@@ -51,2 +51,11 @@ 'use strict'; | ||
_this.handleSwatchHover = function (data, event) { | ||
var isValidColor = _color2.default.simpleCheckForValidColor(data); | ||
if (isValidColor) { | ||
var colors = _color2.default.toState(data, data.h || _this.state.oldHue); | ||
_this.setState(colors); | ||
_this.props.onSwatchHover && _this.props.onSwatchHover(colors, event); | ||
} | ||
}; | ||
_this.state = _extends({}, _color2.default.toState(props.color, 0)); | ||
@@ -68,3 +77,8 @@ | ||
value: function render() { | ||
return _react2.default.createElement(Picker, _extends({}, this.props, this.state, { onChange: this.handleChange })); | ||
var optionalEvents = {}; | ||
if (this.props.onSwatchHover) { | ||
optionalEvents.onSwatchHover = this.handleSwatchHover; | ||
} | ||
return _react2.default.createElement(Picker, _extends({}, this.props, this.state, { onChange: this.handleChange }, optionalEvents)); | ||
} | ||
@@ -71,0 +85,0 @@ }]); |
@@ -118,3 +118,3 @@ 'use strict'; | ||
value: function componentWillReceiveProps(nextProps) { | ||
var input = this.refs.input; | ||
var input = this.input; | ||
if (nextProps.value !== this.state.value) { | ||
@@ -136,2 +136,4 @@ if (input === document.activeElement) { | ||
value: function render() { | ||
var _this2 = this; | ||
var styles = (0, _reactcss2.default)({ | ||
@@ -162,3 +164,5 @@ 'default': { | ||
style: styles.input, | ||
ref: 'input', | ||
ref: function ref(input) { | ||
return _this2.input = input; | ||
}, | ||
value: this.state.value, | ||
@@ -168,3 +172,4 @@ onKeyDown: this.handleKeyDown, | ||
onBlur: this.handleBlur, | ||
placeholder: this.props.placeholder | ||
placeholder: this.props.placeholder, | ||
spellCheck: 'false' | ||
}), | ||
@@ -171,0 +176,0 @@ this.props.label ? _react2.default.createElement( |
@@ -47,3 +47,3 @@ 'use strict'; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = Hue.__proto__ || Object.getPrototypeOf(Hue)).call.apply(_ref2, [this].concat(args))), _this), _this.handleChange = function (e, skip) { | ||
var change = hue.calculateChange(e, skip, _this.props, _this.refs.container); | ||
var change = hue.calculateChange(e, skip, _this.props, _this.container); | ||
change && _this.props.onChange && _this.props.onChange(change, e); | ||
@@ -73,2 +73,4 @@ }, _this.handleMouseDown = function (e) { | ||
value: function render() { | ||
var _this2 = this; | ||
var styles = (0, _reactcss2.default)({ | ||
@@ -119,3 +121,5 @@ 'default': { | ||
style: styles.container, | ||
ref: 'container', | ||
ref: function ref(container) { | ||
return _this2.container = container; | ||
}, | ||
onMouseDown: this.handleMouseDown, | ||
@@ -122,0 +126,0 @@ onTouchMove: this.handleChange, |
@@ -45,3 +45,3 @@ 'use strict'; | ||
_this.handleChange = function (e, skip) { | ||
_this.props.onChange && _this.throttle(_this.props.onChange, saturation.calculateChange(e, skip, _this.props, _this.refs.container), e); | ||
_this.props.onChange && _this.throttle(_this.props.onChange, saturation.calculateChange(e, skip, _this.props, _this.container), e); | ||
}; | ||
@@ -79,2 +79,4 @@ | ||
value: function render() { | ||
var _this2 = this; | ||
var _ref2 = this.props.style || {}, | ||
@@ -131,3 +133,5 @@ color = _ref2.color, | ||
style: styles.color, | ||
ref: 'container', | ||
ref: function ref(container) { | ||
return _this2.container = container; | ||
}, | ||
onMouseDown: this.handleMouseDown, | ||
@@ -134,0 +138,0 @@ onTouchMove: this.handleChange, |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var _color2 = _interopRequireDefault(_color); | ||
var _Compact = require('./Compact'); | ||
@@ -44,4 +46,18 @@ | ||
test('Compact onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Compact2.default, _extends({}, _color.red, { onChange: changeSpy }))); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Compact with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Compact2.default, _extends({}, _color.red, { onSwatchHover: hoverSpy }))); | ||
@@ -48,0 +64,0 @@ expect(hoverSpy).toHaveBeenCalledTimes(0); |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var _color2 = _interopRequireDefault(_color); | ||
var _Github = require('./Github'); | ||
@@ -35,4 +37,18 @@ | ||
test('Github onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Github2.default, { onChange: changeSpy })); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Github with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Github2.default, { onSwatchHover: hoverSpy })); | ||
@@ -39,0 +55,0 @@ expect(hoverSpy).toHaveBeenCalledTimes(0); |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _color2 = _interopRequireDefault(_color); | ||
var _Sketch = require('./Sketch'); | ||
@@ -48,4 +50,18 @@ | ||
test('Sketch onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Sketch2.default, { onChange: changeSpy })); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Sketch with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Sketch2.default, { onSwatchHover: hoverSpy })); | ||
@@ -52,0 +68,0 @@ expect(hoverSpy).toHaveBeenCalledTimes(0); |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _color2 = _interopRequireDefault(_color); | ||
var _Swatches = require('./Swatches'); | ||
@@ -39,4 +41,18 @@ | ||
test('Swatches onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Swatches2.default, { onChange: changeSpy })); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Swatches with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Swatches2.default, { onSwatchHover: hoverSpy })); | ||
@@ -43,0 +59,0 @@ expect(hoverSpy).toHaveBeenCalledTimes(0); |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var _color2 = _interopRequireDefault(_color); | ||
var _Twitter = require('./Twitter'); | ||
@@ -41,5 +43,19 @@ | ||
test('Twitter onChange events correctly', function () { | ||
var changeSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Twitter2.default, _extends({}, _color.red, { onChange: changeSpy }))); | ||
expect(changeSpy).toHaveBeenCalledTimes(0); | ||
var swatches = tree.find(_common.Swatch); | ||
swatches.at(0).childAt(0).simulate('click'); | ||
expect(changeSpy).toHaveBeenCalled(); | ||
}); | ||
test('Twitter with onSwatchHover events correctly', function () { | ||
var hoverSpy = jest.fn(); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Twitter2.default, { onSwatchHover: hoverSpy })); | ||
var hoverSpy = jest.fn(function (data) { | ||
expect(_color2.default.simpleCheckForValidColor(data)).toBeTruthy(); | ||
}); | ||
var tree = (0, _enzyme.mount)(_react2.default.createElement(_Twitter2.default, _extends({}, _color.red, { onSwatchHover: hoverSpy }))); | ||
expect(hoverSpy).toHaveBeenCalledTimes(0); | ||
@@ -46,0 +62,0 @@ var swatches = tree.find(_common.Swatch); |
@@ -9,4 +9,4 @@ 'use strict'; | ||
test('helpers/color', function () { | ||
test('simpleCheckForValidColor', function () { | ||
describe('helpers/color', function () { | ||
describe('simpleCheckForValidColor', function () { | ||
test('throws on null', function () { | ||
@@ -16,3 +16,3 @@ var data = null; | ||
return _color2.default.simpleCheckForValidColor(data); | ||
}).to.throw(TypeError); | ||
}).toThrowError(TypeError); | ||
}); | ||
@@ -24,3 +24,3 @@ | ||
return _color2.default.simpleCheckForValidColor(data); | ||
}).to.throw(TypeError); | ||
}).toThrowError(TypeError); | ||
}); | ||
@@ -30,3 +30,3 @@ | ||
var data = 255; | ||
expect(_color2.default.simpleCheckForValidColor(data)).to.equal(data); | ||
expect(_color2.default.simpleCheckForValidColor(data)).toEqual(data); | ||
}); | ||
@@ -36,3 +36,3 @@ | ||
var data = NaN; | ||
expect(_color2.default.simpleCheckForValidColor(data)).to.be.NaN; | ||
expect(isNaN(_color2.default.simpleCheckForValidColor(data))).toBeTruthy(); | ||
}); | ||
@@ -42,3 +42,3 @@ | ||
var data = 'ffffff'; | ||
expect(_color2.default.simpleCheckForValidColor(data)).to.equal(data); | ||
expect(_color2.default.simpleCheckForValidColor(data)).toEqual(data); | ||
}); | ||
@@ -48,3 +48,3 @@ | ||
var data = []; | ||
expect(_color2.default.simpleCheckForValidColor(data)).to.equal(data); | ||
expect(_color2.default.simpleCheckForValidColor(data)).toEqual(data); | ||
}); | ||
@@ -54,3 +54,3 @@ | ||
var data = { r: 0, g: 0, b: 0 }; | ||
expect(_color2.default.simpleCheckForValidColor(data)).to.equal(data); | ||
expect(_color2.default.simpleCheckForValidColor(data)).toEqual(data); | ||
}); | ||
@@ -60,9 +60,9 @@ | ||
var data = { r: NaN }; | ||
expect(_color2.default.simpleCheckForValidColor(data)).to.equal(data); | ||
expect(_color2.default.simpleCheckForValidColor(data)).toEqual(data); | ||
}); | ||
}); | ||
test('toState', function () { | ||
describe('toState', function () { | ||
test('returns an object giving a color in all formats', function () { | ||
expect(_color2.default.toState('red')).to.deep.equal({ | ||
expect(_color2.default.toState('red')).toEqual({ | ||
hsl: { a: 1, h: 0, l: 0.5, s: 1 }, | ||
@@ -78,22 +78,34 @@ hex: '#ff0000', | ||
test('gives hex color with leading hash', function () { | ||
expect(_color2.default.toState('blue')).to.include({ | ||
hex: '#0000ff' | ||
}); | ||
expect(_color2.default.toState('blue').hex).toEqual('#0000ff'); | ||
}); | ||
test('doesn\'t mutate hsl color object', function () { | ||
var originalData = { h: 0, s: 0, l: 0, a: 1 }; | ||
var data = Object.assign({}, originalData); | ||
_color2.default.toState(data); | ||
expect(data).toEqual(originalData); | ||
}); | ||
test('doesn\'t mutate hsv color object', function () { | ||
var originalData = { h: 0, s: 0, v: 0, a: 1 }; | ||
var data = Object.assign({}, originalData); | ||
_color2.default.toState(data); | ||
expect(data).toEqual(originalData); | ||
}); | ||
}); | ||
test('isValidHex', function () { | ||
describe('isValidHex', function () { | ||
test('allows strings of length 3, 6, or 8', function () { | ||
expect(_color2.default.isValidHex('f')).to.be.false; | ||
expect(_color2.default.isValidHex('ff')).to.be.false; | ||
expect(_color2.default.isValidHex('fff')).to.be.true; | ||
expect(_color2.default.isValidHex('ffff')).to.be.false; | ||
expect(_color2.default.isValidHex('fffff')).to.be.false; | ||
expect(_color2.default.isValidHex('ffffff')).to.be.true; | ||
expect(_color2.default.isValidHex('fffffff')).to.be.false; | ||
expect(_color2.default.isValidHex('ffffffff')).to.be.true; | ||
expect(_color2.default.isValidHex('fffffffff')).to.be.false; | ||
expect(_color2.default.isValidHex('ffffffffff')).to.be.false; | ||
expect(_color2.default.isValidHex('fffffffffff')).to.be.false; | ||
expect(_color2.default.isValidHex('ffffffffffff')).to.be.false; | ||
expect(_color2.default.isValidHex('f')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('ff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('fff')).toBeTruthy(); | ||
expect(_color2.default.isValidHex('ffff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('fffff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('ffffff')).toBeTruthy(); | ||
expect(_color2.default.isValidHex('fffffff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('ffffffff')).toBeTruthy(); | ||
expect(_color2.default.isValidHex('fffffffff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('ffffffffff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('fffffffffff')).toBeFalsy(); | ||
expect(_color2.default.isValidHex('ffffffffffff')).toBeFalsy(); | ||
}); | ||
@@ -105,3 +117,3 @@ | ||
var hex = ('000000' + i.toString(16)).slice(-6); | ||
expect(_color2.default.isValidHex(hex)).to.be.true; | ||
expect(_color2.default.isValidHex(hex)).toBeTruthy(); | ||
} | ||
@@ -114,3 +126,3 @@ }); | ||
var hex = ('000000' + i.toString(16)).slice(-6); | ||
expect(_color2.default.isValidHex('#' + hex)).to.be.true; | ||
expect(_color2.default.isValidHex('#' + hex)).toBeTruthy(); | ||
} | ||
@@ -120,15 +132,15 @@ }); | ||
test('is case-insensitive', function () { | ||
expect(_color2.default.isValidHex('ffffff')).to.be.true; | ||
expect(_color2.default.isValidHex('FfFffF')).to.be.true; | ||
expect(_color2.default.isValidHex('FFFFFF')).to.be.true; | ||
expect(_color2.default.isValidHex('ffffff')).toBeTruthy(); | ||
expect(_color2.default.isValidHex('FfFffF')).toBeTruthy(); | ||
expect(_color2.default.isValidHex('FFFFFF')).toBeTruthy(); | ||
}); | ||
test('does not allow non-hex characters', function () { | ||
expect(_color2.default.isValidHex('gggggg')).to.be.false; | ||
expect(_color2.default.isValidHex('gggggg')).toBeFalsy(); | ||
}); | ||
test('does not allow numbers', function () { | ||
expect(_color2.default.isValidHex(0xffffff)).to.be.false; | ||
expect(_color2.default.isValidHex(0xffffff)).toBeFalsy(); | ||
}); | ||
}); | ||
}); /* global test, expect */ | ||
}); /* global test, expect, describe */ |
@@ -320,5 +320,5 @@ // jscs: disable | ||
else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { | ||
color.s = convertToPercentage(color.s, 1); | ||
color.v = convertToPercentage(color.v, 1); | ||
rgb = hsvToRgb(color.h, color.s, color.v); | ||
var s = convertToPercentage(color.s, 1); | ||
var v = convertToPercentage(color.v, 1); | ||
rgb = hsvToRgb(color.h, s, v); | ||
ok = true; | ||
@@ -328,5 +328,5 @@ format = "hsv"; | ||
else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { | ||
color.s = convertToPercentage(color.s); | ||
color.l = convertToPercentage(color.l); | ||
rgb = hslToRgb(color.h, color.s, color.l); | ||
var s = convertToPercentage(color.s); | ||
var l = convertToPercentage(color.l); | ||
rgb = hslToRgb(color.h, s, l); | ||
ok = true; | ||
@@ -967,4 +967,4 @@ format = "hsl"; | ||
// Return a valid alpha value [0,1] with all invalid values being set to 1 | ||
function boundAlpha(a) { | ||
a = parseFloat(a); | ||
function boundAlpha(alpha) { | ||
var a = parseFloat(alpha); | ||
@@ -971,0 +971,0 @@ if (isNaN(a) || a < 0 || a > 1) { |
{ | ||
"name": "react-color", | ||
"version": "2.13.0", | ||
"version": "2.13.1", | ||
"description": "A Collection of Color Pickers from Sketch, Photoshop, Chrome & more", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
763720
13268