mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-29 13:26:59 -04:00
Rename all appKey references to messageKey
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ module.exports.configItem = function(config, autoRegister) {
|
||||
|
||||
var result = _.extend({}, {
|
||||
label: config.type + '-label',
|
||||
appKey: 'appKey-' + idCounter,
|
||||
messageKey: 'messageKey-' + idCounter,
|
||||
id: 'id-' + idCounter
|
||||
}, config);
|
||||
|
||||
|
||||
+5
-5
@@ -82,10 +82,10 @@ describe('Clay', function() {
|
||||
var logStub = sinon.stub(console, 'log');
|
||||
Pebble.addEventListener
|
||||
.withArgs('webviewclosed')
|
||||
.callArgWith(1, { response: '%7B%22appKey%22%3A%22value%22%7D' });
|
||||
.callArgWith(1, { response: '%7B%22messageKey%22%3A%22value%22%7D' });
|
||||
|
||||
assert(Pebble.addEventListener.calledWith('webviewclosed'));
|
||||
assert(Pebble.sendAppMessage.calledWith({ appKey: 'value' }));
|
||||
assert(Pebble.sendAppMessage.calledWith({ messageKey: 'value' }));
|
||||
|
||||
Pebble.sendAppMessage.callArg(1);
|
||||
assert(logStub.calledWith('Sent config data to Pebble'));
|
||||
@@ -165,7 +165,7 @@ describe('Clay', function() {
|
||||
describe('string substitutions', function() {
|
||||
var customFn = function() { this.getAllItems(); };
|
||||
var config = fixture.config(['input', 'color']);
|
||||
var settings = { appKey: 'value' };
|
||||
var settings = { messageKey: 'value' };
|
||||
var clay;
|
||||
var html;
|
||||
|
||||
@@ -274,12 +274,12 @@ describe('Clay', function() {
|
||||
it('does not store the response if it is invalid JSON and logs an error',
|
||||
function() {
|
||||
var clay = fixture.clay([]);
|
||||
localStorage.setItem('clay-settings', '{"appKey":"value"}');
|
||||
localStorage.setItem('clay-settings', '{"messageKey":"value"}');
|
||||
|
||||
assert.throws(function() {
|
||||
clay.getSettings('not valid JSON');
|
||||
}, /Not Valid JSON/i);
|
||||
assert.equal(localStorage.getItem('clay-settings'), '{"appKey":"value"}');
|
||||
assert.equal(localStorage.getItem('clay-settings'), '{"messageKey":"value"}');
|
||||
});
|
||||
|
||||
it('Prepares the settings for sendAppMessage', function() {
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('ClayConfig', function() {
|
||||
it('defines read-only properties', function() {
|
||||
var properties = [
|
||||
'EVENTS',
|
||||
'getItemByAppKey',
|
||||
'getItemByMessageKey',
|
||||
'getItemById',
|
||||
'getItemsByType',
|
||||
'serialize',
|
||||
@@ -34,7 +34,7 @@ describe('ClayConfig', function() {
|
||||
* @param {number} fwMinor
|
||||
* @param {Array} capabilities
|
||||
* @param {number} expected
|
||||
* @param {number} notExpected
|
||||
* @param {number} [notExpected] - defaults to the inverse of `expected`
|
||||
* @return {void}
|
||||
*/
|
||||
function testCapabilities(platform, fwMajor, fwMinor, capabilities, expected,
|
||||
@@ -221,7 +221,7 @@ describe('ClayConfig', function() {
|
||||
|
||||
describe('throws when trying to run methods before being built', function() {
|
||||
[
|
||||
'getItemByAppKey',
|
||||
'getItemByMessageKey',
|
||||
'getItemById',
|
||||
'getItemsByType',
|
||||
'serialize'
|
||||
@@ -249,14 +249,17 @@ describe('ClayConfig', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getItemByAppKey()', function() {
|
||||
describe('.getItemByMessageKey()', function() {
|
||||
it('it returns the correct item', function() {
|
||||
var config = fixtures.config([
|
||||
{type: 'input', appKey: 'test-app-key', clayId: 0},
|
||||
{type: 'input', appKey: undefined, clayId: 1}
|
||||
{type: 'input', messageKey: 'test-app-key', clayId: 0},
|
||||
{type: 'input', messageKey: undefined, clayId: 1}
|
||||
]);
|
||||
var clayConfig = fixtures.clayConfig(config);
|
||||
assert.deepEqual(clayConfig.getItemByAppKey('test-app-key').config, config[0]);
|
||||
assert.deepEqual(
|
||||
clayConfig.getItemByMessageKey('test-app-key').config,
|
||||
config[0]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -287,18 +290,18 @@ describe('ClayConfig', function() {
|
||||
describe('.serialize()', function() {
|
||||
it('returns the correct settings', function() {
|
||||
var config = [
|
||||
{type: 'input', appKey: 'test1', defaultValue: 'default val'},
|
||||
{type: 'select', appKey: 'test2', options: [
|
||||
{type: 'input', messageKey: 'test1', defaultValue: 'default val'},
|
||||
{type: 'select', messageKey: 'test2', options: [
|
||||
{label: 'label-1', value: 'val-1'},
|
||||
{label: 'label-2', value: 'val-2'}
|
||||
]},
|
||||
{type: 'toggle', appKey: 'test3'},
|
||||
{type: 'checkboxgroup', appKey: 'test4', options: [
|
||||
{type: 'toggle', messageKey: 'test3'},
|
||||
{type: 'checkboxgroup', messageKey: 'test4', options: [
|
||||
{label: 'label-1', value: 'cb-1'},
|
||||
{label: 'label-2', value: 'cb-2'},
|
||||
{label: 'label-2', value: 'cb-3'}
|
||||
]},
|
||||
{type: 'slider', appKey: 'test5', step: 0.05, defaultValue: 12.5}
|
||||
{type: 'slider', messageKey: 'test5', step: 0.05, defaultValue: 12.5}
|
||||
];
|
||||
var settings = {
|
||||
test2: 'val-2'
|
||||
@@ -314,9 +317,9 @@ describe('ClayConfig', function() {
|
||||
test5: {value: 12.5, precision: 2}
|
||||
});
|
||||
|
||||
clayConfig.getItemByAppKey('test1').set('val-1');
|
||||
clayConfig.getItemByAppKey('test3').set(true);
|
||||
clayConfig.getItemByAppKey('test4').set(['cb-1', 'cb-3']);
|
||||
clayConfig.getItemByMessageKey('test1').set('val-1');
|
||||
clayConfig.getItemByMessageKey('test3').set(true);
|
||||
clayConfig.getItemByMessageKey('test4').set(['cb-1', 'cb-3']);
|
||||
|
||||
assert.deepEqual(clayConfig.serialize(), {
|
||||
test1: {value: 'val-1'},
|
||||
@@ -347,8 +350,8 @@ describe('ClayConfig', function() {
|
||||
|
||||
it('only returns the settings present in the config', function() {
|
||||
var config = [
|
||||
{type: 'input', appKey: 'test1', defaultValue: 'default val'},
|
||||
{type: 'select', appKey: 'test2', options: [
|
||||
{type: 'input', messageKey: 'test1', defaultValue: 'default val'},
|
||||
{type: 'select', messageKey: 'test2', options: [
|
||||
{label: 'label-1', value: 'val-1'},
|
||||
{label: 'label-2', value: 'val-2'}
|
||||
]}
|
||||
|
||||
+12
-10
@@ -12,7 +12,7 @@ describe('ClayItem', function() {
|
||||
it('defines read-only properties', function() {
|
||||
var properties = [
|
||||
'id',
|
||||
'appKey',
|
||||
'messageKey',
|
||||
'config',
|
||||
'$element',
|
||||
'$manipulatorTarget',
|
||||
@@ -53,24 +53,25 @@ describe('ClayItem', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('.appKey', function() {
|
||||
it('sets appKey correctly', function() {
|
||||
describe('.messageKey', function() {
|
||||
it('sets messageKey correctly', function() {
|
||||
var config = fixture.configItem('input');
|
||||
var clayItem = new ClayItem(config);
|
||||
assert.strictEqual(clayItem.appKey, config.appKey);
|
||||
assert.strictEqual(clayItem.messageKey, config.messageKey);
|
||||
});
|
||||
|
||||
it('sets appKey to null if there is no appKey in the config', function() {
|
||||
var clayItem = fixture.clayItem({type: 'input', appKey: undefined});
|
||||
assert.strictEqual(clayItem.appKey, null);
|
||||
it('sets messageKey to null if there is no messageKey in the config',
|
||||
function() {
|
||||
var clayItem = fixture.clayItem({type: 'input', messageKey: undefined});
|
||||
assert.strictEqual(clayItem.messageKey, null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.config', function() {
|
||||
it('sets appKey correctly', function() {
|
||||
it('sets messageKey correctly', function() {
|
||||
var config = fixture.configItem('input');
|
||||
var clayItem = new ClayItem(config);
|
||||
assert.strictEqual(clayItem.appKey, config.appKey);
|
||||
assert.strictEqual(clayItem.messageKey, config.messageKey);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,7 +105,8 @@ describe('ClayItem', function() {
|
||||
|
||||
it('returns itself for chaining', function() {
|
||||
var clayItem = fixture.clayItem('select');
|
||||
assert.strictEqual(clayItem.initialize(), clayItem);
|
||||
var clayConfig = fixture.clayConfig([]);
|
||||
assert.strictEqual(clayItem.initialize(clayConfig), clayItem);
|
||||
});
|
||||
|
||||
it('does nothing if there is no initialize function', function() {
|
||||
|
||||
Reference in New Issue
Block a user