#124/get items by group (#147)

* Add getItemsByGroup function

* Update test

* update readme

* Update README for submit button

* Update docs with ID prop for button and submit components
This commit is contained in:
Keegan Lillo
2016-10-18 09:40:32 -07:00
committed by GitHub
parent 1a63761e43
commit 9c7238d578
3 changed files with 46 additions and 0 deletions
+21
View File
@@ -15,6 +15,7 @@ describe('ClayConfig', function() {
'getItemByMessageKey',
'getItemById',
'getItemsByType',
'getItemsByGroup',
'serialize',
'registerComponent',
'build',
@@ -224,6 +225,7 @@ describe('ClayConfig', function() {
'getItemByMessageKey',
'getItemById',
'getItemsByType',
'getItemsByGroup',
'serialize'
].forEach(function(method) {
it('.' + method + '()', function() {
@@ -287,6 +289,25 @@ describe('ClayConfig', function() {
});
});
describe('.getItemsByGroup()', function() {
it('it returns the correct items', function() {
var config = fixtures.config([
{type: 'input', id: 'g1-0', group: 'group1'},
{type: 'text', id: 'g2-0', group: 'group2'},
{type: 'input', id: 'g1-1', group: 'group1'}
]);
var clayConfig = fixtures.clayConfig(config);
assert.deepEqual(clayConfig.getItemsByGroup('group1'), [
clayConfig.getItemById('g1-0'),
clayConfig.getItemById('g1-1')
]);
assert.deepEqual(clayConfig.getItemsByGroup('group2'), [
clayConfig.getItemById('g2-0')
]);
});
});
describe('.serialize()', function() {
it('returns the correct settings', function() {
var config = [