Refactor view.

This commit is contained in:
Lars Jung 2015-04-25 13:24:34 +02:00
parent 0be36ea9e8
commit d5221c0d17
16 changed files with 421 additions and 161 deletions

View file

@ -2,7 +2,7 @@
'use strict';
var ID = 'view/viewmode';
var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'core/store'];
var DEPS = ['_', '$', 'core/resource', 'core/settings', 'core/store', 'view/content', 'view/sidebar'];
describe('module \'' + ID + '\'', function () {
@ -20,17 +20,16 @@ describe('module \'' + ID + '\'', function () {
get: sinon.stub(),
put: sinon.stub()
};
this.xEvent = {
sub: sinon.stub()
};
this.xContent = {$view: null};
this.xSidebar = {$el: null};
this.applyFn = function () {
this.xResource.image.reset();
this.xStore.get.reset();
this.xStore.put.reset();
this.xEvent.sub.reset();
return this.definition.fn(_, $, this.xEvent, this.xResource, this.xSettings, this.xStore);
return this.definition.fn(_, $, this.xResource, this.xSettings, this.xStore, this.xContent, this.xSidebar);
};
});
@ -42,7 +41,8 @@ describe('module \'' + ID + '\'', function () {
beforeEach(function () {
util.restoreHtml();
$('<div id="sidebar"/>').appendTo('body');
this.xContent.$view = $('<div id="view"/>').appendTo('body');
this.xSidebar.$el = $('<div id="sidebar"/>').appendTo('body');
});
describe('definition', function () {
@ -86,31 +86,18 @@ describe('module \'' + ID + '\'', function () {
assert.isUndefined(instance);
});
it('adds HTML', function () {
it('adds HTML to #sidebar', function () {
this.applyFn();
assert.lengthOf($('#sidebar > .block > .l10n-view'), 1);
});
it('adds Style', function () {
it('adds Style to head', function () {
var styleTagCount = $('head > style').length;
this.applyFn();
assert.lengthOf($('head > style'), styleTagCount + 1);
});
it('subscribes to 1 event', function () {
this.applyFn();
assert.isTrue(this.xEvent.sub.calledOnce);
});
it('subscribes to location.changed', function () {
this.applyFn();
assert.strictEqual(this.xEvent.sub.firstCall.args[0], 'location.changed');
assert.isFunction(this.xEvent.sub.firstCall.args[1]);
});
});
});