mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 16:47:37 -04:00
Only send settings that are actually in the config back to the watch
This commit is contained in:
@@ -184,6 +184,9 @@ function ClayConfig(settings, config, $rootContainer, meta) {
|
|||||||
*/
|
*/
|
||||||
self.serialize = function() {
|
self.serialize = function() {
|
||||||
_checkBuilt('serialize');
|
_checkBuilt('serialize');
|
||||||
|
|
||||||
|
_settings = {};
|
||||||
|
|
||||||
_.eachObj(_itemsByAppKey, function(appKey, item) {
|
_.eachObj(_itemsByAppKey, function(appKey, item) {
|
||||||
_settings[appKey] = {
|
_settings[appKey] = {
|
||||||
value: item.get()
|
value: item.get()
|
||||||
|
|||||||
@@ -159,6 +159,26 @@ describe('ClayConfig', function() {
|
|||||||
fixtures.clayConfig(config, true, true, loadedSettings);
|
fixtures.clayConfig(config, true, true, loadedSettings);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('only returns the settings present in the config', function() {
|
||||||
|
var config = [
|
||||||
|
{type: 'input', appKey: 'test1', defaultValue: 'default val'},
|
||||||
|
{type: 'select', appKey: 'test2', options: [
|
||||||
|
{label: 'label-1', value: 'val-1'},
|
||||||
|
{label: 'label-2', value: 'val-2'}
|
||||||
|
]}
|
||||||
|
];
|
||||||
|
var settings = {
|
||||||
|
test2: 'val-2',
|
||||||
|
notInTheConfig: 'Should not exist'
|
||||||
|
};
|
||||||
|
|
||||||
|
var clayConfig = fixtures.clayConfig(config, true, true, settings);
|
||||||
|
assert.deepEqual(clayConfig.serialize(), {
|
||||||
|
test1: {value: 'default val'},
|
||||||
|
test2: {value: 'val-2'}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.registerComponent()', function() {
|
describe('.registerComponent()', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user