mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 12:07:10 -04:00
Add integration test.
This commit is contained in:
parent
ea306c7d0c
commit
70c8364349
5 changed files with 154 additions and 20 deletions
|
@ -24,8 +24,7 @@ $(function () {
|
||||||
|
|
||||||
describe('integration tests', function () {
|
describe('integration tests', function () {
|
||||||
|
|
||||||
// @include "tests/integration/first.js"
|
// @include "tests/integration/*.js"
|
||||||
|
|
||||||
// @include "tests/integration/*/*.js"
|
// @include "tests/integration/*/*.js"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
(function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
describe('first', function () {
|
|
||||||
|
|
||||||
it('nothing here', function () {
|
|
||||||
|
|
||||||
assert.isTrue(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
|
135
test/tests/integration/view.js
Normal file
135
test/tests/integration/view.js
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('view', function () {
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
|
||||||
|
this.configBackup = modulejs._private.definitions.config;
|
||||||
|
this.storeKey = '_h5ai';
|
||||||
|
this.xConfig = {
|
||||||
|
setup: {
|
||||||
|
API: true,
|
||||||
|
APP_HREF: util.uniqPath('/APP/'),
|
||||||
|
ROOT_HREF: util.uniqPath('/ROOT/'),
|
||||||
|
CURRENT_HREF: util.uniqPath('/CURRENT/')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function () {
|
||||||
|
|
||||||
|
modulejs._private.definitions.config = this.configBackup;
|
||||||
|
util.clearModulejs();
|
||||||
|
util.restoreHtml();
|
||||||
|
window.localStorage.removeItem(this.storeKey);
|
||||||
|
$('body').removeAttr('id');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
|
||||||
|
delete modulejs._private.definitions.config;
|
||||||
|
modulejs.define('config', this.xConfig);
|
||||||
|
util.clearModulejs();
|
||||||
|
util.restoreHtml();
|
||||||
|
window.localStorage.removeItem(this.storeKey);
|
||||||
|
$('body').removeAttr('id');
|
||||||
|
$('<div id="fallback"/>').appendTo('body');
|
||||||
|
$('<div id="fallback-hints"/>').appendTo('body');
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('requiring view/viewmode', function () {
|
||||||
|
|
||||||
|
it('requires without errors', function () {
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('adds HTML #main-row to #root', function () {
|
||||||
|
|
||||||
|
modulejs.require('view/viewmode');
|
||||||
|
assert.lengthOf($('#root > #main-row'), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('adds HTML #content to #main-row', function () {
|
||||||
|
|
||||||
|
modulejs.require('view/viewmode');
|
||||||
|
assert.lengthOf($('#main-row > #content'), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('adds HTML .block viewmode to #sidebar', function () {
|
||||||
|
|
||||||
|
modulejs.require('view/viewmode');
|
||||||
|
assert.lengthOf($('#sidebar > .block > .l10n-view'), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('adds style to head', function () {
|
||||||
|
|
||||||
|
var styleTagCount = $('head > style').length;
|
||||||
|
modulejs.require('view/viewmode');
|
||||||
|
assert.lengthOf($('head > style'), styleTagCount + 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}());
|
|
@ -11,7 +11,6 @@ describe('module \'' + ID + '\'', function () {
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.storeKey = '_h5ai';
|
this.storeKey = '_h5ai';
|
||||||
this.storeBackup = window.localStorage.getItem(this.storeKey);
|
|
||||||
this.xModernizr = {localstorage: true};
|
this.xModernizr = {localstorage: true};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
|
@ -21,11 +20,12 @@ describe('module \'' + ID + '\'', function () {
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
if (this.storeBackup) {
|
util.restoreHtml();
|
||||||
window.localStorage.setItem(this.storeKey, this.storeBackup);
|
});
|
||||||
} else {
|
|
||||||
window.localStorage.removeItem(this.storeKey);
|
beforeEach(function () {
|
||||||
}
|
|
||||||
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
|
@ -2,21 +2,33 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var title;
|
var title;
|
||||||
|
var htmlId;
|
||||||
var htmlClasses;
|
var htmlClasses;
|
||||||
|
var bodyId;
|
||||||
|
var bodyClasses;
|
||||||
var $pinnedElements;
|
var $pinnedElements;
|
||||||
|
|
||||||
function pinHtml() {
|
function pinHtml() {
|
||||||
|
|
||||||
title = document.title;
|
title = document.title;
|
||||||
|
htmlId = $('html').attr('id');
|
||||||
htmlClasses = $('html').attr('class');
|
htmlClasses = $('html').attr('class');
|
||||||
|
bodyId = $('body').attr('id');
|
||||||
|
bodyClasses = $('body').attr('class');
|
||||||
$pinnedElements = $('head,body').children();
|
$pinnedElements = $('head,body').children();
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreHtml() {
|
function restoreHtml() {
|
||||||
|
|
||||||
document.title = title;
|
document.title = title;
|
||||||
|
$('html').attr('id', htmlId);
|
||||||
$('html').attr('class', htmlClasses);
|
$('html').attr('class', htmlClasses);
|
||||||
|
$('body').attr('id', bodyId);
|
||||||
|
$('body').attr('class', bodyClasses);
|
||||||
$('head,body').children().not($pinnedElements).remove();
|
$('head,body').children().not($pinnedElements).remove();
|
||||||
|
if (window.localStorage && window.localStorage.clear) {
|
||||||
|
window.localStorage.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.util = window.util || {};
|
window.util = window.util || {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue