Refactor code.

This commit is contained in:
Lars Jung 2015-05-02 20:16:48 +02:00
parent 16186811a4
commit 167e30dee1
4 changed files with 10 additions and 10 deletions

View file

@ -3,6 +3,6 @@ modulejs.define('core/settings', ['_', 'config'], function (_, config) {
return _.extend({}, config.options, {
appHref: config.setup.APP_HREF,
rootHref: config.setup.ROOT_HREF,
currentHref: config.setup.CURRENT_HREF
version: config.setup.VERSION
});
});

View file

@ -1,10 +1,10 @@
modulejs.define('view/topbar', ['$', 'config', 'view/root'], function ($, config, root) {
modulejs.define('view/topbar', ['$', 'core/settings', 'view/root'], function ($, settings, root) {
var template =
'<div id="topbar">' +
'<div id="toolbar"/>' +
'<div id="flowbar"/>' +
'<a id="backlink" href="http://larsjung.de/h5ai/" title="powered by h5ai ' + config.setup.VERSION + '">' +
'<a id="backlink" href="http://larsjung.de/h5ai/" title="powered by h5ai ' + settings.version + '">' +
'<div>powered</div>' +
'<div>by h5ai</div>' +
'</a>' +

View file

@ -19,7 +19,7 @@ describe('module \'' + ID + '\'', function () {
setup: {
APP_HREF: util.uniqId(),
ROOT_HREF: util.uniqId(),
CURRENT_HREF: util.uniqId()
VERSION: util.uniqId()
}
};
this.applyFn = function () {
@ -101,12 +101,12 @@ describe('module \'' + ID + '\'', function () {
});
});
describe('.currentHref', function () {
describe('.version', function () {
it('set correct', function () {
var instance = this.applyFn();
assert.strictEqual(instance.currentHref, this.xConfig.setup.CURRENT_HREF);
assert.strictEqual(instance.version, this.xConfig.setup.VERSION);
});
});
});

View file

@ -2,7 +2,7 @@
'use strict';
var ID = 'view/topbar';
var DEPS = ['$', 'config', 'view/root'];
var DEPS = ['$', 'core/settings', 'view/root'];
describe('module \'' + ID + '\'', function () {
@ -10,11 +10,11 @@ describe('module \'' + ID + '\'', function () {
this.definition = modulejs._private.definitions[ID];
this.xConfig = {setup: {VERSION: util.uniqId()}};
this.xSettings = {version: util.uniqId()};
this.xRoot = {$el: null};
this.applyFn = function () {
return this.definition.fn($, this.xConfig, this.xRoot);
return this.definition.fn($, this.xSettings, this.xRoot);
};
});
@ -104,7 +104,7 @@ describe('module \'' + ID + '\'', function () {
it('#backlink has correct title', function () {
this.applyFn();
assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai ' + this.xConfig.setup.VERSION);
assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai ' + this.xSettings.version);
});
it('#backlink has correct text', function () {