mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-03 15:47:43 -04:00
Add karma testing framework and some basic tests
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"env": {
|
||||
"mocha": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('chai').assert;
|
||||
var ApiItem = require('../../../src/scripts/lib/api-item');
|
||||
var fixture = require('../../fixture');
|
||||
var items = require('../../../src/scripts/lib/items');
|
||||
|
||||
/**
|
||||
* @param {Object} object
|
||||
* @param {Array} properties
|
||||
*/
|
||||
function checkReadOnly(object, properties) {
|
||||
properties.forEach(function(property) {
|
||||
assert.strictEqual(
|
||||
Object.getOwnPropertyDescriptor(object, property).writable,
|
||||
false
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
describe('ApiItem', function() {
|
||||
it('defines read-only properties', function() {
|
||||
var properties = [
|
||||
'id',
|
||||
'appKey',
|
||||
'config',
|
||||
'$element',
|
||||
'$manipulatorTarget',
|
||||
'on',
|
||||
'one',
|
||||
'off',
|
||||
'trigger',
|
||||
'initialize'
|
||||
];
|
||||
var apiItem = new ApiItem(fixture('input'));
|
||||
checkReadOnly(apiItem, properties);
|
||||
});
|
||||
|
||||
it('attaches the manipulator methods', function() {
|
||||
Object.keys(items).forEach(function(itemName) {
|
||||
var apiItem = new ApiItem(fixture(itemName));
|
||||
var manipulator = items[itemName].manipulator;
|
||||
checkReadOnly(apiItem, Object.keys(manipulator));
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user