add radio component

This commit is contained in:
Keegan
2016-02-14 02:31:46 -08:00
parent f00b288a82
commit 71dd8ef1c3
12 changed files with 186 additions and 31 deletions
+14 -6
View File
@@ -42,7 +42,11 @@ describe('ClayConfig', function() {
describe('.getAllItems()', function() {
it('returns an array of all the items', function() {
var config = fixtures.config(['input', 'text', ['input']]);
var config = fixtures.config([
{type: 'input', clayId: 0},
{type: 'text', clayId: 1},
[{type: 'input', clayId: 2}]
]);
var clayConfig = fixtures.clayConfig(config);
var allItems = clayConfig.getAllItems();
assert.strictEqual(allItems.length, 3);
@@ -55,8 +59,8 @@ describe('ClayConfig', function() {
describe('.getItemByAppKey()', function() {
it('it returns the correct item', function() {
var config = fixtures.config([
{type: 'input', appKey: 'test-app-key'},
{type: 'input', appKey: undefined}
{type: 'input', appKey: 'test-app-key', clayId: 0},
{type: 'input', appKey: undefined, clayId: 1}
]);
var clayConfig = fixtures.clayConfig(config);
assert.deepEqual(clayConfig.getItemByAppKey('test-app-key').config, config[0]);
@@ -66,8 +70,8 @@ describe('ClayConfig', function() {
describe('.getItemById()', function() {
it('it returns the correct item', function() {
var config = fixtures.config([
{type: 'input', id: 'test-id'},
{type: 'input', id: undefined}
{type: 'input', id: 'test-id', clayId: 0},
{type: 'input', id: undefined, clayId: 1}
]);
var clayConfig = fixtures.clayConfig(config);
assert.deepEqual(clayConfig.getItemById('test-id').config, config[0]);
@@ -76,7 +80,11 @@ describe('ClayConfig', function() {
describe('.getItemsByType()', function() {
it('it returns the correct items', function() {
var config = fixtures.config(['input', 'text', 'input']);
var config = fixtures.config([
{type: 'input', clayId: 0},
{type: 'text', clayId: 1},
{type: 'input', clayId: 2}
]);
var clayConfig = fixtures.clayConfig(config);
assert.deepEqual(clayConfig.getItemsByType('input')[0].config, config[0]);
assert.deepEqual(clayConfig.getItemsByType('input')[1].config, config[2]);
+19 -2
View File
@@ -7,7 +7,7 @@ var fixture = require('../../fixture');
describe('manipulators', function() {
/**
* @param {string} itemType
* @param {string|Clay~ConfigItem} itemType
* @param {*} value
* @param {*} [expected]
* @return {void}
@@ -31,7 +31,7 @@ describe('manipulators', function() {
}
/**
* @param {string} itemType
* @param {string|Clay~ConfigItem} itemType
* @return {void}
*/
function testDisable(itemType) {
@@ -85,6 +85,23 @@ describe('manipulators', function() {
testEnable('toggle');
});
describe('radio', function() {
var item = {
type: 'radio',
clayId: 1,
options: [
{ label: '1', value: 'one' },
{ label: '2', value: 'two' },
{ label: '3', value: 'three "quote' }
]
};
testSetGet(item, 'one');
testSetGet(item, 'two');
testSetGet(item, 'three "quote');
testDisable(item);
testEnable(item);
});
describe('color', function() {
testSetGet('color', 'FF0000', 0xff0000);
testSetGet('color', '#FF0000', 0xff0000);