h5ai/test/tests/integration/view.js

130 lines
3.5 KiB
JavaScript
Raw Normal View History

2015-04-29 14:23:15 +02:00
(function () {
'use strict';
describe('view', function () {
before(function () {
this.configBackup = modulejs._private.definitions.config;
this.storeKey = '_h5ai';
this.xConfig = {
setup: {
2015-05-20 01:53:56 +02:00
H5AI_HREF: util.uniqPath('-H5AI/'),
2015-05-03 04:05:42 +02:00
ROOT_HREF: util.uniqPath('-ROOT/')
2015-04-29 14:23:15 +02:00
}
};
});
after(function () {
modulejs._private.definitions.config = this.configBackup;
util.clearModulejs();
util.restoreHtml();
});
beforeEach(function () {
delete modulejs._private.definitions.config;
modulejs.define('config', this.xConfig);
util.clearModulejs();
util.restoreHtml();
$('<div id="fallback"/>').appendTo('body');
$('<div id="fallback-hints"/>').appendTo('body');
});
describe('requiring \'view/viewmode\' sets up basic HTML', function () {
2015-04-29 14:23:15 +02:00
2015-04-29 17:56:44 +02:00
it('runs without errors', function () {
2015-04-29 14:23:15 +02:00
modulejs.require('view/viewmode');
});
it('adds id root to body', function () {
modulejs.require('view/viewmode');
assert.strictEqual($('body').attr('id'), 'root');
});
it('removes HTML #fallback', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#fallback'), 0);
});
it('removes HTML #fallback-hints', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#fallback-hints'), 0);
});
2015-04-29 19:47:37 +02:00
it('adds HTML #mainrow to #root', function () {
2015-04-29 14:23:15 +02:00
modulejs.require('view/viewmode');
2015-04-29 19:47:37 +02:00
assert.lengthOf($('#root > #mainrow'), 1);
2015-04-29 14:23:15 +02:00
});
2015-04-29 19:47:37 +02:00
it('adds HTML #content to #mainrow', function () {
2015-04-29 14:23:15 +02:00
modulejs.require('view/viewmode');
2015-04-29 19:47:37 +02:00
assert.lengthOf($('#mainrow > #content'), 1);
2015-04-29 14:23:15 +02:00
});
it('adds HTML #view to #content', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#content > #view'), 1);
});
it('adds HTML #items to #view', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#view > #items'), 1);
});
it('adds HTML #topbar to #root', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#root > #topbar'), 1);
});
it('adds HTML #toolbar to #topbar', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#topbar > #toolbar'), 1);
});
it('adds HTML #flowbar to #topbar', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#topbar > #flowbar'), 1);
});
it('adds HTML #backlink to #topbar', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#topbar > #backlink'), 1);
});
it('adds HTML #sidebar-toggle to #toolbar', function () {
modulejs.require('view/viewmode');
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
});
2015-05-10 13:05:39 +02:00
it('adds HTML #viewmode-settings to #sidebar', function () {
2015-04-29 14:23:15 +02:00
modulejs.require('view/viewmode');
2015-05-10 13:05:39 +02:00
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
2015-04-29 14:23:15 +02:00
});
it('adds style to head', function () {
var styleTagCount = $('head > style').length;
modulejs.require('view/viewmode');
assert.lengthOf($('head > style'), styleTagCount + 1);
});
});
});
}());