mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-02 07:07:46 -04:00
refactor events to mixin from separate class
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
var _ = require('../src/scripts/vendor/minified/minified')._;
|
||||
var idCounter = 0;
|
||||
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {{}} [config]
|
||||
* @returns {{}}
|
||||
*/
|
||||
function fixture(type, config) {
|
||||
|
||||
var basic = {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ module.exports = function(config) {
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['progress', 'mocha', 'coverage', 'threshold'],
|
||||
reporters: ['mocha', 'coverage', 'threshold'],
|
||||
|
||||
// optionally, configure the reporter
|
||||
coverageReporter: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('chai').assert;
|
||||
var ApiItem = require('../../../src/scripts/lib/clay-item');
|
||||
var ClayItem = require('../../../src/scripts/lib/clay-item');
|
||||
var fixture = require('../../fixture');
|
||||
var items = require('../../../src/scripts/lib/items');
|
||||
|
||||
@@ -18,7 +18,7 @@ function checkReadOnly(object, properties) {
|
||||
});
|
||||
}
|
||||
|
||||
describe('ApiItem', function() {
|
||||
describe('ClayItem', function() {
|
||||
it('defines read-only properties', function() {
|
||||
var properties = [
|
||||
'id',
|
||||
@@ -32,15 +32,36 @@ describe('ApiItem', function() {
|
||||
'trigger',
|
||||
'initialize'
|
||||
];
|
||||
var apiItem = new ApiItem(fixture('input'));
|
||||
var apiItem = new ClayItem(fixture('input'));
|
||||
checkReadOnly(apiItem, properties);
|
||||
});
|
||||
|
||||
it('attaches the manipulator methods', function() {
|
||||
Object.keys(items).forEach(function(itemName) {
|
||||
var apiItem = new ApiItem(fixture(itemName));
|
||||
var clayItem = new ClayItem(fixture(itemName));
|
||||
var manipulator = items[itemName].manipulator;
|
||||
checkReadOnly(apiItem, Object.keys(manipulator));
|
||||
checkReadOnly(clayItem, Object.keys(manipulator));
|
||||
});
|
||||
});
|
||||
|
||||
describe('.id', function() {
|
||||
it('sets id correctly', function() {
|
||||
var config = fixture('input');
|
||||
var clayItem = new ClayItem(config);
|
||||
assert.strictEqual(clayItem.id, config.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.appKey', function() {
|
||||
it('sets appKey correctly', function() {
|
||||
var config = fixture('input');
|
||||
var clayItem = new ClayItem(config);
|
||||
assert.strictEqual(clayItem.appKey, config.appKey);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.$manipulatorTarget', function() {
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
+22
-12
@@ -3,19 +3,29 @@
|
||||
var utils = require('../../../src/scripts/lib/utils');
|
||||
var assert = require('chai').assert;
|
||||
|
||||
describe('.updateProperties', function() {
|
||||
var obj;
|
||||
describe('Utils', function() {
|
||||
describe('.updateProperties', function() {
|
||||
var obj;
|
||||
|
||||
beforeEach(function() {
|
||||
obj = {
|
||||
one: 1,
|
||||
two: 2
|
||||
};
|
||||
});
|
||||
beforeEach(function() {
|
||||
obj = {
|
||||
one: 1,
|
||||
two: 2
|
||||
};
|
||||
});
|
||||
|
||||
it('sets the properties as non-writable', function() {
|
||||
utils.updateProperties(obj, { writable: false });
|
||||
assert.strictEqual(Object.getOwnPropertyDescriptor(obj, 'one').writable, false);
|
||||
assert.strictEqual(Object.getOwnPropertyDescriptor(obj, 'two').writable, false);
|
||||
it('sets the properties as non-writable', function() {
|
||||
utils.updateProperties(obj, { writable: false });
|
||||
assert.strictEqual(
|
||||
Object.getOwnPropertyDescriptor(obj, 'one').writable,
|
||||
false
|
||||
);
|
||||
assert.strictEqual(
|
||||
Object.getOwnPropertyDescriptor(obj, 'two').writable,
|
||||
false
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user