Publish tests.

This commit is contained in:
Lars Jung
2015-04-22 17:12:45 +02:00
parent 5a8ecd593d
commit c396800dfa
40 changed files with 21478 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
(function () {
'use strict';
chai.Assertion.addChainableMethod('isPlainObject', function () {
this.assert(
_.isPlainObject(this._obj),
'expected ' + this._obj + ' to be a plain Object',
'expected ' + this._obj + ' not to be a plain Object'
);
});
chai.assert.isPlainObject = function (val, msg) {
new chai.Assertion(val, msg).to.be.isPlainObject();
};
}());

View File

@@ -0,0 +1,20 @@
(function () {
'use strict';
chai.Assertion.addChainableMethod('lengthOfKeys', function (count) {
var keyCount = _.keys(this._obj).length;
this.assert(
keyCount === count,
'expected ' + this._obj + ' to have ' + count + ' keys, but has ' + keyCount,
'expected ' + this._obj + ' not to have ' + count + ' keys, but has ' + keyCount
);
});
chai.assert.lengthOfKeys = function (val, count, msg) {
new chai.Assertion(val, msg).to.be.lengthOfKeys(count);
};
}());

2
test/util/global.js Normal file
View File

@@ -0,0 +1,2 @@
window.util = window.util || {};
window.util.GLOBAL = this;

23
test/util/pin.js Normal file
View File

@@ -0,0 +1,23 @@
(function () {
'use strict';
var htmlClasses;
var $pinnedElements;
function pinHtml() {
htmlClasses = $('html').attr('class');
$pinnedElements = $('head,body').children();
}
function restoreHtml() {
$('html').attr('class', htmlClasses);
$('head,body').children().not($pinnedElements).remove();
}
window.util = window.util || {};
window.util.pinHtml = pinHtml;
window.util.restoreHtml = restoreHtml;
}());

32
test/util/uniq.js Normal file
View File

@@ -0,0 +1,32 @@
(function () {
'use strict';
var PREFIX = 'UQ';
var SUFFIX = 'ID';
var LENGTH = 4;
var RE = new RegExp('^' + PREFIX + '\\d{' + LENGTH + '}' + SUFFIX + '$');
var counter = 0;
function uniqId() {
counter += 1;
return PREFIX + ('00000000' + counter).substr(-LENGTH) + SUFFIX;
}
function uniqObj() {
return {uniqId: uniqId()};
}
function isUniqId(uid) {
return RE.test(uid);
}
window.util = window.util || {};
window.util.uniqId = uniqId;
window.util.uniqObj = uniqObj;
window.util.isUniqId = isUniqId;
}());