mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-01 06:46:49 -04:00
Merge remote-tracking branch 'origin/master' into #47/range-slider-component
# Conflicts: # index.js
This commit is contained in:
@@ -7,6 +7,7 @@ var HTML = require('../../../src/scripts/vendor/minified').HTML;
|
||||
var components = require('../../../src/scripts/components');
|
||||
var manipulators = require('../../../src/scripts/lib/manipulators');
|
||||
var fixture = require('../../fixture');
|
||||
var sinon = require('sinon');
|
||||
|
||||
var componentSchema = Joi.object().keys({
|
||||
name: Joi.string().required(),
|
||||
@@ -39,6 +40,20 @@ describe('components', function() {
|
||||
it('is able to be passed to ClayConfig', function() {
|
||||
fixture.clayConfig([component.name]);
|
||||
});
|
||||
|
||||
it('only has one $manipulatorTarget', function() {
|
||||
var configItem = fixture.clayConfig([component.name]).getAllItems()[0];
|
||||
assert.strictEqual(configItem.$manipulatorTarget.length, 1);
|
||||
});
|
||||
|
||||
it('only dispatches change events once', function() {
|
||||
var configItem = fixture.clayConfig([component.name]).getAllItems()[0];
|
||||
var handler = sinon.spy();
|
||||
configItem.on('change', handler);
|
||||
configItem.trigger('change');
|
||||
assert.strictEqual(handler.callCount, 1);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+25
-31
@@ -7,31 +7,19 @@ var standardComponents = require('../../src/scripts/components');
|
||||
var sinon = require('sinon');
|
||||
var toSource = require('tosource');
|
||||
|
||||
var accountToken = '0123456789abcdef0123456789abcdef';
|
||||
var watchToken = '0123456789abcdef0123456789abcdef';
|
||||
var activeWatchInfo = {
|
||||
platform: 'chalk',
|
||||
model: 'qemu_platform_chalk',
|
||||
language: 'en_US',
|
||||
firmware: {
|
||||
major: 3,
|
||||
minor: 3,
|
||||
patch: 2,
|
||||
suffix: ''
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
function stubPebble() {
|
||||
var meta = fixture.meta();
|
||||
|
||||
global.Pebble = {
|
||||
addEventListener: sinon.stub(),
|
||||
openURL: sinon.stub(),
|
||||
sendAppMessage: sinon.stub(),
|
||||
getActiveWatchInfo: sinon.stub().returns(activeWatchInfo),
|
||||
getAccountToken: sinon.stub().returns(accountToken),
|
||||
getWatchToken: sinon.stub().returns(watchToken)
|
||||
getActiveWatchInfo: sinon.stub().returns(meta.activeWatchInfo),
|
||||
getAccountToken: sinon.stub().returns(meta.accountToken),
|
||||
getWatchToken: sinon.stub().returns(meta.watchToken)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -135,6 +123,15 @@ describe('Clay', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('.config', function() {
|
||||
it('is a copy not a reference', function() {
|
||||
var config = fixture.config(['input', 'text', 'color']);
|
||||
var clay = fixture.clay(config);
|
||||
assert.notStrictEqual(clay.config, config);
|
||||
assert.deepEqual(clay.config, config);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.registerComponent()', function() {
|
||||
it('adds the component to the this.components', function() {
|
||||
var clay = fixture.clay([]);
|
||||
@@ -323,37 +320,34 @@ describe('Clay', function() {
|
||||
var emptyMeta = {
|
||||
activeWatchInfo: null,
|
||||
accountToken: '',
|
||||
watchToken: ''
|
||||
watchToken: '',
|
||||
userData: {}
|
||||
};
|
||||
|
||||
it('populates the meta in the showConfiguration handler', function() {
|
||||
stubPebble();
|
||||
var clay = fixture.clay([]);
|
||||
var userData = {foo: 'bar'};
|
||||
var clay = fixture.clay([], null, {userData: userData});
|
||||
|
||||
// meta only gets populated after showConfiguration happens
|
||||
assert.deepEqual(clay.meta, emptyMeta);
|
||||
Pebble.addEventListener.withArgs('showConfiguration').callArg(1);
|
||||
|
||||
assert.deepEqual(clay.meta, {
|
||||
activeWatchInfo: activeWatchInfo,
|
||||
accountToken: accountToken,
|
||||
watchToken: watchToken
|
||||
});
|
||||
assert.deepEqual(clay.meta, fixture.meta({userData: userData}));
|
||||
});
|
||||
|
||||
it('populates the meta in the ready handler', function() {
|
||||
stubPebble();
|
||||
var clay = fixture.clay([], null, {autoHandleEvents: false});
|
||||
var userData = {foo: 'bar'};
|
||||
var clay = fixture.clay([], null, {
|
||||
autoHandleEvents: false,
|
||||
userData: userData
|
||||
});
|
||||
|
||||
// meta only gets populated after ready happens
|
||||
assert.deepEqual(clay.meta, emptyMeta);
|
||||
Pebble.addEventListener.withArgs('ready').callArg(1);
|
||||
|
||||
assert.deepEqual(clay.meta, {
|
||||
activeWatchInfo: activeWatchInfo,
|
||||
accountToken: accountToken,
|
||||
watchToken: watchToken
|
||||
});
|
||||
assert.deepEqual(clay.meta, fixture.meta({userData: userData}));
|
||||
});
|
||||
|
||||
it('populates the meta with with empty values when there is no Pebble global',
|
||||
|
||||
Reference in New Issue
Block a user