h5ai/test/tests/unit/core/settings.js

105 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-04-22 17:12:45 +02:00
(function () {
'use strict';
var ID = 'core/settings';
var DEPS = ['_', 'config'];
2015-04-22 23:21:48 +02:00
describe('module \'' + ID + '\'', function () {
2015-04-22 17:12:45 +02:00
before(function () {
this.definition = modulejs._private.definitions[ID];
this.xConfig = {
options: {
2015-06-14 15:24:05 +02:00
someOptions: uniq.obj(),
otherOptions: uniq.obj(),
more: uniq.obj()
2015-04-22 17:12:45 +02:00
},
setup: {
2015-06-14 15:24:05 +02:00
PUBLIC_HREF: uniq.id(),
ROOT_HREF: uniq.id()
2015-04-22 17:12:45 +02:00
}
};
this.applyFn = function () {
return this.definition.fn(_, this.xConfig);
};
});
describe('definition', function () {
it('is defined', function () {
assert.isPlainObject(this.definition);
});
it('has correct id', function () {
assert.strictEqual(this.definition.id, ID);
});
it('requires correct', function () {
assert.deepEqual(this.definition.deps, DEPS);
});
it('args for each request', function () {
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
});
it('has no instance', function () {
assert.notProperty(modulejs._private.instances, ID);
});
it('inits without errors', function () {
this.applyFn();
});
});
describe('application', function () {
it('returns plain object with properties', function () {
var instance = this.applyFn();
assert.isPlainObject(instance);
assert.isAbove(_.keys(instance).length, 0);
});
});
describe('publics', function () {
2015-04-22 19:34:35 +02:00
it('extended from options', function () {
2015-04-22 17:12:45 +02:00
var instance = this.applyFn();
assert.strictEqual(instance.someOptions, this.xConfig.options.someOptions);
assert.strictEqual(instance.otherOptions, this.xConfig.options.otherOptions);
assert.strictEqual(instance.more, this.xConfig.options.more);
2015-05-14 14:50:51 +02:00
assert.strictEqual(_.keys(instance).length, _.keys(this.xConfig.options).length + 2);
2015-04-22 17:12:45 +02:00
});
2015-04-22 19:34:35 +02:00
});
2015-05-14 00:13:22 +02:00
describe('.publicHref', function () {
2015-04-22 17:12:45 +02:00
2015-04-22 19:34:35 +02:00
it('set correct', function () {
2015-04-22 17:12:45 +02:00
var instance = this.applyFn();
2015-05-14 00:13:22 +02:00
assert.strictEqual(instance.publicHref, this.xConfig.setup.PUBLIC_HREF);
2015-04-22 17:12:45 +02:00
});
2015-04-22 19:34:35 +02:00
});
2015-04-22 17:12:45 +02:00
2015-04-22 19:34:35 +02:00
describe('.rootHref', function () {
it('set correct', function () {
2015-04-22 17:12:45 +02:00
var instance = this.applyFn();
assert.strictEqual(instance.rootHref, this.xConfig.setup.ROOT_HREF);
});
2015-04-22 19:34:35 +02:00
});
2015-04-22 17:12:45 +02:00
});
}());