add sunlight colors to color picker and tests

This commit is contained in:
Keegan
2016-02-12 16:38:06 -08:00
parent ba74959919
commit 5ad2834cc8
9 changed files with 267 additions and 27 deletions
+20 -3
View File
@@ -9,17 +9,21 @@ describe('manipulators', function() {
/**
* @param {string} itemType
* @param {*} value
* @param {*} expected
* @return {void}
*/
function testSetGet(itemType, value) {
function testSetGet(itemType, value, expected) {
expected = typeof expected === 'undefined' ? value : expected;
describe('.set() and .get()', function() {
it('sets and gets the value then triggers a "change" event', function() {
it('sets: "' + value + '" and gets: "' + expected + '" then triggers "change"',
function() {
var handlerSpy = sinon.spy();
var clayItem = fixture.clayItem(itemType);
clayItem.on('change', handlerSpy);
clayItem.set(value);
assert.strictEqual(clayItem.get(), value);
assert.strictEqual(clayItem.get(), expected);
assert.strictEqual(handlerSpy.callCount, 1, 'handler not called once');
assert(handlerSpy.calledOn(clayItem), 'handler not called on clayItem');
});
@@ -80,4 +84,17 @@ describe('manipulators', function() {
testDisable('toggle');
testEnable('toggle');
});
describe('color', function() {
testSetGet('color', 'FF0000', 0xff0000);
testSetGet('color', '#FF0000', 0xff0000);
testSetGet('color', '0xFF0000', 0xff0000);
testSetGet('color', '#ff0000', 0xff0000);
testSetGet('color', 0xff0000, 0xff0000);
testSetGet('color', '', 0x000000);
testSetGet('color', false, 0x000000);
testSetGet('color', undefined, 0x000000);
testDisable('color');
testEnable('color');
});
});