' +
'
' +
diff --git a/src/_h5ai/public/js/lib/view/view.js b/src/_h5ai/public/js/lib/view/view.js
index 7dbb3d0b..be96ecc5 100644
--- a/src/_h5ai/public/js/lib/view/view.js
+++ b/src/_h5ai/public/js/lib/view/view.js
@@ -1,15 +1,14 @@
modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'], function (_, $, event, format, location, resource, allsettings, store, content) {
-
var modes = ['details', 'grid', 'icons'];
var sizes = [20, 40, 60, 80, 100, 150, 200, 250, 300, 350, 400];
var settings = _.extend({
- binaryPrefix: false,
- hideFolders: false,
- hideParentFolder: false,
- modes: modes,
- setParentFolderLabels: false,
- sizes: sizes
- }, allsettings.view);
+ binaryPrefix: false,
+ hideFolders: false,
+ hideParentFolder: false,
+ modes: modes,
+ setParentFolderLabels: false,
+ sizes: sizes
+ }, allsettings.view);
var sortedSizes = settings.sizes.sort(function (a, b) { return a - b; });
var checkedModes = _.intersection(settings.modes, modes);
var storekey = 'view';
@@ -41,46 +40,42 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
function cropSize(size, min, max) {
-
return Math.min(max, Math.max(min, size));
}
function createStyles(size) {
-
var dsize = cropSize(size, 20, 80);
var gsize = cropSize(size, 40, 160);
var isize = cropSize(size, 80, 1000);
var ilsize = Math.round(isize * 4 / 3);
var rules = [
- '#view.view-details.view-size-' + size + ' .item .label { line-height: ' + (dsize + 14) + 'px !important; }',
- '#view.view-details.view-size-' + size + ' .item .date { line-height: ' + (dsize + 14) + 'px !important; }',
- '#view.view-details.view-size-' + size + ' .item .size { line-height: ' + (dsize + 14) + 'px !important; }',
- '#view.view-details.view-size-' + size + ' .square { width: ' + dsize + 'px !important; height: ' + dsize + 'px !important; }',
- '#view.view-details.view-size-' + size + ' .square img { width: ' + dsize + 'px !important; height: ' + dsize + 'px !important; }',
- '#view.view-details.view-size-' + size + ' .label { margin: 0 246px 0 ' + (dsize + 32) + 'px !important; }',
+ '#view.view-details.view-size-' + size + ' .item .label { line-height: ' + (dsize + 14) + 'px !important; }',
+ '#view.view-details.view-size-' + size + ' .item .date { line-height: ' + (dsize + 14) + 'px !important; }',
+ '#view.view-details.view-size-' + size + ' .item .size { line-height: ' + (dsize + 14) + 'px !important; }',
+ '#view.view-details.view-size-' + size + ' .square { width: ' + dsize + 'px !important; height: ' + dsize + 'px !important; }',
+ '#view.view-details.view-size-' + size + ' .square img { width: ' + dsize + 'px !important; height: ' + dsize + 'px !important; }',
+ '#view.view-details.view-size-' + size + ' .label { margin: 0 246px 0 ' + (dsize + 32) + 'px !important; }',
- '#view.view-grid.view-size-' + size + ' .item .label { line-height: ' + gsize + 'px !important; }',
- '#view.view-grid.view-size-' + size + ' .square { width: ' + gsize + 'px !important; height: ' + gsize + 'px !important; }',
- '#view.view-grid.view-size-' + size + ' .square img { width: ' + gsize + 'px !important; height: ' + gsize + 'px !important; }',
+ '#view.view-grid.view-size-' + size + ' .item .label { line-height: ' + gsize + 'px !important; }',
+ '#view.view-grid.view-size-' + size + ' .square { width: ' + gsize + 'px !important; height: ' + gsize + 'px !important; }',
+ '#view.view-grid.view-size-' + size + ' .square img { width: ' + gsize + 'px !important; height: ' + gsize + 'px !important; }',
- '#view.view-icons.view-size-' + size + ' .item { width: ' + ilsize + 'px !important; }',
- '#view.view-icons.view-size-' + size + ' .landscape { width: ' + ilsize + 'px !important; height: ' + isize + 'px !important; }',
- '#view.view-icons.view-size-' + size + ' .landscape img { width: ' + isize + 'px !important; height: ' + isize + 'px !important; }',
- '#view.view-icons.view-size-' + size + ' .landscape .thumb { width: ' + ilsize + 'px !important; }'
- ];
+ '#view.view-icons.view-size-' + size + ' .item { width: ' + ilsize + 'px !important; }',
+ '#view.view-icons.view-size-' + size + ' .landscape { width: ' + ilsize + 'px !important; height: ' + isize + 'px !important; }',
+ '#view.view-icons.view-size-' + size + ' .landscape img { width: ' + isize + 'px !important; height: ' + isize + 'px !important; }',
+ '#view.view-icons.view-size-' + size + ' .landscape .thumb { width: ' + ilsize + 'px !important; }'
+ ];
return rules.join('\n');
}
function addCssStyles() {
-
var styles = _.map(sortedSizes, function (size) { return createStyles(size); });
styles.push('#view .icon img { max-width: ' + settings.maxIconSize + 'px; max-height: ' + settings.maxIconSize + 'px; }');
$('').text(styles.join('\n')).appendTo('head');
}
function set(mode, size) {
-
var stored = store.get(storekey);
mode = mode || stored && stored.mode;
@@ -109,37 +104,30 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
}
function getModes() {
-
return checkedModes;
}
function getSizes() {
-
return sortedSizes;
}
function getMode() {
-
return store.get(storekey).mode;
}
function setMode(mode) {
-
set(mode, null);
}
function getSize() {
-
return store.get(storekey).size;
}
function setSize(size) {
-
set(null, size);
}
function createHtml(item) {
-
var $html = $(tplItem);
var $a = $html.find('a');
var $iconImg = $html.find('.icon img');
@@ -178,56 +166,16 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
}
function onMouseenter() {
-
var item = $(this).closest('.item').data('item');
event.pub('item.mouseenter', item);
}
function onMouseleave() {
-
var item = $(this).closest('.item').data('item');
event.pub('item.mouseleave', item);
}
- function setItems(items) {
-
- var removed = _.map($items.find('.item'), function (item) {
-
- return $(item).data('item');
- });
-
- $items.find('.item').remove();
-
- _.each(items, function (e) {
-
- $items.append(createHtml(e));
- });
-
- content.$el.scrollLeft(0).scrollTop(0);
- checkHint();
- event.pub('view.changed', items, removed);
- }
-
- function changeItems(add, remove) {
-
- _.each(add, function (item) {
-
- createHtml(item).hide().appendTo($items).fadeIn(400);
- });
-
- _.each(remove, function (item) {
-
- item.$view.fadeOut(400, function () {
- item.$view.remove();
- });
- });
-
- checkHint();
- event.pub('view.changed', add, remove);
- }
-
function checkHint() {
-
var hasNoItems = $items.find('.item').not('.folder-parent').length === 0;
if (hasNoItems) {
@@ -237,14 +185,43 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
}
}
- function setHint(l10nKey) {
+ function setItems(items) {
+ var removed = _.map($items.find('.item'), function (item) {
+ return $(item).data('item');
+ });
+ $items.find('.item').remove();
+
+ _.each(items, function (e) {
+ $items.append(createHtml(e));
+ });
+
+ content.$el.scrollLeft(0).scrollTop(0);
+ checkHint();
+ event.pub('view.changed', items, removed);
+ }
+
+ function changeItems(add, remove) {
+ _.each(add, function (item) {
+ createHtml(item).hide().appendTo($items).fadeIn(400);
+ });
+
+ _.each(remove, function (item) {
+ item.$view.fadeOut(400, function () {
+ item.$view.remove();
+ });
+ });
+
+ checkHint();
+ event.pub('view.changed', add, remove);
+ }
+
+ function setHint(l10nKey) {
$hint.removeClass().addClass('l10n-' + l10nKey);
checkHint();
}
function onLocationChanged(item) {
-
if (!item) {
item = location.getItem();
}
@@ -255,10 +232,9 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
items.push(item.parent);
}
- _.each(item.content, function (item) {
-
- if (!(item.isFolder() && settings.hideFolders)) {
- items.push(item);
+ _.each(item.content, function (child) {
+ if (!(child.isFolder() && settings.hideFolders)) {
+ items.push(child);
}
});
@@ -267,13 +243,11 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
}
function onLocationRefreshed(item, added, removed) {
-
var add = [];
- _.each(added, function (item) {
-
- if (!(item.isFolder() && settings.hideFolders)) {
- add.push(item);
+ _.each(added, function (child) {
+ if (!(child.isFolder() && settings.hideFolders)) {
+ add.push(child);
}
});
@@ -282,7 +256,6 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
}
function init() {
-
addCssStyles();
set();
diff --git a/src/_h5ai/public/js/lib/view/viewmode.js b/src/_h5ai/public/js/lib/view/viewmode.js
index 8cb00a76..f361ed5a 100644
--- a/src/_h5ai/public/js/lib/view/viewmode.js
+++ b/src/_h5ai/public/js/lib/view/viewmode.js
@@ -1,8 +1,7 @@
modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'], function (_, $, event, resource, allsettings, sidebar, topbar, view) {
-
var settings = _.extend({
- modeToggle: false
- }, allsettings.view);
+ modeToggle: false
+ }, allsettings.view);
var tplSettings =
'
View
';
var tplMode =
@@ -20,7 +19,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
function onChanged(mode, size) {
-
$('#viewmode-settings .mode').removeClass('active');
$('#viewmode-' + mode).addClass('active');
$('#viewmode-size').val(_.indexOf(sizes, size));
@@ -32,7 +30,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
}
function addSettings() {
-
if (modes.length < 2 && sizes.length < 2) {
return;
}
@@ -43,7 +40,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
_.each(modes, function (mode) {
$(tplMode.replace(/\[MODE\]/g, mode))
.on('click', function () {
-
view.setMode(mode);
})
.appendTo($viewBlock);
@@ -55,7 +51,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
$(tplSize)
.prop('max', max).attr('max', max)
.on('input change', function (ev) {
-
view.setSize(sizes[ev.target.valueAsNumber]);
})
.appendTo($viewBlock);
@@ -65,7 +60,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
}
function onToggle() {
-
var mode = view.getMode();
var nextIdx = (modes.indexOf(mode) + 1) % modes.length;
var nextMode = modes[nextIdx];
@@ -74,7 +68,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
}
function addToggle() {
-
if (settings.modeToggle && modes.length > 1) {
$(tplToggle)
.on('click', onToggle)
@@ -83,7 +76,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
}
function init() {
-
modes = view.getModes();
sizes = view.getSizes();
diff --git a/src/_h5ai/public/js/scripts.js b/src/_h5ai/public/js/scripts.js
index 8375817a..6ad84374 100644
--- a/src/_h5ai/public/js/scripts.js
+++ b/src/_h5ai/public/js/scripts.js
@@ -17,7 +17,7 @@
// @include 'vendor/prism-*.js'
(function () {
- 'use strict';
+ 'use strict'; // eslint-disable-line strict
var win = window;
modulejs.define('_', function () { return win._; });
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 00000000..f1ac9ec4
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,51 @@
+---
+ env:
+ es6: false
+ node: false
+ browser: true
+ mocha: true
+
+ globals:
+ modulejs: false
+ jQuery: false
+ $: false
+ _: false
+ util: false
+ assert: false
+ uniq: false
+ sinon: false
+
+ ecmaFeatures:
+ arrowFunctions: false
+ binaryLiterals: false
+ blockBindings: false
+ classes: false
+ defaultParams: false
+ destructuring: false
+ forOf: false
+ generators: false
+ globalReturn: false
+ jsx: false
+ modules: false
+ objectLiteralComputedProperties: false
+ objectLiteralDuplicateProperties: false
+ objectLiteralShorthandMethods: false
+ objectLiteralShorthandProperties: false
+ octalLiterals: false
+ regexUFlag: false
+ regexYFlag: false
+ spread: false
+ superInFunctions: false
+ templateStrings: false
+ unicodeCodePointEscapes: false
+
+ rules:
+ consistent-this: 0
+ func-names: 0
+ max-nested-callbacks: [1, 5]
+ max-params: [1, 10]
+ no-invalid-this: 0
+ no-var: 0
+ object-shorthand: 0
+ prefer-arrow-callback: 0
+ prefer-reflect: 0
diff --git a/test/index.html.jade b/test/index.html.jade
index 5c7c2cee..f6137360 100644
--- a/test/index.html.jade
+++ b/test/index.html.jade
@@ -1,14 +1,14 @@
doctype html
html
head
- meta( charset="utf-8" )
- meta( http-equiv="x-ua-compatible", content="ie=edge" )
+ meta(charset="utf-8")
+ meta(http-equiv="x-ua-compatible", content="ie=edge")
title h5ai test suite - v#{pkg.version}
- meta( name="viewport", content="width=device-width, initial-scale=1" )
- link( rel="stylesheet", href="h5ai-styles.css" )
- link( rel="stylesheet", href="styles.css" )
- script( src="h5ai-scripts.js" )
- script( src="scripts.js" )
+ meta(name="viewport", content="width=device-width, initial-scale=1")
+ link(rel="stylesheet", href="h5ai-styles.css")
+ link(rel="stylesheet", href="styles.css")
+ script(src="h5ai-scripts.js")
+ script(src="scripts.js")
body
div#mocha
diff --git a/test/scripts.js b/test/scripts.js
index 53aa541e..43b14689 100644
--- a/test/scripts.js
+++ b/test/scripts.js
@@ -1,19 +1,21 @@
// @include "vendor/*.js"
-// @include "util/*.js"
-$(function () {
- 'use strict';
+(function () {
+ 'use strict'; // eslint-disable-line strict
+ // @include "util/*.js"
+}());
+
+jQuery(function () {
+ 'use strict'; // eslint-disable-line strict
util.mockConfigModule();
util.clearModulejs();
util.setupMocha();
describe('all tests', function () {
-
// @include "tests/premisses.js"
describe('unit tests', function () {
-
// @include "tests/unit/modulejs.js"
// @include "tests/unit/libs.js"
// @include "tests/unit/boot.js"
@@ -23,7 +25,6 @@ $(function () {
});
describe('integration tests', function () {
-
// @include "tests/integration/*.js"
// @-include "tests/integration/*/*.js"
});
diff --git a/test/tests/integration/view.js b/test/tests/integration/view.js
index e9ca4def..98f6e02d 100644
--- a/test/tests/integration/view.js
+++ b/test/tests/integration/view.js
@@ -1,129 +1,106 @@
(function () {
-'use strict';
-
-describe('view', function () {
-
- before(function () {
-
- this.configBackup = modulejs._private.definitions.config;
- this.storeKey = '_h5ai';
- this.xConfig = {
- setup: {
- PUBLIC_HREF: uniq.path('-PUBLIC/'),
- ROOT_HREF: uniq.path('-ROOT/')
- }
- };
- });
-
- 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();
- $('
').appendTo('body');
- $('
').appendTo('body');
- });
-
- describe('requiring \'view/viewmode\' sets up basic HTML', function () {
-
- it('runs without errors', function () {
-
- modulejs.require('view/viewmode');
+ describe('view', function () {
+ before(function () {
+ this.configBackup = modulejs._private.definitions.config;
+ this.storeKey = '_h5ai';
+ this.xConfig = {
+ setup: {
+ PUBLIC_HREF: uniq.path('-PUBLIC/'),
+ ROOT_HREF: uniq.path('-ROOT/')
+ }
+ };
});
- it('adds id root to body', function () {
-
- modulejs.require('view/viewmode');
- assert.strictEqual($('body').attr('id'), 'root');
+ after(function () {
+ modulejs._private.definitions.config = this.configBackup;
+ util.clearModulejs();
+ util.restoreHtml();
});
- it('removes HTML #fallback', function () {
-
- modulejs.require('view/viewmode');
- assert.lengthOf($('#fallback'), 0);
+ beforeEach(function () {
+ delete modulejs._private.definitions.config;
+ modulejs.define('config', this.xConfig);
+ util.clearModulejs();
+ util.restoreHtml();
+ $('
').appendTo('body');
+ $('
').appendTo('body');
});
- it('removes HTML #fallback-hints', function () {
+ describe('requiring \'view/viewmode\' sets up basic HTML', function () {
+ it('runs without errors', function () {
+ modulejs.require('view/viewmode');
+ });
- modulejs.require('view/viewmode');
- assert.lengthOf($('#fallback-hints'), 0);
- });
+ it('adds id root to body', function () {
+ modulejs.require('view/viewmode');
+ assert.strictEqual($('body').attr('id'), 'root');
+ });
- it('adds HTML #mainrow to #root', function () {
+ it('removes HTML #fallback', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#fallback'), 0);
+ });
- modulejs.require('view/viewmode');
- assert.lengthOf($('#root > #mainrow'), 1);
- });
+ it('removes HTML #fallback-hints', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#fallback-hints'), 0);
+ });
- it('adds HTML #content to #mainrow', function () {
+ it('adds HTML #mainrow to #root', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#root > #mainrow'), 1);
+ });
- modulejs.require('view/viewmode');
- assert.lengthOf($('#mainrow > #content'), 1);
- });
+ it('adds HTML #content to #mainrow', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#mainrow > #content'), 1);
+ });
- it('adds HTML #view to #content', function () {
+ it('adds HTML #view to #content', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#content > #view'), 1);
+ });
- 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 #items to #view', function () {
+ it('adds HTML #topbar to #root', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#root > #topbar'), 1);
+ });
- modulejs.require('view/viewmode');
- assert.lengthOf($('#view > #items'), 1);
- });
+ it('adds HTML #toolbar to #topbar', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#topbar > #toolbar'), 1);
+ });
- it('adds HTML #topbar to #root', function () {
+ it('adds HTML #flowbar to #topbar', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#topbar > #flowbar'), 1);
+ });
- modulejs.require('view/viewmode');
- assert.lengthOf($('#root > #topbar'), 1);
- });
+ it('adds HTML #backlink to #topbar', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#topbar > #backlink'), 1);
+ });
- it('adds HTML #toolbar to #topbar', function () {
+ it('adds HTML #sidebar-toggle to #toolbar', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
+ });
- modulejs.require('view/viewmode');
- assert.lengthOf($('#topbar > #toolbar'), 1);
- });
+ it('adds HTML #viewmode-settings to #sidebar', function () {
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('#sidebar > #viewmode-settings'), 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 #viewmode-settings to #sidebar', function () {
-
- modulejs.require('view/viewmode');
- assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
- });
-
- it('adds style to head', function () {
-
- var styleTagCount = $('head > style').length;
- modulejs.require('view/viewmode');
- assert.lengthOf($('head > style'), styleTagCount + 1);
+ it('adds style to head', function () {
+ var styleTagCount = $('head > style').length;
+ modulejs.require('view/viewmode');
+ assert.lengthOf($('head > style'), styleTagCount + 1);
+ });
});
});
-});
-
}());
diff --git a/test/tests/premisses.js b/test/tests/premisses.js
index 7c32f5fd..34671082 100644
--- a/test/tests/premisses.js
+++ b/test/tests/premisses.js
@@ -1,81 +1,69 @@
(function () {
-'use strict';
+ describe('premisses', function () {
+ it('window is global object', function () {
+ assert.isObject(window);
+ assert.strictEqual(window, window.window);
+ });
-describe('premisses', function () {
+ it('document is global object', function () {
+ assert.isObject(document);
+ assert.strictEqual(document, window.document);
+ });
- it('window is global object', function () {
+ it('jQuery and $ are global functions', function () {
+ assert.isFunction(jQuery);
+ assert.strictEqual(jQuery, window.jQuery);
+ assert.strictEqual(jQuery.fn.jquery, '2.1.3');
- assert.isObject(window);
- assert.strictEqual(window, window.window);
+ assert.strictEqual($, jQuery);
+ assert.strictEqual($, window.$);
+ });
+
+ it('_ is global function', function () {
+ assert.isFunction(_);
+ assert.strictEqual(_, window._);
+ assert.strictEqual(_.VERSION, '3.9.3');
+ });
+
+ it('util is global object', function () {
+ assert.isPlainObject(util);
+ assert.strictEqual(util, window.util);
+ });
+
+ it('uniq is global object', function () {
+ assert.isPlainObject(uniq);
+ assert.strictEqual(uniq, window.uniq);
+ });
+
+ it('assert.isPlainObject() works', function () {
+ assert.isFunction(assert.isPlainObject);
+
+ assert.isPlainObject({});
+ assert.isPlainObject({a: 1});
+ assert.isPlainObject(Object());
+ assert.isPlainObject(new Object()); // eslint-disable-line no-new-object
+
+ assert.throws(function () { assert.isPlainObject(); });
+ assert.throws(function () { assert.isPlainObject(1); });
+ assert.throws(function () { assert.isPlainObject('a'); });
+ assert.throws(function () { assert.isPlainObject(new Date()); });
+ assert.throws(function () { assert.isPlainObject(/a/); });
+ assert.throws(function () { assert.isPlainObject(function () {}); });
+ assert.throws(function () { assert.isPlainObject(new function A() {}); });
+ });
+
+ it('assert.lengthOfKeys() works', function () {
+ assert.isFunction(assert.lengthOfKeys);
+
+ assert.lengthOfKeys({}, 0);
+ assert.lengthOfKeys({a: true}, 1);
+ assert.lengthOfKeys({a: true, b: 0, c: undefined}, 3);
+
+ assert.throws(function () { assert.lengthOfKeys(); });
+ assert.throws(function () { assert.lengthOfKeys(1); });
+ assert.throws(function () { assert.lengthOfKeys('a'); });
+ assert.throws(function () { assert.lengthOfKeys({}); });
+ assert.throws(function () { assert.lengthOfKeys({}, 1); });
+ });
});
-
- it('document is global object', function () {
-
- assert.isObject(document);
- assert.strictEqual(document, window.document);
- });
-
- it('jQuery and $ are global functions', function () {
-
- assert.isFunction(jQuery);
- assert.strictEqual(jQuery, window.jQuery);
- assert.strictEqual(jQuery.fn.jquery, '2.1.3');
-
- assert.strictEqual($, jQuery);
- assert.strictEqual($, window.$);
- });
-
- it('_ is global function', function () {
-
- assert.isFunction(_);
- assert.strictEqual(_, window._);
- assert.strictEqual(_.VERSION, '3.9.3');
- });
-
- it('util is global object', function () {
-
- assert.isPlainObject(util);
- assert.strictEqual(util, window.util);
- });
-
- it('uniq is global object', function () {
-
- assert.isPlainObject(uniq);
- assert.strictEqual(uniq, window.uniq);
- });
-
- it('assert.isPlainObject() works', function () {
-
- assert.isFunction(assert.isPlainObject);
-
- assert.isPlainObject({});
- assert.isPlainObject({a: 1});
- assert.isPlainObject(Object());
- assert.isPlainObject(new Object());
-
- assert.throws(function () { assert.isPlainObject(); });
- assert.throws(function () { assert.isPlainObject(1); });
- assert.throws(function () { assert.isPlainObject('a'); });
- assert.throws(function () { assert.isPlainObject(new Date()); });
- assert.throws(function () { assert.isPlainObject(/a/); });
- assert.throws(function () { assert.isPlainObject(function () {}); });
- assert.throws(function () { assert.isPlainObject(new function A() {}); });
- });
-
- it('assert.lengthOfKeys() works', function () {
-
- assert.isFunction(assert.lengthOfKeys);
-
- assert.lengthOfKeys({}, 0);
- assert.lengthOfKeys({a: true}, 1);
- assert.lengthOfKeys({a: true, b: 0, c: undefined}, 3);
-
- assert.throws(function () { assert.lengthOfKeys(); });
- assert.throws(function () { assert.lengthOfKeys(1); });
- assert.throws(function () { assert.lengthOfKeys('a'); });
- assert.throws(function () { assert.lengthOfKeys({}); });
- assert.throws(function () { assert.lengthOfKeys({}, 1); });
- });
-});
-
}());
diff --git a/test/tests/unit/boot.js b/test/tests/unit/boot.js
index 7ee4c0fa..2e0e684f 100644
--- a/test/tests/unit/boot.js
+++ b/test/tests/unit/boot.js
@@ -1,105 +1,86 @@
(function () {
-'use strict';
+ var ID = 'boot';
+ var DEPS = ['$', 'core/server'];
-var ID = 'boot';
-var DEPS = ['$', 'core/server'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xConfig = uniq.obj();
+ this.xDefine = sinon.stub(modulejs, 'define');
+ this.xRequire = sinon.stub(modulejs, 'require');
+ this.xServer = {
+ request: sinon.stub().callsArgWith(1, this.xConfig)
+ };
- before(function () {
+ this.applyFn = function () {
+ this.xDefine.reset();
+ this.xRequire.reset();
+ this.xServer.request.reset();
- this.definition = modulejs._private.definitions[ID];
-
- this.xConfig = uniq.obj();
- this.xDefine = sinon.stub(modulejs, 'define');
- this.xRequire = sinon.stub(modulejs, 'require');
- this.xServer = {
- request: sinon.stub().callsArgWith(1, this.xConfig)
- };
-
- this.applyFn = function () {
-
- this.xDefine.reset();
- this.xRequire.reset();
- this.xServer.request.reset();
-
- return this.definition.fn($, this.xServer);
- };
- });
-
- after(function () {
-
- this.xDefine.restore();
- this.xRequire.restore();
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ return this.definition.fn($, this.xServer);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ this.xDefine.restore();
+ this.xRequire.restore();
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns undefined', function () {
+ var instance = this.applyFn();
+ assert.isUndefined(instance);
+ });
- assert.notProperty(modulejs._private.instances, ID);
- });
+ it('no data-module', function () {
+ this.applyFn();
+ assert.isFalse(this.xServer.request.called);
+ assert.isFalse(this.xDefine.called);
+ assert.isFalse(this.xRequire.called);
+ });
- it('inits without errors', function () {
+ it('data-module=\'test\'', function () {
+ $('').attr('data-module', 'test').appendTo('head');
+ this.applyFn();
+ assert.isFalse(this.xServer.request.called);
+ assert.isFalse(this.xDefine.called);
+ assert.isFalse(this.xRequire.called);
+ });
- this.applyFn();
- });
- });
-
- describe('application', function () {
-
- it('returns undefined', function () {
-
- var instance = this.applyFn();
- assert.isUndefined(instance);
- });
-
- it('no data-module', function () {
-
- this.applyFn();
- assert.isFalse(this.xServer.request.called);
- assert.isFalse(this.xDefine.called);
- assert.isFalse(this.xRequire.called);
- });
-
- it('data-module=\'test\'', function () {
-
- $('').attr('data-module', 'test').appendTo('head');
- this.applyFn();
- assert.isFalse(this.xServer.request.called);
- assert.isFalse(this.xDefine.called);
- assert.isFalse(this.xRequire.called);
- });
-
- it('data-module=\'info\'', function () {
-
- var expectedData = {
+ it('data-module=\'info\'', function () {
+ var expectedData = {
action: 'get',
setup: true,
options: true,
@@ -107,25 +88,24 @@ describe('module \'' + ID + '\'', function () {
refresh: true
};
- $('').attr('data-module', 'info').appendTo('head');
+ $('').attr('data-module', 'info').appendTo('head');
- this.applyFn();
+ this.applyFn();
- assert.isTrue(this.xServer.request.calledOnce);
- assert.isPlainObject(this.xServer.request.lastCall.args[0]);
- assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
- assert.isFunction(this.xServer.request.lastCall.args[1]);
+ assert.isTrue(this.xServer.request.calledOnce);
+ assert.isPlainObject(this.xServer.request.lastCall.args[0]);
+ assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
+ assert.isFunction(this.xServer.request.lastCall.args[1]);
- assert.isTrue(this.xDefine.calledOnce);
- assert.deepEqual(this.xDefine.lastCall.args, ['config', this.xConfig]);
+ assert.isTrue(this.xDefine.calledOnce);
+ assert.deepEqual(this.xDefine.lastCall.args, ['config', this.xConfig]);
- assert.isTrue(this.xRequire.calledOnce);
- assert.deepEqual(this.xRequire.lastCall.args, ['main/info']);
- });
+ assert.isTrue(this.xRequire.calledOnce);
+ assert.deepEqual(this.xRequire.lastCall.args, ['main/info']);
+ });
- it('data-module=\'index\'', function () {
-
- var expectedData = {
+ it('data-module=\'index\'', function () {
+ var expectedData = {
action: 'get',
setup: true,
options: true,
@@ -134,22 +114,21 @@ describe('module \'' + ID + '\'', function () {
langs: true
};
- $('').attr('data-module', 'index').appendTo('head');
+ $('').attr('data-module', 'index').appendTo('head');
- this.applyFn();
+ this.applyFn();
- assert.isTrue(this.xServer.request.calledOnce);
- assert.isPlainObject(this.xServer.request.lastCall.args[0]);
- assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
- assert.isFunction(this.xServer.request.lastCall.args[1]);
+ assert.isTrue(this.xServer.request.calledOnce);
+ assert.isPlainObject(this.xServer.request.lastCall.args[0]);
+ assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
+ assert.isFunction(this.xServer.request.lastCall.args[1]);
- assert.isTrue(this.xDefine.calledOnce);
- assert.deepEqual(this.xDefine.lastCall.args, ['config', this.xConfig]);
+ assert.isTrue(this.xDefine.calledOnce);
+ assert.deepEqual(this.xDefine.lastCall.args, ['config', this.xConfig]);
- assert.isTrue(this.xRequire.calledOnce);
- assert.deepEqual(this.xRequire.lastCall.args, ['main/index']);
+ assert.isTrue(this.xRequire.calledOnce);
+ assert.deepEqual(this.xRequire.lastCall.args, ['main/index']);
+ });
});
});
-});
-
}());
diff --git a/test/tests/unit/config.js b/test/tests/unit/config.js
index 2bfffb15..2eb72079 100644
--- a/test/tests/unit/config.js
+++ b/test/tests/unit/config.js
@@ -1,61 +1,47 @@
(function () {
-'use strict';
+ var ID = 'config';
+ var DEPS = [];
-var ID = 'config';
-var DEPS = [];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.applyFn = function () {
-
- return this.definition.fn($);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ return this.definition.fn($);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
- });
+ it('has correct id', function () {
+ assert.strictEqual(this.definition.id, ID);
+ });
- it('requires correct', function () {
+ it('requires correct', function () {
+ assert.deepEqual(this.definition.deps, DEPS);
+ });
- assert.deepEqual(this.definition.deps, DEPS);
- });
+ it('args for each request', function () {
+ assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ });
- it('args for each request', function () {
+ it('has no instance', function () {
+ assert.notProperty(modulejs._private.instances, ID);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
- });
+ it('inits without errors', function () {
+ this.applyFn();
+ });
- it('has no instance', function () {
-
- assert.notProperty(modulejs._private.instances, ID);
- });
-
- it('inits without errors', function () {
-
- this.applyFn();
- });
-
- it('is only dummy definition', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 1);
- assert.isTrue(uniq.isId(instance._uniq_id));
+ it('is only dummy definition', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 1);
+ assert.isTrue(uniq.isId(instance._uniq_id));
+ });
});
});
-});
-
}());
diff --git a/test/tests/unit/core/event.js b/test/tests/unit/core/event.js
index 2a5d0ea5..8d01a8d4 100644
--- a/test/tests/unit/core/event.js
+++ b/test/tests/unit/core/event.js
@@ -1,127 +1,104 @@
(function () {
-'use strict';
+ var ID = 'core/event';
+ var DEPS = ['_'];
-var ID = 'core/event';
-var DEPS = ['_'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.applyFn = function () {
-
- return this.definition.fn(_);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ return this.definition.fn(_);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ describe('application', function () {
+ it('returns plain object with 3 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 3);
+ });
});
- it('args for each request', function () {
-
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ describe('.sub()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.sub);
+ });
});
- it('has no instance', function () {
-
- assert.notProperty(modulejs._private.instances, ID);
+ describe('.unsub()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.unsub);
+ });
});
- it('inits without errors', function () {
+ describe('.pub()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.pub);
+ });
+ });
- this.applyFn();
+ describe('works', function () {
+ it('works', function () {
+ var topic = 'topic';
+ var arg1 = 'arg1';
+ var arg2 = 'arg2';
+ var arg3 = 'arg3';
+ var subSpy = sinon.spy();
+
+ var instance = this.applyFn();
+ instance.sub(topic, subSpy);
+ instance.pub(topic, arg1, arg2, arg3);
+
+ assert.isTrue(subSpy.calledOnce);
+ assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
+
+ instance.pub(topic, arg1, arg2);
+
+ assert.isTrue(subSpy.calledTwice);
+ assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
+ assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
+
+ instance.unsub(topic, subSpy);
+
+ assert.isTrue(subSpy.calledTwice);
+ assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
+ assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
+
+ instance.pub(topic, arg1);
+
+ assert.isTrue(subSpy.calledTwice);
+ assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
+ assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
+ });
});
});
-
- describe('application', function () {
-
- it('returns plain object with 3 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 3);
- });
- });
-
- describe('.sub()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.sub);
- });
- });
-
- describe('.unsub()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.unsub);
- });
- });
-
- describe('.pub()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.pub);
- });
- });
-
- describe('works', function () {
-
- it('works', function () {
-
- var topic = 'topic';
- var arg1 = 'arg1';
- var arg2 = 'arg2';
- var arg3 = 'arg3';
- var subSpy = sinon.spy();
-
- var instance = this.applyFn();
- instance.sub(topic, subSpy);
- instance.pub(topic, arg1, arg2, arg3);
-
- assert.isTrue(subSpy.calledOnce);
- assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
-
- instance.pub(topic, arg1, arg2);
-
- assert.isTrue(subSpy.calledTwice);
- assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
- assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
-
- instance.unsub(topic, subSpy);
-
- assert.isTrue(subSpy.calledTwice);
- assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
- assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
-
- instance.pub(topic, arg1);
-
- assert.isTrue(subSpy.calledTwice);
- assert.deepEqual(subSpy.firstCall.args, [arg1, arg2, arg3]);
- assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/format.js b/test/tests/unit/core/format.js
index 7f69c152..cc8b6725 100644
--- a/test/tests/unit/core/format.js
+++ b/test/tests/unit/core/format.js
@@ -1,221 +1,188 @@
(function () {
-'use strict';
+ var ID = 'core/format';
+ var DEPS = ['_'];
-var ID = 'core/format';
-var DEPS = ['_'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.applyFn = function () {
-
- return this.definition.fn(_);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ return this.definition.fn(_);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
- });
+ it('has correct id', function () {
+ assert.strictEqual(this.definition.id, ID);
+ });
- it('requires correct', function () {
+ it('requires correct', function () {
+ assert.deepEqual(this.definition.deps, DEPS);
+ });
- assert.deepEqual(this.definition.deps, DEPS);
- });
+ it('args for each request', function () {
+ assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ });
- it('args for each request', function () {
+ it('has no instance', function () {
+ assert.notProperty(modulejs._private.instances, ID);
+ });
- 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 4 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 4);
- });
- });
-
- describe('.setDefaultMetric()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.setDefaultMetric);
- });
- });
-
- describe('.formatSize()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.formatSize);
- });
-
- it('defaults to decimal metric', function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.formatSize(1024), '1 KB');
- instance.setDefaultMetric(true);
- assert.strictEqual(instance.formatSize(1024), '1 KiB');
- instance.setDefaultMetric(false);
- assert.strictEqual(instance.formatSize(1024), '1 KB');
- });
-
- describe('decimal metric', function () {
-
- _.each([
- [0, '0 B'],
- [10, '10 B'],
- [999, '999 B'],
- [1000, '1 KB'],
- [1001, '1 KB'],
- [1499, '1 KB'],
- [1500, '2 KB'],
- [999999, '1000 KB'],
- [1000000, '1.0 MB'],
- [1000001, '1.0 MB'],
- [1230000, '1.2 MB'],
- [1250000, '1.3 MB'],
- [999999999, '1000.0 MB'],
- [1000000000, '1.0 GB'],
- [1250000000, '1.3 GB'],
- [999999999999, '1000.0 GB'],
- [1000000000000, '1.0 TB'],
- [1250000000000, '1.3 TB']
- ], function (data) {
-
- var arg = data[0];
- var exp = data[1];
-
- it(arg + ' => ' + exp, function () {
-
- var instance = this.applyFn();
- instance.setDefaultMetric(false);
- assert.strictEqual(instance.formatSize(arg), exp);
- });
+ it('inits without errors', function () {
+ this.applyFn();
});
});
- describe('binary metric', function () {
-
- _.each([
- [0, '0 B'],
- [10, '10 B'],
- [999, '999 B'],
- [1000, '1000 B'],
- [1001, '1001 B'],
- [1024, '1 KiB'],
- [1499, '1 KiB'],
- [1500, '1 KiB'],
- [999999, '977 KiB'],
- [1000000, '977 KiB'],
- [1000001, '977 KiB'],
- [1230000, '1.2 MiB'],
- [1250000, '1.2 MiB'],
- [999999999, '953.7 MiB'],
- [1000000000, '953.7 MiB'],
- [1250000000, '1.2 GiB'],
- [999999999999, '931.3 GiB'],
- [1000000000000, '931.3 GiB'],
- [1250000000000, '1.1 TiB']
- ], function (data) {
-
- var arg = data[0];
- var exp = data[1];
-
- it(arg + ' => ' + exp, function () {
-
- var instance = this.applyFn();
- instance.setDefaultMetric(true);
- assert.strictEqual(instance.formatSize(arg), exp);
- });
- });
- });
- });
-
- describe('.setDefaultDateFormat()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.setDefaultDateFormat);
- });
- });
-
- describe('.formatDate()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.formatDate);
- });
-
- it('default format', function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.formatDate(0), '');
- assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00');
- assert.strictEqual(instance.formatDate(-1000), '1970-01-01 00:59');
- assert.strictEqual(instance.formatDate(1400000000000), '2014-05-13 18:53');
-
- instance.setDefaultDateFormat('YYYY-MM-DD HH:mm:ss');
- assert.strictEqual(instance.formatDate(0), '');
- assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00:01');
- assert.strictEqual(instance.formatDate(-1000), '1970-01-01 00:59:59');
- assert.strictEqual(instance.formatDate(1400000000000), '2014-05-13 18:53:20');
-
- instance.setDefaultDateFormat('H YY s');
- assert.strictEqual(instance.formatDate(0), '');
- assert.strictEqual(instance.formatDate(1000), '1 70 1');
- assert.strictEqual(instance.formatDate(-1000), '0 70 59');
- assert.strictEqual(instance.formatDate(1400000000000), '18 14 20');
- });
-
- _.each([
- [0, 'YYYY-MM-DD HH:mm:ss', ''],
- [1000, 'YYYY-MM-DD HH:mm:ss', '1970-01-01 01:00:01'],
- [-1000, 'YYYY-MM-DD HH:mm:ss', '1970-01-01 00:59:59'],
- [1400000000000, 'YYYY-MM-DD HH:mm:ss', '2014-05-13 18:53:20'],
- [1400000000000, 'XYYYYXMMXDDXHHXmmXssX', 'X2014X05X13X18X53X20X'],
- [1400000000000, 'YYYY YY Y MM M DD D HH H mm m ss s', '2014 14 2014 05 5 13 13 18 18 53 53 20 20']
- ], function (data) {
-
- var arg1 = data[0];
- var arg2 = data[1];
- var exp = data[2];
-
- it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
-
+ describe('application', function () {
+ it('returns plain object with 4 properties', function () {
var instance = this.applyFn();
- assert.strictEqual(instance.formatDate(arg1, arg2), exp);
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 4);
+ });
+ });
+
+ describe('.setDefaultMetric()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.setDefaultMetric);
+ });
+ });
+
+ describe('.formatSize()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.formatSize);
+ });
+
+ it('defaults to decimal metric', function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.formatSize(1024), '1 KB');
+ instance.setDefaultMetric(true);
+ assert.strictEqual(instance.formatSize(1024), '1 KiB');
+ instance.setDefaultMetric(false);
+ assert.strictEqual(instance.formatSize(1024), '1 KB');
+ });
+
+ describe('decimal metric', function () {
+ _.each([
+ [0, '0 B'],
+ [10, '10 B'],
+ [999, '999 B'],
+ [1000, '1 KB'],
+ [1001, '1 KB'],
+ [1499, '1 KB'],
+ [1500, '2 KB'],
+ [999999, '1000 KB'],
+ [1000000, '1.0 MB'],
+ [1000001, '1.0 MB'],
+ [1230000, '1.2 MB'],
+ [1250000, '1.3 MB'],
+ [999999999, '1000.0 MB'],
+ [1000000000, '1.0 GB'],
+ [1250000000, '1.3 GB'],
+ [999999999999, '1000.0 GB'],
+ [1000000000000, '1.0 TB'],
+ [1250000000000, '1.3 TB']
+ ], function (data) {
+ var arg = data[0];
+ var exp = data[1];
+
+ it(arg + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ instance.setDefaultMetric(false);
+ assert.strictEqual(instance.formatSize(arg), exp);
+ });
+ });
+ });
+
+ describe('binary metric', function () {
+ _.each([
+ [0, '0 B'],
+ [10, '10 B'],
+ [999, '999 B'],
+ [1000, '1000 B'],
+ [1001, '1001 B'],
+ [1024, '1 KiB'],
+ [1499, '1 KiB'],
+ [1500, '1 KiB'],
+ [999999, '977 KiB'],
+ [1000000, '977 KiB'],
+ [1000001, '977 KiB'],
+ [1230000, '1.2 MiB'],
+ [1250000, '1.2 MiB'],
+ [999999999, '953.7 MiB'],
+ [1000000000, '953.7 MiB'],
+ [1250000000, '1.2 GiB'],
+ [999999999999, '931.3 GiB'],
+ [1000000000000, '931.3 GiB'],
+ [1250000000000, '1.1 TiB']
+ ], function (data) {
+ var arg = data[0];
+ var exp = data[1];
+
+ it(arg + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ instance.setDefaultMetric(true);
+ assert.strictEqual(instance.formatSize(arg), exp);
+ });
+ });
+ });
+ });
+
+ describe('.setDefaultDateFormat()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.setDefaultDateFormat);
+ });
+ });
+
+ describe('.formatDate()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.formatDate);
+ });
+
+ it('default format', function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.formatDate(0), '');
+ assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00');
+ assert.strictEqual(instance.formatDate(-1000), '1970-01-01 00:59');
+ assert.strictEqual(instance.formatDate(1400000000000), '2014-05-13 18:53');
+
+ instance.setDefaultDateFormat('YYYY-MM-DD HH:mm:ss');
+ assert.strictEqual(instance.formatDate(0), '');
+ assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00:01');
+ assert.strictEqual(instance.formatDate(-1000), '1970-01-01 00:59:59');
+ assert.strictEqual(instance.formatDate(1400000000000), '2014-05-13 18:53:20');
+
+ instance.setDefaultDateFormat('H YY s');
+ assert.strictEqual(instance.formatDate(0), '');
+ assert.strictEqual(instance.formatDate(1000), '1 70 1');
+ assert.strictEqual(instance.formatDate(-1000), '0 70 59');
+ assert.strictEqual(instance.formatDate(1400000000000), '18 14 20');
+ });
+
+ _.each([
+ [0, 'YYYY-MM-DD HH:mm:ss', ''],
+ [1000, 'YYYY-MM-DD HH:mm:ss', '1970-01-01 01:00:01'],
+ [-1000, 'YYYY-MM-DD HH:mm:ss', '1970-01-01 00:59:59'],
+ [1400000000000, 'YYYY-MM-DD HH:mm:ss', '2014-05-13 18:53:20'],
+ [1400000000000, 'XYYYYXMMXDDXHHXmmXssX', 'X2014X05X13X18X53X20X'],
+ [1400000000000, 'YYYY YY Y MM M DD D HH H mm m ss s', '2014 14 2014 05 5 13 13 18 18 53 53 20 20']
+ ], function (data) {
+ var arg1 = data[0];
+ var arg2 = data[1];
+ var exp = data[2];
+
+ it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.formatDate(arg1, arg2), exp);
+ });
});
});
});
-});
-
}());
diff --git a/test/tests/unit/core/langs.js b/test/tests/unit/core/langs.js
index 47bda5bb..a6c181e4 100644
--- a/test/tests/unit/core/langs.js
+++ b/test/tests/unit/core/langs.js
@@ -1,64 +1,49 @@
(function () {
-'use strict';
+ var ID = 'core/langs';
+ var DEPS = ['_', 'config'];
-var ID = 'core/langs';
-var DEPS = ['_', 'config'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xConfig = {langs: uniq.obj()};
- this.applyFn = function () {
-
- return this.definition.fn(_, this.xConfig);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xConfig = {langs: uniq.obj()};
+ this.applyFn = function () {
+ return this.definition.fn(_, this.xConfig);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- 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 right content', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.deepEqual(instance, this.xConfig.langs);
+ });
});
});
-
- describe('application', function () {
-
- it('returns plain object with right content', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.deepEqual(instance, this.xConfig.langs);
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/location.js b/test/tests/unit/core/location.js
index c4bd839b..ea95c1bb 100644
--- a/test/tests/unit/core/location.js
+++ b/test/tests/unit/core/location.js
@@ -1,309 +1,266 @@
(function () {
-'use strict';
+ var ID = 'core/location';
+ var DEPS = ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'];
-var ID = 'core/location';
-var DEPS = ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xModernizr = {
+ history: true
+ };
+ this.xSettings = {view: {
+ fastBrowsing: true,
+ unmanagedInNewWindow: true
+ }};
+ this.xEvent = {
+ pub: sinon.stub(),
+ sub: sinon.stub()
+ };
+ this.xNotification = {
+ set: sinon.stub()
+ };
+ this.applyFn = function () {
+ this.xEvent.pub.reset();
+ this.xEvent.sub.reset();
+ this.xNotification.set.reset();
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xModernizr = {
- history: true
- };
- this.xSettings = {view: {
- fastBrowsing: true,
- unmanagedInNewWindow: true
- }};
- this.xEvent = {
- pub: sinon.stub(),
- sub: sinon.stub()
- };
- this.xNotification = {
- set: sinon.stub()
- };
- this.applyFn = function () {
-
- this.xEvent.pub.reset();
- this.xEvent.sub.reset();
- this.xNotification.set.reset();
-
- return this.definition.fn(_, this.xEvent, this.xModernizr, this.xSettings, this.xNotification);
- };
- });
-
- after(function () {
-
- window.onpopstate = null;
- });
-
- beforeEach(function () {
-
- window.onpopstate = null;
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ return this.definition.fn(_, this.xEvent, this.xModernizr, this.xSettings, this.xNotification);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ window.onpopstate = null;
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ window.onpopstate = null;
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- 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 7 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 7);
- });
-
- it('sets window.onpopstate function when history and fastBrowsing', function () {
-
- this.xModernizr.history = true;
- this.xSettings.view.fastBrowsing = true;
-
- assert.isNull(window.onpopstate);
- this.applyFn();
- assert.isFunction(window.onpopstate);
- });
-
- it('sets window.onpopstate to null when not history and fastBrowsing', function () {
-
- this.xModernizr.history = false;
- this.xSettings.view.fastBrowsing = true;
-
- assert.isNull(window.onpopstate);
- this.applyFn();
- assert.isNull(window.onpopstate);
- });
-
- it('sets window.onpopstate to null when history and not fastBrowsing', function () {
-
- this.xModernizr.history = true;
- this.xSettings.view.fastBrowsing = false;
-
- assert.isNull(window.onpopstate);
- this.applyFn();
- assert.isNull(window.onpopstate);
- });
-
- it('sets window.onpopstate to null when not history and not fastBrowsing', function () {
-
- this.xModernizr.history = false;
- this.xSettings.view.fastBrowsing = false;
-
- assert.isNull(window.onpopstate);
- this.applyFn();
- assert.isNull(window.onpopstate);
- });
- });
-
- describe('.forceEncoding()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.forceEncoding);
- });
-
- _.each([
- ['', ''],
- ['//', '/'],
- ['////', '/'],
- ['//a///b////c//', '/a/b/c/'],
- ['a b', 'a%20b'],
- ['ab ', 'ab%20'],
- [' ab', '%20ab'],
- ['a!b', 'a%21b'],
- ['a#b', 'a%23b'],
- ['a$b', 'a%24b'],
- ['a&b', 'a%26b'],
- ['a\'b', 'a%27b'],
- ['a(b', 'a%28b'],
- ['a)b', 'a%29b'],
- ['a*b', 'a%2Ab'],
- ['a+b', 'a%2Bb'],
- ['a,b', 'a%2Cb'],
- ['a:b', 'a%3Ab'],
- ['a;b', 'a%3Bb'],
- ['a=b', 'a%3Db'],
- ['a?b', 'a%3Fb'],
- ['a@b', 'a%40b'],
- ['a[b', 'a%5Bb'],
- ['a]b', 'a%5Db']
- ], function (data) {
-
- var arg = data[0];
- var exp = data[1];
-
- it(arg + ' => ' + exp, function () {
-
+ describe('application', function () {
+ it('returns plain object with 7 properties', function () {
var instance = this.applyFn();
- assert.strictEqual(instance.forceEncoding(arg), exp);
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 7);
+ });
+
+ it('sets window.onpopstate function when history and fastBrowsing', function () {
+ this.xModernizr.history = true;
+ this.xSettings.view.fastBrowsing = true;
+
+ assert.isNull(window.onpopstate);
+ this.applyFn();
+ assert.isFunction(window.onpopstate);
+ });
+
+ it('sets window.onpopstate to null when not history and fastBrowsing', function () {
+ this.xModernizr.history = false;
+ this.xSettings.view.fastBrowsing = true;
+
+ assert.isNull(window.onpopstate);
+ this.applyFn();
+ assert.isNull(window.onpopstate);
+ });
+
+ it('sets window.onpopstate to null when history and not fastBrowsing', function () {
+ this.xModernizr.history = true;
+ this.xSettings.view.fastBrowsing = false;
+
+ assert.isNull(window.onpopstate);
+ this.applyFn();
+ assert.isNull(window.onpopstate);
+ });
+
+ it('sets window.onpopstate to null when not history and not fastBrowsing', function () {
+ this.xModernizr.history = false;
+ this.xSettings.view.fastBrowsing = false;
+
+ assert.isNull(window.onpopstate);
+ this.applyFn();
+ assert.isNull(window.onpopstate);
+ });
+ });
+
+ describe('.forceEncoding()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.forceEncoding);
+ });
+
+ _.each([
+ ['', ''],
+ ['//', '/'],
+ ['////', '/'],
+ ['//a///b////c//', '/a/b/c/'],
+ ['a b', 'a%20b'],
+ ['ab ', 'ab%20'],
+ [' ab', '%20ab'],
+ ['a!b', 'a%21b'],
+ ['a#b', 'a%23b'],
+ ['a$b', 'a%24b'],
+ ['a&b', 'a%26b'],
+ ['a\'b', 'a%27b'],
+ ['a(b', 'a%28b'],
+ ['a)b', 'a%29b'],
+ ['a*b', 'a%2Ab'],
+ ['a+b', 'a%2Bb'],
+ ['a,b', 'a%2Cb'],
+ ['a:b', 'a%3Ab'],
+ ['a;b', 'a%3Bb'],
+ ['a=b', 'a%3Db'],
+ ['a?b', 'a%3Fb'],
+ ['a@b', 'a%40b'],
+ ['a[b', 'a%5Bb'],
+ ['a]b', 'a%5Db']
+ ], function (data) {
+ var arg = data[0];
+ var exp = data[1];
+
+ it(arg + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.forceEncoding(arg), exp);
+ });
+ });
+ });
+
+ describe('.getDomain()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.getDomain);
+ });
+
+ it('returns document.domain', function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.getDomain(), window.document.domain);
+ });
+ });
+
+ describe('.getAbsHref()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.getAbsHref);
+ });
+
+ it('returns null before .setLocation()', function () {
+ var instance = this.applyFn();
+ assert.isNull(instance.getAbsHref());
+ });
+ });
+
+ describe('.getItem()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.getItem);
+ });
+ });
+
+ describe('.setLocation()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.setLocation);
+ });
+ });
+
+ describe('.refresh()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.refresh);
+ });
+ });
+
+ describe('.setLink()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.setLink);
+ });
+
+ it('sets href correct', function () {
+ var $el = $('
');
+ var item = {
+ absHref: uniq.id(),
+ isManaged: false,
+ isFolder: sinon.stub().returns(false)
+ };
+
+ var setLink = this.applyFn().setLink;
+ setLink($el, item);
+
+ assert.strictEqual($el.attr('href'), item.absHref);
+ });
+
+ it('sets target=\'_blank\' for unmanaged folders', function () {
+ this.xSettings.view.unmanagedInNewWindow = true;
+
+ var $el = $('
');
+ var item = {
+ absHref: uniq.id(),
+ isManaged: false,
+ isFolder: sinon.stub().returns(true)
+ };
+
+ var setLink = this.applyFn().setLink;
+ setLink($el, item);
+
+ assert.strictEqual($el.attr('target'), '_blank');
+ });
+
+ it('does not set target=\'_blank\' for managed folders', function () {
+ this.xSettings.view.unmanagedInNewWindow = true;
+
+ var $el = $('
');
+ var item = {
+ absHref: uniq.id(),
+ isManaged: true,
+ isFolder: sinon.stub().returns(true)
+ };
+
+ var setLink = this.applyFn().setLink;
+ setLink($el, item);
+
+ assert.isUndefined($el.attr('target'));
+ });
+
+ it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
+ this.xSettings.view.unmanagedInNewWindow = false;
+
+ var $el = $('
');
+ var item = {
+ absHref: uniq.id(),
+ isManaged: true,
+ isFolder: sinon.stub().returns(true)
+ };
+
+ var setLink = this.applyFn().setLink;
+ setLink($el, item);
+
+ assert.isUndefined($el.attr('target'));
});
});
});
-
- describe('.getDomain()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.getDomain);
- });
-
- it('returns document.domain', function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.getDomain(), window.document.domain);
- });
- });
-
- describe('.getAbsHref()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.getAbsHref);
- });
-
- it('returns null before .setLocation()', function () {
-
- var instance = this.applyFn();
- assert.isNull(instance.getAbsHref());
- });
- });
-
- describe('.getItem()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.getItem);
- });
- });
-
- describe('.setLocation()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.setLocation);
- });
- });
-
- describe('.refresh()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.refresh);
- });
- });
-
- describe('.setLink()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.setLink);
- });
-
- it('sets href correct', function () {
-
- var $el = $('
');
- var item = {
- absHref: uniq.id(),
- isManaged: false,
- isFolder: sinon.stub().returns(false)
- };
-
- var setLink = this.applyFn().setLink;
- setLink($el, item);
-
- assert.strictEqual($el.attr('href'), item.absHref);
- });
-
- it('sets target=\'_blank\' for unmanaged folders', function () {
-
- this.xSettings.view.unmanagedInNewWindow = true;
-
- var $el = $('
');
- var item = {
- absHref: uniq.id(),
- isManaged: false,
- isFolder: sinon.stub().returns(true)
- };
-
- var setLink = this.applyFn().setLink;
- setLink($el, item);
-
- assert.strictEqual($el.attr('target'), '_blank');
- });
-
- it('does not set target=\'_blank\' for managed folders', function () {
-
- this.xSettings.view.unmanagedInNewWindow = true;
-
- var $el = $('
');
- var item = {
- absHref: uniq.id(),
- isManaged: true,
- isFolder: sinon.stub().returns(true)
- };
-
- var setLink = this.applyFn().setLink;
- setLink($el, item);
-
- assert.isUndefined($el.attr('target'));
- });
-
- it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
-
- this.xSettings.view.unmanagedInNewWindow = false;
-
- var $el = $('
');
- var item = {
- absHref: uniq.id(),
- isManaged: true,
- isFolder: sinon.stub().returns(true)
- };
-
- var setLink = this.applyFn().setLink;
- setLink($el, item);
-
- assert.isUndefined($el.attr('target'));
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/modernizr.js b/test/tests/unit/core/modernizr.js
index b9f3f38b..5556a51e 100644
--- a/test/tests/unit/core/modernizr.js
+++ b/test/tests/unit/core/modernizr.js
@@ -1,90 +1,69 @@
(function () {
-'use strict';
+ var ID = 'core/modernizr';
+ var DEPS = [];
-var ID = 'core/modernizr';
-var DEPS = [];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.applyFn = function () {
-
- return this.definition.fn();
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ return this.definition.fn();
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ describe('application', function () {
+ it('returns plain object with 3 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOf(_.keys(instance), 3);
+ });
});
- it('args for each request', function () {
-
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ describe('.canvas', function () {
+ it('is boolean', function () {
+ var instance = this.applyFn();
+ assert.isBoolean(instance.canvas);
+ });
});
- it('has no instance', function () {
-
- assert.notProperty(modulejs._private.instances, ID);
+ describe('.history', function () {
+ it('is boolean', function () {
+ var instance = this.applyFn();
+ assert.isBoolean(instance.history);
+ });
});
- it('inits without errors', function () {
-
- this.applyFn();
+ describe('.localstorage', function () {
+ it('is boolean', function () {
+ var instance = this.applyFn();
+ assert.isBoolean(instance.localstorage);
+ });
});
});
-
- describe('application', function () {
-
- it('returns plain object with 3 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOf(_.keys(instance), 3);
- });
- });
-
- describe('.canvas', function () {
-
- it('is boolean', function () {
-
- var instance = this.applyFn();
- assert.isBoolean(instance.canvas);
- });
- });
-
- describe('.history', function () {
-
- it('is boolean', function () {
-
- var instance = this.applyFn();
- assert.isBoolean(instance.history);
- });
- });
-
- describe('.localstorage', function () {
-
- it('is boolean', function () {
-
- var instance = this.applyFn();
- assert.isBoolean(instance.localstorage);
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/resource.js b/test/tests/unit/core/resource.js
index c175a559..4504870e 100644
--- a/test/tests/unit/core/resource.js
+++ b/test/tests/unit/core/resource.js
@@ -1,113 +1,92 @@
(function () {
-'use strict';
+ var ID = 'core/resource';
+ var DEPS = ['_', 'config', 'core/settings'];
-var ID = 'core/resource';
-var DEPS = ['_', 'config', 'core/settings'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xConfig = {
- theme: {
- a: 'myTheme/a.svg',
- b: 'myTheme/b.jpg'
- }
- };
- this.xSettings = {publicHref: uniq.path('/publicHref/')};
- this.applyFn = function () {
-
- return this.definition.fn(_, this.xConfig, this.xSettings);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xConfig = {
+ theme: {
+ a: 'myTheme/a.svg',
+ b: 'myTheme/b.jpg'
+ }
+ };
+ this.xSettings = {publicHref: uniq.path('/publicHref/')};
+ this.applyFn = function () {
+ return this.definition.fn(_, this.xConfig, this.xSettings);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ describe('application', function () {
+ it('returns plain object with 2 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 2);
+ });
});
- it('args for each request', function () {
+ describe('.image()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.image);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ it('works', function () {
+ var instance = this.applyFn();
+ var ui = this.xSettings.publicHref + 'images/ui/';
+
+ assert.strictEqual(instance.image(), ui + 'undefined.svg');
+ assert.strictEqual(instance.image(1), ui + '1.svg');
+ assert.strictEqual(instance.image(''), ui + '.svg');
+ assert.strictEqual(instance.image('a'), ui + 'a.svg');
+ });
});
- it('has no instance', function () {
+ describe('.icon()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.icon);
+ });
- assert.notProperty(modulejs._private.instances, ID);
- });
+ it('works', function () {
+ var instance = this.applyFn();
+ var themes = this.xSettings.publicHref + 'images/themes/';
- it('inits without errors', function () {
-
- this.applyFn();
+ assert.strictEqual(instance.icon(''), themes + 'default/file.svg');
+ assert.strictEqual(instance.icon('a'), themes + 'myTheme/a.svg');
+ assert.strictEqual(instance.icon('a-sub'), themes + 'myTheme/a.svg');
+ assert.strictEqual(instance.icon('b'), themes + 'myTheme/b.jpg');
+ assert.strictEqual(instance.icon('x'), themes + 'default/x.svg');
+ assert.strictEqual(instance.icon('y'), themes + 'default/file.svg');
+ assert.strictEqual(instance.icon('y-sub'), themes + 'default/file.svg');
+ });
});
});
-
- describe('application', function () {
-
- it('returns plain object with 2 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 2);
- });
- });
-
- describe('.image()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.image);
- });
-
- it('works', function () {
-
- var instance = this.applyFn();
- var ui = this.xSettings.publicHref + 'images/ui/';
-
- assert.strictEqual(instance.image(), ui + 'undefined.svg');
- assert.strictEqual(instance.image(1), ui + '1.svg');
- assert.strictEqual(instance.image(''), ui + '.svg');
- assert.strictEqual(instance.image('a'), ui + 'a.svg');
- });
- });
-
- describe('.icon()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.icon);
- });
-
- it('works', function () {
-
- var instance = this.applyFn();
- var themes = this.xSettings.publicHref + 'images/themes/';
-
- assert.strictEqual(instance.icon(''), themes + 'default/file.svg');
- assert.strictEqual(instance.icon('a'), themes + 'myTheme/a.svg');
- assert.strictEqual(instance.icon('a-sub'), themes + 'myTheme/a.svg');
- assert.strictEqual(instance.icon('b'), themes + 'myTheme/b.jpg');
- assert.strictEqual(instance.icon('x'), themes + 'default/x.svg');
- assert.strictEqual(instance.icon('y'), themes + 'default/file.svg');
- assert.strictEqual(instance.icon('y-sub'), themes + 'default/file.svg');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/server.js b/test/tests/unit/core/server.js
index badb0076..4cb9d19d 100644
--- a/test/tests/unit/core/server.js
+++ b/test/tests/unit/core/server.js
@@ -1,193 +1,169 @@
(function () {
-'use strict';
+ var ID = 'core/server';
+ var DEPS = ['_', '$'];
+ var $submitEl;
-var ID = 'core/server';
-var DEPS = ['_', '$'];
-var $submitEl;
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xAjaxResult = {
- done: sinon.stub().returnsThis(),
- fail: sinon.stub().returnsThis(),
- always: sinon.stub().returnsThis()
- };
- this.xAjax = sinon.stub($, 'ajax').returns(this.xAjaxResult);
- this.xSubmit = sinon.stub($.fn, 'submit', function () {
-
- $submitEl = this;
- return this;
- });
-
- this.applyFn = function () {
-
- this.xAjaxResult.done.reset();
- this.xAjaxResult.fail.reset();
- this.xAjaxResult.always.reset();
- this.xAjax.reset();
- this.xSubmit.reset();
- $submitEl = undefined;
-
- return this.definition.fn(_, $);
- };
- });
-
- after(function () {
-
- this.xAjax.restore();
- this.xSubmit.restore();
- });
-
- 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 2 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 2);
- });
- });
-
- describe('.request()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.request);
- });
-
- it('done() works', function () {
-
- var instance = this.applyFn();
-
- var xData = uniq.obj();
- var xResult = uniq.obj();
- var spy = sinon.spy();
- var res = instance.request(xData, spy);
-
- assert.isUndefined(res);
- assert.isTrue(this.xAjax.calledOnce);
- assert.deepEqual(this.xAjax.lastCall.args, [{
- url: '?',
- data: xData,
- type: 'post',
- dataType: 'json'
- }]);
- assert.isTrue(this.xAjaxResult.done.calledOnce);
- assert.isTrue(this.xAjaxResult.fail.calledOnce);
- assert.isFalse(spy.called);
-
- this.xAjaxResult.done.callArgWith(0, xResult);
-
- assert.isTrue(spy.calledOnce);
- assert.deepEqual(spy.firstCall.args, [xResult]);
- });
-
- it('fail() works', function () {
-
- var instance = this.applyFn();
-
- var xData = uniq.obj();
- var spy = sinon.spy();
- var res = instance.request(xData, spy);
-
- assert.isUndefined(res);
- assert.isTrue(this.xAjax.calledOnce);
- assert.deepEqual(this.xAjax.lastCall.args, [{
- url: '?',
- data: xData,
- type: 'post',
- dataType: 'json'
- }]);
- assert.isTrue(this.xAjaxResult.done.calledOnce);
- assert.isTrue(this.xAjaxResult.fail.calledOnce);
- assert.isFalse(spy.called);
-
- this.xAjaxResult.fail.callArg(0);
-
- assert.isTrue(spy.calledOnce);
- assert.deepEqual(spy.firstCall.args, []);
- });
- });
-
- describe('.formRequest()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.formRequest);
- });
-
- it('works', function () {
-
- var instance = this.applyFn();
-
- var xData = {
- a: uniq.id(),
- b: uniq.id()
+ this.xAjaxResult = {
+ done: sinon.stub().returnsThis(),
+ fail: sinon.stub().returnsThis(),
+ always: sinon.stub().returnsThis()
};
- var res = instance.formRequest(xData);
+ this.xAjax = sinon.stub($, 'ajax').returns(this.xAjaxResult);
+ this.xSubmit = sinon.stub($.fn, 'submit', function () {
+ $submitEl = this;
+ return this;
+ });
- assert.isUndefined(res);
+ this.applyFn = function () {
+ this.xAjaxResult.done.reset();
+ this.xAjaxResult.fail.reset();
+ this.xAjaxResult.always.reset();
+ this.xAjax.reset();
+ this.xSubmit.reset();
+ $submitEl = undefined;
- assert.isTrue(this.xSubmit.calledOnce);
+ return this.definition.fn(_, $);
+ };
+ });
- assert.lengthOf($submitEl, 1);
- assert.strictEqual($submitEl.get(0).tagName.toLowerCase(), 'form');
- assert.strictEqual($submitEl.attr('method'), 'post');
- assert.strictEqual($submitEl.attr('style').replace(/\s+/g, ''), 'display:none;');
- assert.strictEqual($submitEl.attr('action'), '?');
+ after(function () {
+ this.xAjax.restore();
+ this.xSubmit.restore();
+ });
- var $children = $submitEl.children();
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.lengthOf($children, 2);
+ it('has correct id', function () {
+ assert.strictEqual(this.definition.id, ID);
+ });
- assert.strictEqual($children.eq(0).attr('type'), 'hidden');
- assert.strictEqual($children.eq(0).attr('name'), 'a');
- assert.strictEqual($children.eq(0).attr('value'), xData.a);
+ it('requires correct', function () {
+ assert.deepEqual(this.definition.deps, DEPS);
+ });
- assert.strictEqual($children.eq(1).attr('type'), 'hidden');
- assert.strictEqual($children.eq(1).attr('name'), 'b');
- assert.strictEqual($children.eq(1).attr('value'), xData.b);
+ 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 2 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 2);
+ });
+ });
+
+ describe('.request()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.request);
+ });
+
+ it('done() works', function () {
+ var instance = this.applyFn();
+
+ var xData = uniq.obj();
+ var xResult = uniq.obj();
+ var spy = sinon.spy();
+ var res = instance.request(xData, spy);
+
+ assert.isUndefined(res);
+ assert.isTrue(this.xAjax.calledOnce);
+ assert.deepEqual(this.xAjax.lastCall.args, [{
+ url: '?',
+ data: xData,
+ type: 'post',
+ dataType: 'json'
+ }]);
+ assert.isTrue(this.xAjaxResult.done.calledOnce);
+ assert.isTrue(this.xAjaxResult.fail.calledOnce);
+ assert.isFalse(spy.called);
+
+ this.xAjaxResult.done.callArgWith(0, xResult);
+
+ assert.isTrue(spy.calledOnce);
+ assert.deepEqual(spy.firstCall.args, [xResult]);
+ });
+
+ it('fail() works', function () {
+ var instance = this.applyFn();
+
+ var xData = uniq.obj();
+ var spy = sinon.spy();
+ var res = instance.request(xData, spy);
+
+ assert.isUndefined(res);
+ assert.isTrue(this.xAjax.calledOnce);
+ assert.deepEqual(this.xAjax.lastCall.args, [{
+ url: '?',
+ data: xData,
+ type: 'post',
+ dataType: 'json'
+ }]);
+ assert.isTrue(this.xAjaxResult.done.calledOnce);
+ assert.isTrue(this.xAjaxResult.fail.calledOnce);
+ assert.isFalse(spy.called);
+
+ this.xAjaxResult.fail.callArg(0);
+
+ assert.isTrue(spy.calledOnce);
+ assert.deepEqual(spy.firstCall.args, []);
+ });
+ });
+
+ describe('.formRequest()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.formRequest);
+ });
+
+ it('works', function () {
+ var instance = this.applyFn();
+
+ var xData = {
+ a: uniq.id(),
+ b: uniq.id()
+ };
+ var res = instance.formRequest(xData);
+
+ assert.isUndefined(res);
+
+ assert.isTrue(this.xSubmit.calledOnce);
+
+ assert.lengthOf($submitEl, 1);
+ assert.strictEqual($submitEl.get(0).tagName.toLowerCase(), 'form');
+ assert.strictEqual($submitEl.attr('method'), 'post');
+ assert.strictEqual($submitEl.attr('style').replace(/\s+/g, ''), 'display:none;');
+ assert.strictEqual($submitEl.attr('action'), '?');
+
+ var $children = $submitEl.children();
+
+ assert.lengthOf($children, 2);
+
+ assert.strictEqual($children.eq(0).attr('type'), 'hidden');
+ assert.strictEqual($children.eq(0).attr('name'), 'a');
+ assert.strictEqual($children.eq(0).attr('value'), xData.a);
+
+ assert.strictEqual($children.eq(1).attr('type'), 'hidden');
+ assert.strictEqual($children.eq(1).attr('name'), 'b');
+ assert.strictEqual($children.eq(1).attr('value'), xData.b);
+ });
});
});
-});
-
}());
diff --git a/test/tests/unit/core/settings.js b/test/tests/unit/core/settings.js
index bf5ca696..a48792a7 100644
--- a/test/tests/unit/core/settings.js
+++ b/test/tests/unit/core/settings.js
@@ -1,104 +1,83 @@
(function () {
-'use strict';
+ var ID = 'core/settings';
+ var DEPS = ['_', 'config'];
-var ID = 'core/settings';
-var DEPS = ['_', 'config'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xConfig = {
- options: {
- someOptions: uniq.obj(),
- otherOptions: uniq.obj(),
- more: uniq.obj()
- },
- setup: {
- PUBLIC_HREF: uniq.id(),
- ROOT_HREF: uniq.id()
- }
- };
- this.applyFn = function () {
-
- return this.definition.fn(_, this.xConfig);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xConfig = {
+ options: {
+ someOptions: uniq.obj(),
+ otherOptions: uniq.obj(),
+ more: uniq.obj()
+ },
+ setup: {
+ PUBLIC_HREF: uniq.id(),
+ ROOT_HREF: uniq.id()
+ }
+ };
+ this.applyFn = function () {
+ return this.definition.fn(_, this.xConfig);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ describe('application', function () {
+ it('returns plain object with properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.isAbove(_.keys(instance).length, 0);
+ });
});
- it('args for each request', function () {
-
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ describe('publics', function () {
+ it('extended from options', function () {
+ 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);
+ assert.strictEqual(_.keys(instance).length, _.keys(this.xConfig.options).length + 2);
+ });
});
- it('has no instance', function () {
-
- assert.notProperty(modulejs._private.instances, ID);
+ describe('.publicHref', function () {
+ it('set correct', function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.publicHref, this.xConfig.setup.PUBLIC_HREF);
+ });
});
- it('inits without errors', function () {
-
- this.applyFn();
+ describe('.rootHref', function () {
+ it('set correct', function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.rootHref, this.xConfig.setup.ROOT_HREF);
+ });
});
});
-
- 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 () {
-
- it('extended from options', function () {
-
- 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);
- assert.strictEqual(_.keys(instance).length, _.keys(this.xConfig.options).length + 2);
- });
- });
-
- describe('.publicHref', function () {
-
- it('set correct', function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.publicHref, this.xConfig.setup.PUBLIC_HREF);
- });
- });
-
- describe('.rootHref', function () {
-
- it('set correct', function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.rootHref, this.xConfig.setup.ROOT_HREF);
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/store.js b/test/tests/unit/core/store.js
index 6de17ebf..b078cfd3 100644
--- a/test/tests/unit/core/store.js
+++ b/test/tests/unit/core/store.js
@@ -1,131 +1,108 @@
(function () {
-'use strict';
+ var ID = 'core/store';
+ var DEPS = ['core/modernizr'];
-var ID = 'core/store';
-var DEPS = ['core/modernizr'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.storeKey = '_h5ai';
- this.xModernizr = {localstorage: true};
- this.applyFn = function () {
-
- return this.definition.fn(this.xModernizr);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.storeKey = '_h5ai';
+ this.xModernizr = {localstorage: true};
+ this.applyFn = function () {
+ return this.definition.fn(this.xModernizr);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
-
- assert.notProperty(modulejs._private.instances, ID);
+ describe('application', function () {
+ it('returns plain object with 2 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 2);
+ });
});
- it('inits without errors', function () {
+ describe('.put()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.put);
+ });
+ });
- this.applyFn();
+ describe('.get()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.get);
+ });
+ });
+
+ describe('works', function () {
+ it('works', function () {
+ var key1 = 'test1';
+ var value1 = '1234';
+ var key2 = 'test2';
+ var value2 = '5678';
+ var instance = this.applyFn();
+
+ assert.isNull(window.localStorage.getItem(this.storeKey));
+
+ assert.isUndefined(instance.get(key1));
+ assert.isNull(window.localStorage.getItem(this.storeKey));
+
+ assert.isUndefined(instance.put(key1, value1));
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234"}');
+
+ assert.strictEqual(instance.get(key1), value1);
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234"}');
+
+ assert.isUndefined(instance.put(key1, undefined));
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{}');
+
+ assert.isUndefined(instance.get(key1));
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{}');
+
+ assert.isUndefined(instance.put(key1, value1));
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234"}');
+
+ assert.isUndefined(instance.put(key2, value2));
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234","test2":"5678"}');
+
+ assert.isUndefined(instance.put(key1, undefined));
+ assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test2":"5678"}');
+ });
});
});
-
- describe('application', function () {
-
- it('returns plain object with 2 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 2);
- });
- });
-
- describe('.put()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.put);
- });
- });
-
- describe('.get()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.get);
- });
- });
-
- describe('works', function () {
-
- it('works', function () {
-
- var key1 = 'test1';
- var value1 = '1234';
- var key2 = 'test2';
- var value2 = '5678';
- var instance = this.applyFn();
-
- assert.isNull(window.localStorage.getItem(this.storeKey));
-
- assert.isUndefined(instance.get(key1));
- assert.isNull(window.localStorage.getItem(this.storeKey));
-
- assert.isUndefined(instance.put(key1, value1));
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234"}');
-
- assert.strictEqual(instance.get(key1), value1);
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234"}');
-
- assert.isUndefined(instance.put(key1, undefined));
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{}');
-
- assert.isUndefined(instance.get(key1));
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{}');
-
- assert.isUndefined(instance.put(key1, value1));
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234"}');
-
- assert.isUndefined(instance.put(key2, value2));
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test1":"1234","test2":"5678"}');
-
- assert.isUndefined(instance.put(key1, undefined));
- assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test2":"5678"}');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/core/types.js b/test/tests/unit/core/types.js
index c58e0e62..97834daa 100644
--- a/test/tests/unit/core/types.js
+++ b/test/tests/unit/core/types.js
@@ -1,103 +1,84 @@
(function () {
-'use strict';
+ var ID = 'core/types';
+ var DEPS = ['_', 'config'];
-var ID = 'core/types';
-var DEPS = ['_', 'config'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xConfig = {types: {
- a: ['*.a', '*.aa'],
- b: ['*.b'],
- c: ['*.c']
- }};
- this.applyFn = function () {
-
- return this.definition.fn(_, this.xConfig);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xConfig = {types: {
+ a: ['*.a', '*.aa'],
+ b: ['*.b'],
+ c: ['*.c']
+ }};
+ this.applyFn = function () {
+ return this.definition.fn(_, this.xConfig);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- 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 1 property', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 1);
- });
- });
-
- describe('.getType()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.getType);
- });
-
- _.each([
- ['file.a', 'a'],
- ['file.aa', 'a'],
- ['foo.b', 'b'],
- ['some/path/file.c', 'c'],
- ['/some/abs/path/file.c', 'c'],
- ['file.x', 'file'],
- ['foo', 'file'],
- ['some/path/foo', 'file'],
- ['/some/path/foo', 'file'],
- ['foo/', 'folder'],
- ['/', 'folder'],
- ['some/path/foo/', 'folder'],
- ['/some/path/foo/', 'folder']
- ], function (data) {
-
- var arg = data[0];
- var exp = data[1];
-
- it(arg + ' => ' + exp, function () {
-
+ describe('application', function () {
+ it('returns plain object with 1 property', function () {
var instance = this.applyFn();
- assert.strictEqual(instance.getType(arg), exp);
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 1);
+ });
+ });
+
+ describe('.getType()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.getType);
+ });
+
+ _.each([
+ ['file.a', 'a'],
+ ['file.aa', 'a'],
+ ['foo.b', 'b'],
+ ['some/path/file.c', 'c'],
+ ['/some/abs/path/file.c', 'c'],
+ ['file.x', 'file'],
+ ['foo', 'file'],
+ ['some/path/foo', 'file'],
+ ['/some/path/foo', 'file'],
+ ['foo/', 'folder'],
+ ['/', 'folder'],
+ ['some/path/foo/', 'folder'],
+ ['/some/path/foo/', 'folder']
+ ], function (data) {
+ var arg = data[0];
+ var exp = data[1];
+
+ it(arg + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.getType(arg), exp);
+ });
});
});
});
-});
-
}());
diff --git a/test/tests/unit/core/util.js b/test/tests/unit/core/util.js
index 85d091f8..bb5252d5 100644
--- a/test/tests/unit/core/util.js
+++ b/test/tests/unit/core/util.js
@@ -1,232 +1,201 @@
(function () {
-'use strict';
+ var ID = 'core/util';
+ var DEPS = ['_'];
-var ID = 'core/util';
-var DEPS = ['_'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.applyFn = function () {
-
- return this.definition.fn(_);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ return this.definition.fn(_);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- 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 4 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 4);
- });
- });
-
- describe('.regularCmpFn()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.regularCmpFn);
- });
-
- _.each([
- [0, 0, 0],
- [1, 0, 1],
- [1, 2, -1],
- ['a', 'a', 0],
- ['b', 'a', 1],
- ['a', 'b', -1],
- ['a 2', 'a 10', 1]
- ], function (data) {
-
- var arg1 = data[0];
- var arg2 = data[1];
- var exp = data[2];
-
- it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
-
+ describe('application', function () {
+ it('returns plain object with 4 properties', function () {
var instance = this.applyFn();
- assert.strictEqual(instance.regularCmpFn(arg1, arg2), exp);
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 4);
+ });
+ });
+
+ describe('.regularCmpFn()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.regularCmpFn);
+ });
+
+ _.each([
+ [0, 0, 0],
+ [1, 0, 1],
+ [1, 2, -1],
+ ['a', 'a', 0],
+ ['b', 'a', 1],
+ ['a', 'b', -1],
+ ['a 2', 'a 10', 1]
+ ], function (data) {
+ var arg1 = data[0];
+ var arg2 = data[1];
+ var exp = data[2];
+
+ it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.regularCmpFn(arg1, arg2), exp);
+ });
+ });
+ });
+
+ describe('.naturalCmpFn()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.naturalCmpFn);
+ });
+
+ _.each([
+ [0, 0, 0],
+ [1, 0, 1],
+ [1, 2, -1],
+ ['a', 'a', 0],
+ ['b', 'a', 1],
+ ['a', 'b', -1],
+ ['a 2', 'a 10', -1]
+ ], function (data) {
+ var arg1 = data[0];
+ var arg2 = data[1];
+ var exp = data[2];
+
+ it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.naturalCmpFn(arg1, arg2), exp);
+ });
+ });
+ });
+
+ describe('.escapePattern()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.escapePattern);
+ });
+
+ _.each([
+ ['a', 'a'],
+ ['1', '1'],
+ ['ä', 'ä'],
+ ['~', '~'],
+ [':', ':'],
+ ['_', '_'],
+ ['<', '<'],
+ ['-', '\\-'],
+ ['[', '\\['],
+ [']', '\\]'],
+ ['{', '\\{'],
+ ['}', '\\}'],
+ ['(', '\\('],
+ [')', '\\)'],
+ ['*', '\\*'],
+ ['+', '\\+'],
+ ['?', '\\?'],
+ ['.', '\\.'],
+ [',', '\\,'],
+ ['\\', '\\\\'],
+ ['$', '\\$'],
+ ['^', '\\^'],
+ ['|', '\\|'],
+ ['#', '\\#'],
+ [' ', '\\ '],
+ ['-[]{}()*+?.,\\$^|# ', '\\-\\[\\]\\{\\}\\(\\)\\*\\+\\?\\.\\,\\\\\\$\\^\\|\\#\\ '],
+ ['abc123', 'abc123'],
+ ['a.b+c*1', 'a\\.b\\+c\\*1']
+ ], function (data) {
+ var arg = data[0];
+ var exp = data[1];
+
+ it(arg + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.escapePattern(arg), exp);
+ });
+ });
+ });
+
+ describe('.parsePattern()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isFunction(instance.parsePattern);
+ });
+
+ _.each([
+ ['a', false, 'a'],
+ ['1', false, '1'],
+ ['ä', false, 'ä'],
+ ['~', false, '~'],
+ [':', false, ':'],
+ ['_', false, '_'],
+ ['<', false, '<'],
+ ['-', false, '\\-'],
+ ['[', false, '\\['],
+ [']', false, '\\]'],
+ ['{', false, '\\{'],
+ ['}', false, '\\}'],
+ ['(', false, '\\('],
+ [')', false, '\\)'],
+ ['*', false, '\\*'],
+ ['+', false, '\\+'],
+ ['?', false, '\\?'],
+ ['.', false, '\\.'],
+ [',', false, '\\,'],
+ ['\\', false, '\\\\'],
+ ['$', false, '\\$'],
+ ['^', false, '\\^'],
+ ['|', false, '\\|'],
+ ['#', false, '\\#'],
+ [' ', false, '\\ '],
+ ['-[]{}()*+?.,\\$^|# ', false, '\\-\\[\\]\\{\\}\\(\\)\\*\\+\\?\\.\\,\\\\\\$\\^\\|\\#\\ '],
+ ['abc123', false, 'abc123'],
+ ['a.b+c*1', false, 'a\\.b\\+c\\*1'],
+
+ ['abc', true, 'a.*?b.*?c'],
+ ['abc def', true, 'a.*?b.*?c|d.*?e.*?f'],
+ ['*#a b.=', true, '\\*.*?\\#.*?a|b.*?\\..*?='],
+ ['re:.', true, '.'],
+ [' .', true, '\\.'],
+ ['re: .', true, ' .']
+
+ ], function (data) {
+ var arg1 = data[0];
+ var arg2 = data[1];
+ var exp = data[2];
+
+ it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
+ var instance = this.applyFn();
+ assert.strictEqual(instance.parsePattern(arg1, arg2), exp);
+ });
});
});
});
-
- describe('.naturalCmpFn()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.naturalCmpFn);
- });
-
- _.each([
- [0, 0, 0],
- [1, 0, 1],
- [1, 2, -1],
- ['a', 'a', 0],
- ['b', 'a', 1],
- ['a', 'b', -1],
- ['a 2', 'a 10', -1]
- ], function (data) {
-
- var arg1 = data[0];
- var arg2 = data[1];
- var exp = data[2];
-
- it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.naturalCmpFn(arg1, arg2), exp);
- });
- });
- });
-
- describe('.escapePattern()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.escapePattern);
- });
-
- _.each([
- ['a', 'a'],
- ['1', '1'],
- ['ä', 'ä'],
- ['~', '~'],
- [':', ':'],
- ['_', '_'],
- ['<', '<'],
- ['-', '\\-'],
- ['[', '\\['],
- [']', '\\]'],
- ['{', '\\{'],
- ['}', '\\}'],
- ['(', '\\('],
- [')', '\\)'],
- ['*', '\\*'],
- ['+', '\\+'],
- ['?', '\\?'],
- ['.', '\\.'],
- [',', '\\,'],
- ['\\', '\\\\'],
- ['$', '\\$'],
- ['^', '\\^'],
- ['|', '\\|'],
- ['#', '\\#'],
- [' ', '\\ '],
- ['-[]{}()*+?.,\\$^|# ', '\\-\\[\\]\\{\\}\\(\\)\\*\\+\\?\\.\\,\\\\\\$\\^\\|\\#\\ '],
- ['abc123', 'abc123'],
- ['a.b+c*1', 'a\\.b\\+c\\*1']
- ], function (data) {
-
- var arg = data[0];
- var exp = data[1];
-
- it(arg + ' => ' + exp, function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.escapePattern(arg), exp);
- });
- });
- });
-
- describe('.parsePattern()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.parsePattern);
- });
-
- _.each([
- ['a', false, 'a'],
- ['1', false, '1'],
- ['ä', false, 'ä'],
- ['~', false, '~'],
- [':', false, ':'],
- ['_', false, '_'],
- ['<', false, '<'],
- ['-', false, '\\-'],
- ['[', false, '\\['],
- [']', false, '\\]'],
- ['{', false, '\\{'],
- ['}', false, '\\}'],
- ['(', false, '\\('],
- [')', false, '\\)'],
- ['*', false, '\\*'],
- ['+', false, '\\+'],
- ['?', false, '\\?'],
- ['.', false, '\\.'],
- [',', false, '\\,'],
- ['\\', false, '\\\\'],
- ['$', false, '\\$'],
- ['^', false, '\\^'],
- ['|', false, '\\|'],
- ['#', false, '\\#'],
- [' ', false, '\\ '],
- ['-[]{}()*+?.,\\$^|# ', false, '\\-\\[\\]\\{\\}\\(\\)\\*\\+\\?\\.\\,\\\\\\$\\^\\|\\#\\ '],
- ['abc123', false, 'abc123'],
- ['a.b+c*1', false, 'a\\.b\\+c\\*1'],
-
- ['abc', true, 'a.*?b.*?c'],
- ['abc def', true, 'a.*?b.*?c|d.*?e.*?f'],
- ['*#a b.=', true, '\\*.*?\\#.*?a|b.*?\\..*?='],
- ['re:.', true, '.'],
- [' .', true, '\\.'],
- ['re: .', true, ' .']
-
- ], function (data) {
-
- var arg1 = data[0];
- var arg2 = data[1];
- var exp = data[2];
-
- it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
-
- var instance = this.applyFn();
- assert.strictEqual(instance.parsePattern(arg1, arg2), exp);
- });
- });
- });
-});
-
}());
diff --git a/test/tests/unit/ext/title.js b/test/tests/unit/ext/title.js
index a4139028..24ed3ea2 100644
--- a/test/tests/unit/ext/title.js
+++ b/test/tests/unit/ext/title.js
@@ -1,125 +1,104 @@
(function () {
-'use strict';
+ var ID = 'ext/title';
+ var DEPS = ['_', 'core/event', 'core/settings'];
-var ID = 'ext/title';
-var DEPS = ['_', 'core/event', 'core/settings'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xEvent = {
+ sub: sinon.stub()
+ };
+ this.xSettings = {title: {
+ enabled: true
+ }};
- before(function () {
+ this.applyFn = function () {
+ this.xEvent.sub.reset();
- this.definition = modulejs._private.definitions[ID];
-
- this.xEvent = {
- sub: sinon.stub()
- };
- this.xSettings = {title: {
- enabled: true
- }};
-
- this.applyFn = function () {
-
- this.xEvent.sub.reset();
-
- return this.definition.fn(_, this.xEvent, this.xSettings);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ return this.definition.fn(_, this.xEvent, this.xSettings);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.deepEqual(this.definition.deps, DEPS);
+ 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();
+ });
});
- 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 undefined', function () {
-
- var instance = this.applyFn();
- assert.isUndefined(instance);
- });
-
- it('subscribes to location.changed', function () {
-
- this.xSettings.title.enabled = true;
-
- this.applyFn();
- assert.isTrue(this.xEvent.sub.calledOnce);
- assert.strictEqual(this.xEvent.sub.lastCall.args[0], 'location.changed');
- });
-
- it('does not subscribe to events if disabled', function () {
-
- this.xSettings.title.enabled = false;
-
- this.applyFn();
- assert.isFalse(this.xEvent.sub.called);
- });
- });
-
- describe('sets title on location.changed', function () {
-
- _.each([
- [''],
- ['a', 'a'],
- ['a', 'b', 'b - a > b'],
- ['a', 'b', 'c', 'c - a > b > c']
- ], function (data) {
-
- var labels = data.slice(0, -1);
- var exp = data.slice(-1)[0];
-
- it(labels + ' => ' + exp, function () {
+ describe('application', function () {
+ it('returns undefined', function () {
+ var instance = this.applyFn();
+ assert.isUndefined(instance);
+ });
+ it('subscribes to location.changed', function () {
this.xSettings.title.enabled = true;
this.applyFn();
+ assert.isTrue(this.xEvent.sub.calledOnce);
+ assert.strictEqual(this.xEvent.sub.lastCall.args[0], 'location.changed');
+ });
- var fn = this.xEvent.sub.lastCall.args[1];
- var crumb = _.map(labels, function (x) { return {label: x}; });
- var item = {
- getCrumb: sinon.stub().returns(crumb)
- };
+ it('does not subscribe to events if disabled', function () {
+ this.xSettings.title.enabled = false;
- fn(item);
+ this.applyFn();
+ assert.isFalse(this.xEvent.sub.called);
+ });
+ });
- assert.isTrue(item.getCrumb.calledOnce);
- assert.strictEqual(document.title, exp);
+ describe('sets title on location.changed', function () {
+ _.each([
+ [''],
+ ['a', 'a'],
+ ['a', 'b', 'b - a > b'],
+ ['a', 'b', 'c', 'c - a > b > c']
+ ], function (data) {
+ var labels = data.slice(0, -1);
+ var exp = data.slice(-1)[0];
+
+ it(labels + ' => ' + exp, function () {
+ this.xSettings.title.enabled = true;
+
+ this.applyFn();
+
+ var fn = this.xEvent.sub.lastCall.args[1];
+ var crumb = _.map(labels, function (x) { return {label: x}; });
+ var item = {
+ getCrumb: sinon.stub().returns(crumb)
+ };
+
+ fn(item);
+
+ assert.isTrue(item.getCrumb.calledOnce);
+ assert.strictEqual(document.title, exp);
+ });
});
});
});
-});
-
}());
diff --git a/test/tests/unit/libs.js b/test/tests/unit/libs.js
index 19a74a33..09600806 100644
--- a/test/tests/unit/libs.js
+++ b/test/tests/unit/libs.js
@@ -1,39 +1,29 @@
(function () {
-'use strict';
-
-describe('libs', function () {
-
- var libs = {
+ describe('libs', function () {
+ var libs = {
_: window._,
$: window.jQuery,
marked: window.marked,
prism: window.Prism
};
- _.each(libs, function (lib, id) {
+ _.each(libs, function (lib, id) {
+ describe('module \'' + id + '\'', function () {
+ it('is defined', function () {
+ assert.isDefined(modulejs._private.definitions[id]);
+ });
- describe('module \'' + id + '\'', function () {
+ it('has no instance', function () {
+ assert.notProperty(modulejs._private.instances, id);
+ });
- it('is defined', function () {
-
- assert.isDefined(modulejs._private.definitions[id]);
- });
-
- it('has no instance', function () {
-
- assert.notProperty(modulejs._private.instances, id);
- });
-
- it('returns global lib', function () {
-
- var definition = modulejs._private.definitions[id];
- var instance = definition.fn();
- assert.isDefined(instance);
- assert.strictEqual(instance, lib);
+ it('returns global lib', function () {
+ var definition = modulejs._private.definitions[id];
+ var instance = definition.fn();
+ assert.isDefined(instance);
+ assert.strictEqual(instance, lib);
+ });
});
});
-
});
-});
-
}());
diff --git a/test/tests/unit/main/index.js b/test/tests/unit/main/index.js
index e26ca33a..75e5d436 100644
--- a/test/tests/unit/main/index.js
+++ b/test/tests/unit/main/index.js
@@ -1,125 +1,102 @@
(function () {
-'use strict';
+ var ID = 'main/index';
+ var DEPS = ['_', 'core/location'];
-var ID = 'main/index';
-var DEPS = ['_', 'core/location'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xLocation = {setLocation: sinon.stub()};
+ this.xRequire = sinon.stub(modulejs, 'require');
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xLocation = {setLocation: sinon.stub()};
- this.xRequire = sinon.stub(modulejs, 'require');
-
- this.applyFn = function () {
-
- this.xLocation.setLocation.reset();
- this.xRequire.reset();
- return this.definition.fn(_, this.xLocation);
- };
- });
-
- after(function () {
-
- this.xRequire.restore();
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ this.xLocation.setLocation.reset();
+ this.xRequire.reset();
+ return this.definition.fn(_, this.xLocation);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ this.xRequire.restore();
});
- it('requires correct', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.deepEqual(this.definition.deps, DEPS);
- });
+ it('has correct id', function () {
+ assert.strictEqual(this.definition.id, ID);
+ });
- it('args for each request', function () {
+ it('requires correct', function () {
+ assert.deepEqual(this.definition.deps, DEPS);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
- });
+ it('args for each request', function () {
+ assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ });
- it('has no instance', function () {
+ it('has no instance', function () {
+ assert.notProperty(modulejs._private.instances, ID);
+ });
- assert.notProperty(modulejs._private.instances, ID);
- });
-
- it('inits without errors', function () {
-
- this.applyFn();
- });
- });
-
- describe('application', function () {
-
- it('returns undefined', function () {
-
- var instance = this.applyFn();
- assert.isUndefined(instance);
- });
-
- it('requires view/viewmode', function () {
-
- this.applyFn();
- assert.isTrue(this.xRequire.calledWithExactly('view/viewmode'));
- });
-
- it('requires all extensions', function () {
-
- this.applyFn();
- var re = /^ext\//;
- var self = this;
-
- _.each(modulejs.state(), function (state, id) {
-
- if (re.test(id)) {
- assert.isTrue(self.xRequire.calledWithExactly(id));
- }
+ it('inits without errors', function () {
+ this.applyFn();
});
});
- it('requires only views and extensions', function () {
+ describe('application', function () {
+ it('returns undefined', function () {
+ var instance = this.applyFn();
+ assert.isUndefined(instance);
+ });
- this.applyFn();
- assert.isTrue(this.xRequire.alwaysCalledWithMatch(/^(view|ext)\//));
- });
+ it('requires view/viewmode', function () {
+ this.applyFn();
+ assert.isTrue(this.xRequire.calledWithExactly('view/viewmode'));
+ });
- it('requires views before extensions', function () {
+ it('requires all extensions', function () {
+ this.applyFn();
+ var re = /^ext\//;
+ var self = this;
- this.applyFn();
- var foundExtension = false;
- var reView = /^view\//;
- var reExt = /^ext\//;
+ _.each(modulejs.state(), function (state, id) {
+ if (re.test(id)) {
+ assert.isTrue(self.xRequire.calledWithExactly(id));
+ }
+ });
+ });
- _.each(this.xRequire.args, function (args) {
+ it('requires only views and extensions', function () {
+ this.applyFn();
+ assert.isTrue(this.xRequire.alwaysCalledWithMatch(/^(view|ext)\//));
+ });
- if (foundExtension) {
- assert.match(args[0], reExt);
- } else if (reExt.test(args[0])) {
- foundExtension = true;
- } else {
- assert.match(args[0], reView);
- }
+ it('requires views before extensions', function () {
+ this.applyFn();
+ var foundExtension = false;
+ var reView = /^view\//;
+ var reExt = /^ext\//;
+
+ _.each(this.xRequire.args, function (args) {
+ if (foundExtension) {
+ assert.match(args[0], reExt);
+ } else if (reExt.test(args[0])) {
+ foundExtension = true;
+ } else {
+ assert.match(args[0], reView);
+ }
+ });
+ });
+
+ it('calls setLocation with current href, keeping browser url', function () {
+ this.applyFn();
+ assert.isTrue(this.xLocation.setLocation.calledOnce);
+ assert.deepEqual(this.xLocation.setLocation.firstCall.args, [document.location.href, true]);
+ assert.isTrue(this.xLocation.setLocation.calledAfter(this.xRequire));
});
});
-
- it('calls setLocation with current href, keeping browser url', function () {
-
- this.applyFn();
- assert.isTrue(this.xLocation.setLocation.calledOnce);
- assert.deepEqual(this.xLocation.setLocation.firstCall.args, [document.location.href, true]);
- assert.isTrue(this.xLocation.setLocation.calledAfter(this.xRequire));
- });
});
-});
-
}());
diff --git a/test/tests/unit/main/info.js b/test/tests/unit/main/info.js
index a2025779..33ad4d0e 100644
--- a/test/tests/unit/main/info.js
+++ b/test/tests/unit/main/info.js
@@ -1,213 +1,180 @@
(function () {
-'use strict';
+ var ID = 'main/info';
+ var DEPS = ['$', 'config', 'core/resource', 'core/server'];
-var ID = 'main/info';
-var DEPS = ['$', 'config', 'core/resource', 'core/server'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xConfig = {
+ setup: {
+ VERSION: uniq.id()
+ },
+ options: {}
+ };
+ this.xResource = {
+ image: sinon.stub()
+ };
+ this.xServer = {
+ request: sinon.stub()
+ };
- before(function () {
+ this.applyFn = function () {
+ this.xServer.request.reset();
- this.definition = modulejs._private.definitions[ID];
-
- this.xConfig = {
- setup: {
- VERSION: uniq.id()
- },
- options: {}
- };
- this.xResource = {
- image: sinon.stub()
- };
- this.xServer = {
- request: sinon.stub()
- };
-
- this.applyFn = function () {
-
- this.xServer.request.reset();
-
- return this.definition.fn($, this.xConfig, this.xResource, this.xServer);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ return this.definition.fn($, this.xConfig, this.xResource, this.xServer);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ $('
').appendTo('body');
});
- 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 undefined', function () {
-
- var instance = this.applyFn();
- assert.isUndefined(instance);
- });
-
- it('adds HTML #support to #content', function () {
-
- this.applyFn();
- assert.lengthOf($('#content > #support'), 1);
- assert.lengthOf($('#support > .paypal'), 1);
- assert.lengthOf($('.paypal > form'), 1);
- });
-
- it('adds HTML #login-wrapper to #content', function () {
-
- this.applyFn();
- assert.lengthOf($('#content > #login-wrapper'), 1);
- });
-
- describe('no admin', function () {
-
- it('adds HTML #pass to #login-wrapper', function () {
-
- this.xConfig.setup.AS_ADMIN = false;
- this.applyFn();
- assert.lengthOf($('#login-wrapper > #pass'), 1);
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
});
- it('sets #pass val to empty string', function () {
-
- this.xConfig.setup.AS_ADMIN = false;
- this.applyFn();
- assert.strictEqual($('#login-wrapper > #pass').val(), '');
+ it('has correct id', function () {
+ assert.strictEqual(this.definition.id, ID);
});
- it('adds HTML #login to #login-wrapper', function () {
-
- this.xConfig.setup.AS_ADMIN = false;
- this.applyFn();
- assert.lengthOf($('#login-wrapper > #login'), 1);
+ it('requires correct', function () {
+ assert.deepEqual(this.definition.deps, DEPS);
});
- it('does not add HTML #logout to #login-wrapper', function () {
-
- this.xConfig.setup.AS_ADMIN = false;
- this.applyFn();
- assert.lengthOf($('#login-wrapper > #logout'), 0);
+ it('args for each request', function () {
+ assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
});
- it('does not add HTML #tests to #content', function () {
-
- this.xConfig.setup.AS_ADMIN = false;
- this.applyFn();
- assert.lengthOf($('#content > #tests'), 0);
+ it('has no instance', function () {
+ assert.notProperty(modulejs._private.instances, ID);
});
- it('login works', function () {
+ it('inits without errors', function () {
+ this.applyFn();
+ });
+ });
- var pass = uniq.id();
- var expectedData = {
+ describe('application', function () {
+ it('returns undefined', function () {
+ var instance = this.applyFn();
+ assert.isUndefined(instance);
+ });
+
+ it('adds HTML #support to #content', function () {
+ this.applyFn();
+ assert.lengthOf($('#content > #support'), 1);
+ assert.lengthOf($('#support > .paypal'), 1);
+ assert.lengthOf($('.paypal > form'), 1);
+ });
+
+ it('adds HTML #login-wrapper to #content', function () {
+ this.applyFn();
+ assert.lengthOf($('#content > #login-wrapper'), 1);
+ });
+
+ describe('no admin', function () {
+ it('adds HTML #pass to #login-wrapper', function () {
+ this.xConfig.setup.AS_ADMIN = false;
+ this.applyFn();
+ assert.lengthOf($('#login-wrapper > #pass'), 1);
+ });
+
+ it('sets #pass val to empty string', function () {
+ this.xConfig.setup.AS_ADMIN = false;
+ this.applyFn();
+ assert.strictEqual($('#login-wrapper > #pass').val(), '');
+ });
+
+ it('adds HTML #login to #login-wrapper', function () {
+ this.xConfig.setup.AS_ADMIN = false;
+ this.applyFn();
+ assert.lengthOf($('#login-wrapper > #login'), 1);
+ });
+
+ it('does not add HTML #logout to #login-wrapper', function () {
+ this.xConfig.setup.AS_ADMIN = false;
+ this.applyFn();
+ assert.lengthOf($('#login-wrapper > #logout'), 0);
+ });
+
+ it('does not add HTML #tests to #content', function () {
+ this.xConfig.setup.AS_ADMIN = false;
+ this.applyFn();
+ assert.lengthOf($('#content > #tests'), 0);
+ });
+
+ it('login works', function () {
+ var pass = uniq.id();
+ var expectedData = {
action: 'login',
pass: pass
};
- this.xConfig.setup.AS_ADMIN = false;
- this.applyFn();
- $('#pass').val(pass);
- $('#login').trigger('click');
+ this.xConfig.setup.AS_ADMIN = false;
+ this.applyFn();
+ $('#pass').val(pass);
+ $('#login').trigger('click');
- assert.isTrue(this.xServer.request.calledOnce);
- assert.isPlainObject(this.xServer.request.lastCall.args[0]);
- assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
- assert.isFunction(this.xServer.request.lastCall.args[1]);
- });
- });
-
- describe('as admin', function () {
-
- it('does not add HTML #pass to #login-wrapper', function () {
-
- this.xConfig.setup.AS_ADMIN = true;
- this.applyFn();
- assert.lengthOf($('#login-wrapper > #pass'), 0);
+ assert.isTrue(this.xServer.request.calledOnce);
+ assert.isPlainObject(this.xServer.request.lastCall.args[0]);
+ assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
+ assert.isFunction(this.xServer.request.lastCall.args[1]);
+ });
});
- it('does not add #login to #login-wrapper', function () {
+ describe('as admin', function () {
+ it('does not add HTML #pass to #login-wrapper', function () {
+ this.xConfig.setup.AS_ADMIN = true;
+ this.applyFn();
+ assert.lengthOf($('#login-wrapper > #pass'), 0);
+ });
- this.xConfig.setup.AS_ADMIN = true;
- this.applyFn();
- assert.lengthOf($('#login-wrapper > #login'), 0);
- });
+ it('does not add #login to #login-wrapper', function () {
+ this.xConfig.setup.AS_ADMIN = true;
+ this.applyFn();
+ assert.lengthOf($('#login-wrapper > #login'), 0);
+ });
- it('adds HTML #logout to #login-wrapper', function () {
+ it('adds HTML #logout to #login-wrapper', function () {
+ this.xConfig.setup.AS_ADMIN = true;
+ this.applyFn();
+ assert.lengthOf($('#login-wrapper > #logout'), 1);
+ });
- this.xConfig.setup.AS_ADMIN = true;
- this.applyFn();
- assert.lengthOf($('#login-wrapper > #logout'), 1);
- });
+ it('adds HTML #tests to #content', function () {
+ this.xConfig.setup.AS_ADMIN = true;
+ this.applyFn();
+ assert.lengthOf($('#content > #tests'), 1);
+ });
- it('adds HTML #tests to #content', function () {
+ it('adds HTML #test 15x to #tests', function () {
+ this.xConfig.setup.AS_ADMIN = true;
+ this.applyFn();
+ assert.strictEqual($('#tests > .test').length, 15);
+ });
- this.xConfig.setup.AS_ADMIN = true;
- this.applyFn();
- assert.lengthOf($('#content > #tests'), 1);
- });
-
- it('adds HTML #test 15x to #tests', function () {
-
- this.xConfig.setup.AS_ADMIN = true;
- this.applyFn();
- assert.strictEqual($('#tests > .test').length, 15);
- });
-
- it('logout works', function () {
-
- var expectedData = {
+ it('logout works', function () {
+ var expectedData = {
action: 'logout'
};
- this.xConfig.setup.AS_ADMIN = true;
- this.applyFn();
- $('#logout').trigger('click');
+ this.xConfig.setup.AS_ADMIN = true;
+ this.applyFn();
+ $('#logout').trigger('click');
- assert.isTrue(this.xServer.request.calledOnce);
- assert.isPlainObject(this.xServer.request.lastCall.args[0]);
- assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
- assert.isFunction(this.xServer.request.lastCall.args[1]);
+ assert.isTrue(this.xServer.request.calledOnce);
+ assert.isPlainObject(this.xServer.request.lastCall.args[0]);
+ assert.deepEqual(this.xServer.request.lastCall.args[0], expectedData);
+ assert.isFunction(this.xServer.request.lastCall.args[1]);
+ });
});
});
});
-});
-
}());
diff --git a/test/tests/unit/model/item.js b/test/tests/unit/model/item.js
index 07d1a832..e6851278 100644
--- a/test/tests/unit/model/item.js
+++ b/test/tests/unit/model/item.js
@@ -1,444 +1,356 @@
(function () {
-'use strict';
+ var ID = 'model/item';
+ var DEPS = ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'];
-var ID = 'model/item';
-var DEPS = ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xRootName = uniq.id();
- this.xTypes = {
- getType: sinon.stub().returns(uniq.id())
- };
- this.xEvent = uniq.obj();
- this.xSettings = {
- rootHref: uniq.path('/' + this.xRootName + '/')
- };
- this.xServer = uniq.obj();
- this.xLocation = {
- forceEncoding: sinon.stub().returnsArg(0),
- getDomain: sinon.stub().returns(uniq.id()),
- getAbsHref: sinon.stub().returns(uniq.id())
- };
- this.applyFn = function () {
-
- return this.definition.fn(_, this.xEvent, this.xLocation, this.xServer, this.xSettings, this.xTypes);
- };
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xRootName = uniq.id();
+ this.xTypes = {
+ getType: sinon.stub().returns(uniq.id())
+ };
+ this.xEvent = uniq.obj();
+ this.xSettings = {
+ rootHref: uniq.path('/' + this.xRootName + '/')
+ };
+ this.xServer = uniq.obj();
+ this.xLocation = {
+ forceEncoding: sinon.stub().returnsArg(0),
+ getDomain: sinon.stub().returns(uniq.id()),
+ getAbsHref: sinon.stub().returns(uniq.id())
+ };
+ this.applyFn = function () {
+ return this.definition.fn(_, this.xEvent, this.xLocation, this.xServer, this.xSettings, this.xTypes);
+ };
});
- it('has correct id', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.id, ID);
+ 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();
+ });
});
- 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 2 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 2);
- });
- });
-
- describe('.get()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.get);
- });
-
- it('returns null with no argument', function () {
-
- var instance = this.applyFn();
- assert.isNull(instance.get());
- });
-
- it('returns null for no string argument', function () {
-
- var instance = this.applyFn();
- assert.isNull(instance.get(1));
- });
-
- it('returns null for href not starting with rootHref', function () {
-
- var instance = this.applyFn();
- assert.isNull(instance.get('/a/'));
- });
-
- describe('for rootHref', function () {
-
- beforeEach(function () {
-
+ describe('application', function () {
+ it('returns plain object with 2 properties', function () {
var instance = this.applyFn();
- this.item = instance.get(this.xSettings.rootHref);
- });
-
- it('returns object', function () {
-
- assert.isObject(this.item);
- });
-
- it('sets href correct', function () {
-
- assert.strictEqual(this.item.absHref, this.xSettings.rootHref);
- });
-
- it('sets type correct', function () {
-
- assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
- });
-
- it('sets label correct', function () {
-
- assert.strictEqual(this.item.label, this.xRootName);
- });
-
- it('sets time to null', function () {
-
- assert.isNull(this.item.time);
- });
-
- it('sets size to null', function () {
-
- assert.isNull(this.item.size);
- });
-
- it('sets parent to null', function () {
-
- assert.isNull(this.item.parent);
- });
-
- it('sets isManaged to null', function () {
-
- assert.isNull(this.item.isManaged);
- });
-
- it('sets content correct', function () {
-
- assert.isPlainObject(this.item.content);
- assert.lengthOfKeys(this.item.content, 0);
- });
-
- it('.isFolder() returns true', function () {
-
- assert.isTrue(this.item.isFolder());
- });
-
- it('.isCurrentFolder() returns false', function () {
-
- assert.isFalse(this.item.isCurrentFolder());
- });
-
- it('.isInCurrentFolder() returns false', function () {
-
- assert.isFalse(this.item.isInCurrentFolder());
- });
-
- it('.isCurrentParentFolder() returns false', function () {
-
- assert.isFalse(this.item.isCurrentParentFolder());
- });
-
- it('.isDomain() returns false', function () {
-
- assert.isFalse(this.item.isDomain());
- });
-
- it('.isRoot() returns true', function () {
-
- assert.isTrue(this.item.isRoot());
- });
-
- it('.isEmpty() returns true', function () {
-
- assert.isTrue(this.item.isEmpty());
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 2);
});
});
- describe('for folder href other than rootHref', function () {
-
- beforeEach(function () {
-
+ describe('.get()', function () {
+ it('is function', function () {
var instance = this.applyFn();
- this.item = instance.get(this.xSettings.rootHref + 'a/');
+ assert.isFunction(instance.get);
});
- it('returns object', function () {
-
- assert.isObject(this.item);
+ it('returns null with no argument', function () {
+ var instance = this.applyFn();
+ assert.isNull(instance.get());
});
- it('sets href correct', function () {
-
- assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a/');
+ it('returns null for no string argument', function () {
+ var instance = this.applyFn();
+ assert.isNull(instance.get(1));
});
- it('sets type correct', function () {
-
- assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
+ it('returns null for href not starting with rootHref', function () {
+ var instance = this.applyFn();
+ assert.isNull(instance.get('/a/'));
});
- it('sets label correct', function () {
+ describe('for rootHref', function () {
+ beforeEach(function () {
+ var instance = this.applyFn();
+ this.item = instance.get(this.xSettings.rootHref);
+ });
- assert.strictEqual(this.item.label, 'a');
+ it('returns object', function () {
+ assert.isObject(this.item);
+ });
+
+ it('sets href correct', function () {
+ assert.strictEqual(this.item.absHref, this.xSettings.rootHref);
+ });
+
+ it('sets type correct', function () {
+ assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
+ });
+
+ it('sets label correct', function () {
+ assert.strictEqual(this.item.label, this.xRootName);
+ });
+
+ it('sets time to null', function () {
+ assert.isNull(this.item.time);
+ });
+
+ it('sets size to null', function () {
+ assert.isNull(this.item.size);
+ });
+
+ it('sets parent to null', function () {
+ assert.isNull(this.item.parent);
+ });
+
+ it('sets isManaged to null', function () {
+ assert.isNull(this.item.isManaged);
+ });
+
+ it('sets content correct', function () {
+ assert.isPlainObject(this.item.content);
+ assert.lengthOfKeys(this.item.content, 0);
+ });
+
+ it('.isFolder() returns true', function () {
+ assert.isTrue(this.item.isFolder());
+ });
+
+ it('.isCurrentFolder() returns false', function () {
+ assert.isFalse(this.item.isCurrentFolder());
+ });
+
+ it('.isInCurrentFolder() returns false', function () {
+ assert.isFalse(this.item.isInCurrentFolder());
+ });
+
+ it('.isCurrentParentFolder() returns false', function () {
+ assert.isFalse(this.item.isCurrentParentFolder());
+ });
+
+ it('.isDomain() returns false', function () {
+ assert.isFalse(this.item.isDomain());
+ });
+
+ it('.isRoot() returns true', function () {
+ assert.isTrue(this.item.isRoot());
+ });
+
+ it('.isEmpty() returns true', function () {
+ assert.isTrue(this.item.isEmpty());
+ });
});
- it('sets time to null', function () {
+ describe('for folder href other than rootHref', function () {
+ beforeEach(function () {
+ var instance = this.applyFn();
+ this.item = instance.get(this.xSettings.rootHref + 'a/');
+ });
- assert.isNull(this.item.time);
+ it('returns object', function () {
+ assert.isObject(this.item);
+ });
+
+ it('sets href correct', function () {
+ assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a/');
+ });
+
+ it('sets type correct', function () {
+ assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
+ });
+
+ it('sets label correct', function () {
+ assert.strictEqual(this.item.label, 'a');
+ });
+
+ it('sets time to null', function () {
+ assert.isNull(this.item.time);
+ });
+
+ it('sets size to null', function () {
+ assert.isNull(this.item.size);
+ });
+
+ it('sets parent to object', function () {
+ assert.isObject(this.item.parent);
+ });
+
+ it('parent has same constructor', function () {
+ assert.strictEqual(this.item.constructor, this.item.parent.constructor);
+ });
+
+ it('sets isManaged to null', function () {
+ assert.isNull(this.item.isManaged);
+ });
+
+ it('sets content correct', function () {
+ assert.isPlainObject(this.item.content);
+ assert.lengthOfKeys(this.item.content, 0);
+ });
+
+ it('.isFolder() returns true', function () {
+ assert.isTrue(this.item.isFolder());
+ });
+
+ it('.isCurrentFolder() returns false', function () {
+ assert.isFalse(this.item.isCurrentFolder());
+ });
+
+ it('.isInCurrentFolder() returns false', function () {
+ assert.isFalse(this.item.isInCurrentFolder());
+ });
+
+ it('.isCurrentParentFolder() returns false', function () {
+ assert.isFalse(this.item.isCurrentParentFolder());
+ });
+
+ it('.isDomain() returns false', function () {
+ assert.isFalse(this.item.isDomain());
+ });
+
+ it('.isRoot() returns false', function () {
+ assert.isFalse(this.item.isRoot());
+ });
+
+ it('.isEmpty() returns true', function () {
+ assert.isTrue(this.item.isEmpty());
+ });
});
- it('sets size to null', function () {
+ describe('for file href', function () {
+ beforeEach(function () {
+ var instance = this.applyFn();
+ this.item = instance.get(this.xSettings.rootHref + 'a');
+ });
- assert.isNull(this.item.size);
+ it('returns object', function () {
+ assert.isObject(this.item);
+ });
+
+ it('sets href correct', function () {
+ assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a');
+ });
+
+ it('sets type correct', function () {
+ assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
+ });
+
+ it('sets label correct', function () {
+ assert.strictEqual(this.item.label, 'a');
+ });
+
+ it('sets time to null', function () {
+ assert.isNull(this.item.time);
+ });
+
+ it('sets size to null', function () {
+ assert.isNull(this.item.size);
+ });
+
+ it('sets parent to object', function () {
+ assert.isObject(this.item.parent);
+ });
+
+ it('parent has same constructor', function () {
+ assert.strictEqual(this.item.constructor, this.item.parent.constructor);
+ });
+
+ it('sets isManaged to null', function () {
+ assert.isNull(this.item.isManaged);
+ });
+
+ it('sets content correct', function () {
+ assert.isPlainObject(this.item.content);
+ assert.lengthOfKeys(this.item.content, 0);
+ });
+
+ it('.isFolder() returns false', function () {
+ assert.isFalse(this.item.isFolder());
+ });
+
+ it('.isCurrentFolder() returns false', function () {
+ assert.isFalse(this.item.isCurrentFolder());
+ });
+
+ it('.isInCurrentFolder() returns false', function () {
+ assert.isFalse(this.item.isInCurrentFolder());
+ });
+
+ it('.isCurrentParentFolder() returns false', function () {
+ assert.isFalse(this.item.isCurrentParentFolder());
+ });
+
+ it('.isDomain() returns false', function () {
+ assert.isFalse(this.item.isDomain());
+ });
+
+ it('.isRoot() returns false', function () {
+ assert.isFalse(this.item.isRoot());
+ });
+
+ it('.isEmpty() returns true', function () {
+ assert.isTrue(this.item.isEmpty());
+ });
});
- it('sets parent to object', function () {
+ describe('parents', function () {
+ beforeEach(function () {
+ var instance = this.applyFn();
+ this.item = instance.get(this.xSettings.rootHref + 'p/a/');
+ this.parent = this.item.parent;
+ this.grandpa = this.parent.parent;
+ });
- assert.isObject(this.item.parent);
- });
+ it('parent is object', function () {
+ assert.isObject(this.parent);
+ });
- it('parent has same constructor', function () {
+ it('parent has correct href', function () {
+ assert.strictEqual(this.parent.absHref, this.xSettings.rootHref + 'p/');
+ });
- assert.strictEqual(this.item.constructor, this.item.parent.constructor);
- });
+ it('parent has correct label', function () {
+ assert.strictEqual(this.parent.label, 'p');
+ });
- it('sets isManaged to null', function () {
+ it('parent .isEmpty() returns false', function () {
+ assert.isFalse(this.parent.isEmpty());
+ });
- assert.isNull(this.item.isManaged);
- });
+ it('grandpa is object', function () {
+ assert.isObject(this.grandpa);
+ });
- it('sets content correct', function () {
+ it('grandpa has correct href', function () {
+ assert.strictEqual(this.grandpa.absHref, this.xSettings.rootHref);
+ });
- assert.isPlainObject(this.item.content);
- assert.lengthOfKeys(this.item.content, 0);
- });
+ it('grandpa has correct label', function () {
+ assert.strictEqual(this.grandpa.label, this.xRootName);
+ });
- it('.isFolder() returns true', function () {
-
- assert.isTrue(this.item.isFolder());
- });
-
- it('.isCurrentFolder() returns false', function () {
-
- assert.isFalse(this.item.isCurrentFolder());
- });
-
- it('.isInCurrentFolder() returns false', function () {
-
- assert.isFalse(this.item.isInCurrentFolder());
- });
-
- it('.isCurrentParentFolder() returns false', function () {
-
- assert.isFalse(this.item.isCurrentParentFolder());
- });
-
- it('.isDomain() returns false', function () {
-
- assert.isFalse(this.item.isDomain());
- });
-
- it('.isRoot() returns false', function () {
-
- assert.isFalse(this.item.isRoot());
- });
-
- it('.isEmpty() returns true', function () {
-
- assert.isTrue(this.item.isEmpty());
+ it('grandpa .isEmpty() returns false', function () {
+ assert.isFalse(this.grandpa.isEmpty());
+ });
});
});
- describe('for file href', function () {
-
- beforeEach(function () {
-
+ describe('.remove()', function () {
+ it('is function', function () {
var instance = this.applyFn();
- this.item = instance.get(this.xSettings.rootHref + 'a');
- });
-
- it('returns object', function () {
-
- assert.isObject(this.item);
- });
-
- it('sets href correct', function () {
-
- assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a');
- });
-
- it('sets type correct', function () {
-
- assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
- });
-
- it('sets label correct', function () {
-
- assert.strictEqual(this.item.label, 'a');
- });
-
- it('sets time to null', function () {
-
- assert.isNull(this.item.time);
- });
-
- it('sets size to null', function () {
-
- assert.isNull(this.item.size);
- });
-
- it('sets parent to object', function () {
-
- assert.isObject(this.item.parent);
- });
-
- it('parent has same constructor', function () {
-
- assert.strictEqual(this.item.constructor, this.item.parent.constructor);
- });
-
- it('sets isManaged to null', function () {
-
- assert.isNull(this.item.isManaged);
- });
-
- it('sets content correct', function () {
-
- assert.isPlainObject(this.item.content);
- assert.lengthOfKeys(this.item.content, 0);
- });
-
- it('.isFolder() returns false', function () {
-
- assert.isFalse(this.item.isFolder());
- });
-
- it('.isCurrentFolder() returns false', function () {
-
- assert.isFalse(this.item.isCurrentFolder());
- });
-
- it('.isInCurrentFolder() returns false', function () {
-
- assert.isFalse(this.item.isInCurrentFolder());
- });
-
- it('.isCurrentParentFolder() returns false', function () {
-
- assert.isFalse(this.item.isCurrentParentFolder());
- });
-
- it('.isDomain() returns false', function () {
-
- assert.isFalse(this.item.isDomain());
- });
-
- it('.isRoot() returns false', function () {
-
- assert.isFalse(this.item.isRoot());
- });
-
- it('.isEmpty() returns true', function () {
-
- assert.isTrue(this.item.isEmpty());
- });
- });
-
- describe('parents', function () {
-
- beforeEach(function () {
-
- var instance = this.applyFn();
- this.item = instance.get(this.xSettings.rootHref + 'p/a/');
- this.parent = this.item.parent;
- this.grandpa = this.parent.parent;
- });
-
- it('parent is object', function () {
-
- assert.isObject(this.parent);
- });
-
- it('parent has correct href', function () {
-
- assert.strictEqual(this.parent.absHref, this.xSettings.rootHref + 'p/');
- });
-
- it('parent has correct label', function () {
-
- assert.strictEqual(this.parent.label, 'p');
- });
-
- it('parent .isEmpty() returns false', function () {
-
- assert.isFalse(this.parent.isEmpty());
- });
-
- it('grandpa is object', function () {
-
- assert.isObject(this.grandpa);
- });
-
- it('grandpa has correct href', function () {
-
- assert.strictEqual(this.grandpa.absHref, this.xSettings.rootHref);
- });
-
- it('grandpa has correct label', function () {
-
- assert.strictEqual(this.grandpa.label, this.xRootName);
- });
-
- it('grandpa .isEmpty() returns false', function () {
-
- assert.isFalse(this.grandpa.isEmpty());
+ assert.isFunction(instance.remove);
});
});
});
-
- describe('.remove()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isFunction(instance.remove);
- });
- });
-});
-
}());
diff --git a/test/tests/unit/modulejs.js b/test/tests/unit/modulejs.js
index cda9b20c..03dfb9cf 100644
--- a/test/tests/unit/modulejs.js
+++ b/test/tests/unit/modulejs.js
@@ -1,48 +1,36 @@
(function () {
-'use strict';
+ describe('modulejs', function () {
+ it('is global object', function () {
+ assert.isPlainObject(modulejs);
+ assert.strictEqual(modulejs, window.modulejs);
+ });
-describe('modulejs', function () {
+ it('.define() is function', function () {
+ assert.isFunction(modulejs.define);
+ });
- it('is global object', function () {
+ it('.require() is function', function () {
+ assert.isFunction(modulejs.require);
+ });
- assert.isPlainObject(modulejs);
- assert.strictEqual(modulejs, window.modulejs);
+ it('.state() is function', function () {
+ assert.isFunction(modulejs.state);
+ });
+
+ it('.log() is function', function () {
+ assert.isFunction(modulejs.log);
+ });
+
+ it('._private is object', function () {
+ assert.isObject(modulejs._private);
+ });
+
+ it('has definitions', function () {
+ assert.isAbove(_.keys(modulejs._private.definitions).length, 0);
+ });
+
+ it('has no instances', function () {
+ assert.lengthOfKeys(modulejs._private.instances, 0);
+ });
});
-
- it('.define() is function', function () {
-
- assert.isFunction(modulejs.define);
- });
-
- it('.require() is function', function () {
-
- assert.isFunction(modulejs.require);
- });
-
- it('.state() is function', function () {
-
- assert.isFunction(modulejs.state);
- });
-
- it('.log() is function', function () {
-
- assert.isFunction(modulejs.log);
- });
-
- it('._private is object', function () {
-
- assert.isObject(modulejs._private);
- });
-
- it('has definitions', function () {
-
- assert.isAbove(_.keys(modulejs._private.definitions).length, 0);
- });
-
- it('has no instances', function () {
-
- assert.lengthOfKeys(modulejs._private.instances, 0);
- });
-});
-
}());
diff --git a/test/tests/unit/view/content.js b/test/tests/unit/view/content.js
index 9c23e34c..eecce7f0 100644
--- a/test/tests/unit/view/content.js
+++ b/test/tests/unit/view/content.js
@@ -1,93 +1,73 @@
(function () {
-'use strict';
+ var ID = 'view/content';
+ var DEPS = ['$', 'view/mainrow'];
-var ID = 'view/content';
-var DEPS = ['$', 'view/mainrow'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xMainrow = {$el: null};
- this.applyFn = function () {
-
- return this.definition.fn($, this.xMainrow);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xMainrow.$el = $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xMainrow = {$el: null};
+ this.applyFn = function () {
+ return this.definition.fn($, this.xMainrow);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xMainrow.$el = $('
').appendTo('body');
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns object with 1 property', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 1);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds HTML #content to #mainrow', function () {
+ this.applyFn();
+ assert.lengthOf($('#mainrow > #content'), 1);
+ });
});
- it('inits without errors', function () {
-
- this.applyFn();
+ describe('.$el', function () {
+ it('is $(\'#content\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'content');
+ });
});
});
-
- describe('application', function () {
-
- it('returns object with 1 property', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 1);
- });
-
- it('adds HTML #content to #mainrow', function () {
-
- this.applyFn();
- assert.lengthOf($('#mainrow > #content'), 1);
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#content\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'content');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/view/mainrow.js b/test/tests/unit/view/mainrow.js
index 24fc9fa6..66f58f10 100644
--- a/test/tests/unit/view/mainrow.js
+++ b/test/tests/unit/view/mainrow.js
@@ -1,93 +1,73 @@
(function () {
-'use strict';
+ var ID = 'view/mainrow';
+ var DEPS = ['$', 'view/root'];
-var ID = 'view/mainrow';
-var DEPS = ['$', 'view/root'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xRoot = {$el: null};
- this.applyFn = function () {
-
- return this.definition.fn($, this.xRoot);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xRoot.$el = $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xRoot = {$el: null};
+ this.applyFn = function () {
+ return this.definition.fn($, this.xRoot);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xRoot.$el = $('
').appendTo('body');
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns object with 1 property', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 1);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds HTML #mainrow to #root', function () {
+ this.applyFn();
+ assert.lengthOf($('#root > #mainrow'), 1);
+ });
});
- it('inits without errors', function () {
-
- this.applyFn();
+ describe('.$el', function () {
+ it('is $(\'#mainrow\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'mainrow');
+ });
});
});
-
- describe('application', function () {
-
- it('returns object with 1 property', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 1);
- });
-
- it('adds HTML #mainrow to #root', function () {
-
- this.applyFn();
- assert.lengthOf($('#root > #mainrow'), 1);
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#mainrow\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'mainrow');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/view/notification.js b/test/tests/unit/view/notification.js
index f3208be2..8eb726d8 100644
--- a/test/tests/unit/view/notification.js
+++ b/test/tests/unit/view/notification.js
@@ -1,125 +1,102 @@
(function () {
-'use strict';
+ var ID = 'view/notification';
+ var DEPS = ['$', 'view/root'];
-var ID = 'view/notification';
-var DEPS = ['$', 'view/root'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xRoot = {$el: null};
- this.applyFn = function () {
-
- return this.definition.fn($, this.xRoot);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xRoot.$el = $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xRoot = {$el: null};
+ this.applyFn = function () {
+ return this.definition.fn($, this.xRoot);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xRoot.$el = $('
').appendTo('body');
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns plain object with 2 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 2);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds HTML #notification to #root (hidden)', function () {
+ this.applyFn();
+ assert.lengthOf($('#root > #notification'), 1);
+ assert.lengthOf($('#notification:visible'), 0);
+ assert.strictEqual($('#notification').text(), '');
+ });
});
- it('inits without errors', function () {
+ describe('.$el', function () {
+ it('is $(\'#notification\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'notification');
+ });
+ });
- this.applyFn();
+ describe('.set()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.set));
+ });
+
+ it('works', function () {
+ var instance = this.applyFn();
+
+ instance.set();
+ assert.lengthOf($('#notification:visible'), 0);
+ assert.strictEqual($('#notification').text(), '');
+
+ instance.set('hello');
+ assert.lengthOf($('#notification:visible'), 1);
+ assert.strictEqual($('#notification').text(), 'hello');
+
+ instance.set('world');
+ assert.lengthOf($('#notification:visible'), 1);
+ assert.strictEqual($('#notification').text(), 'world');
+
+ instance.set();
+ // assert.lengthOf($('#notification:visible'), 0);
+ assert.strictEqual($('#notification').text(), 'world');
+ });
});
});
-
- describe('application', function () {
-
- it('returns plain object with 2 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 2);
- });
-
- it('adds HTML #notification to #root (hidden)', function () {
-
- this.applyFn();
- assert.lengthOf($('#root > #notification'), 1);
- assert.lengthOf($('#notification:visible'), 0);
- assert.strictEqual($('#notification').text(), '');
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#notification\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'notification');
- });
- });
-
- describe('.set()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.set));
- });
-
- it('works', function () {
-
- var instance = this.applyFn();
-
- instance.set();
- assert.lengthOf($('#notification:visible'), 0);
- assert.strictEqual($('#notification').text(), '');
-
- instance.set('hello');
- assert.lengthOf($('#notification:visible'), 1);
- assert.strictEqual($('#notification').text(), 'hello');
-
- instance.set('world');
- assert.lengthOf($('#notification:visible'), 1);
- assert.strictEqual($('#notification').text(), 'world');
-
- instance.set();
- // assert.lengthOf($('#notification:visible'), 0);
- assert.strictEqual($('#notification').text(), 'world');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/view/root.js b/test/tests/unit/view/root.js
index b8e47188..f2c66358 100644
--- a/test/tests/unit/view/root.js
+++ b/test/tests/unit/view/root.js
@@ -1,105 +1,83 @@
(function () {
-'use strict';
+ var ID = 'view/root';
+ var DEPS = ['$'];
-var ID = 'view/root';
-var DEPS = ['$'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.applyFn = function () {
-
- return this.definition.fn($);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- $('
').appendTo('body');
- $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.applyFn = function () {
+ return this.definition.fn($);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ $('
').appendTo('body');
+ $('
').appendTo('body');
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns object with 1 property', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 1);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds id root to body', function () {
+ this.applyFn();
+ assert.strictEqual($('body').attr('id'), 'root');
+ });
+
+ it('removes HTML #fallback', function () {
+ this.applyFn();
+ assert.lengthOf($('#fallback'), 0);
+ });
+
+ it('removes HTML #fallback-hints', function () {
+ this.applyFn();
+ assert.lengthOf($('#fallback-hints'), 0);
+ });
});
- it('inits without errors', function () {
-
- this.applyFn();
+ describe('.$el', function () {
+ it('is $(\'#root\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'root');
+ });
});
});
-
- describe('application', function () {
-
- it('returns object with 1 property', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 1);
- });
-
- it('adds id root to body', function () {
-
- this.applyFn();
- assert.strictEqual($('body').attr('id'), 'root');
- });
-
- it('removes HTML #fallback', function () {
-
- this.applyFn();
- assert.lengthOf($('#fallback'), 0);
- });
-
- it('removes HTML #fallback-hints', function () {
-
- this.applyFn();
- assert.lengthOf($('#fallback-hints'), 0);
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#root\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'root');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/view/sidebar.js b/test/tests/unit/view/sidebar.js
index f7d1b591..6fc498aa 100644
--- a/test/tests/unit/view/sidebar.js
+++ b/test/tests/unit/view/sidebar.js
@@ -1,142 +1,121 @@
(function () {
-'use strict';
+ var ID = 'view/sidebar';
+ var DEPS = ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'];
-var ID = 'view/sidebar';
-var DEPS = ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xResource = {
+ image: sinon.stub().throws('invalid image request')
+ };
+ this.xResource.image.withArgs('back').returns(uniq.path('-back.png'));
+ this.xResource.image.withArgs('sidebar').returns(uniq.path('-sidebar.png'));
+ this.xStore = {
+ get: sinon.stub().returns(false),
+ put: sinon.stub()
+ };
+ this.xStore.get.returns(false);
+ this.xMainrow = {$el: null};
+ this.xTopbar = {$toolbar: null};
+ this.applyFn = function () {
+ this.xResource.image.reset();
+ this.xStore.get.reset();
+ this.xStore.put.reset();
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xResource = {
- image: sinon.stub().throws('invalid image request')
- };
- this.xResource.image.withArgs('back').returns(uniq.path('-back.png'));
- this.xResource.image.withArgs('sidebar').returns(uniq.path('-sidebar.png'));
- this.xStore = {
- get: sinon.stub().returns(false),
- put: sinon.stub()
- };
- this.xStore.get.returns(false);
- this.xMainrow = {$el: null};
- this.xTopbar = {$toolbar: null};
- this.applyFn = function () {
-
- this.xResource.image.reset();
- this.xStore.get.reset();
- this.xStore.put.reset();
-
- return this.definition.fn($, this.xResource, this.xStore, this.xMainrow, this.xTopbar);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xMainrow.$el = $('
').appendTo('body');
- this.xTopbar.$toolbar = $('
').appendTo('body');
- });
-
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ return this.definition.fn($, this.xResource, this.xStore, this.xMainrow, this.xTopbar);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xMainrow.$el = $('
').appendTo('body');
+ this.xTopbar.$toolbar = $('
').appendTo('body');
});
- it('args for each request', function () {
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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.instance = this.applyFn();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns object with 1 property', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 1);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds HTML #sidebar-toggle to #toolbar', function () {
+ this.applyFn();
+ assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
+ });
+
+ it('toggle works', function () {
+ this.applyFn();
+ assert.lengthOf($('#sidebar:visible'), 0);
+
+ this.xStore.get.returns(false).reset();
+ this.xStore.put.reset();
+
+ $('#sidebar-toggle').trigger('click');
+
+ assert.isTrue(this.xStore.get.calledOnce);
+ assert.strictEqual(this.xStore.get.lastCall.args[0], 'sidebarIsVisible');
+ assert.isTrue(this.xStore.put.calledOnce);
+ assert.strictEqual(this.xStore.put.lastCall.args[0], 'sidebarIsVisible');
+ assert.isTrue(this.xStore.put.lastCall.args[1]);
+
+ assert.lengthOf($('#sidebar:visible'), 1);
+
+ this.xStore.get.returns(true).reset();
+ this.xStore.put.reset();
+
+ $('#sidebar-toggle').trigger('click');
+
+ assert.isTrue(this.xStore.get.calledOnce);
+ assert.strictEqual(this.xStore.get.lastCall.args[0], 'sidebarIsVisible');
+ assert.isTrue(this.xStore.put.calledOnce);
+ assert.strictEqual(this.xStore.put.lastCall.args[0], 'sidebarIsVisible');
+ assert.isFalse(this.xStore.put.lastCall.args[1]);
+
+ assert.lengthOf($('#sidebar:visible'), 0);
+ });
});
- it('inits without errors', function () {
-
- this.instance = this.applyFn();
+ describe('.$el', function () {
+ it('is $(\'#sidebar\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'sidebar');
+ });
});
});
-
- describe('application', function () {
-
- it('returns object with 1 property', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 1);
- });
-
- it('adds HTML #sidebar-toggle to #toolbar', function () {
-
- this.applyFn();
- assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
- });
-
- it('toggle works', function () {
-
- this.applyFn();
- assert.lengthOf($('#sidebar:visible'), 0);
-
- this.xStore.get.returns(false).reset();
- this.xStore.put.reset();
-
- $('#sidebar-toggle').trigger('click');
-
- assert.isTrue(this.xStore.get.calledOnce);
- assert.strictEqual(this.xStore.get.lastCall.args[0], 'sidebarIsVisible');
- assert.isTrue(this.xStore.put.calledOnce);
- assert.strictEqual(this.xStore.put.lastCall.args[0], 'sidebarIsVisible');
- assert.isTrue(this.xStore.put.lastCall.args[1]);
-
- assert.lengthOf($('#sidebar:visible'), 1);
-
- this.xStore.get.returns(true).reset();
- this.xStore.put.reset();
-
- $('#sidebar-toggle').trigger('click');
-
- assert.isTrue(this.xStore.get.calledOnce);
- assert.strictEqual(this.xStore.get.lastCall.args[0], 'sidebarIsVisible');
- assert.isTrue(this.xStore.put.calledOnce);
- assert.strictEqual(this.xStore.put.lastCall.args[0], 'sidebarIsVisible');
- assert.isFalse(this.xStore.put.lastCall.args[1]);
-
- assert.lengthOf($('#sidebar:visible'), 0);
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#sidebar\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'sidebar');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/view/topbar.js b/test/tests/unit/view/topbar.js
index f76b28d8..9b5747d6 100644
--- a/test/tests/unit/view/topbar.js
+++ b/test/tests/unit/view/topbar.js
@@ -1,154 +1,124 @@
(function () {
-'use strict';
+ var ID = 'view/topbar';
+ var DEPS = ['$', 'view/root'];
-var ID = 'view/topbar';
-var DEPS = ['$', 'view/root'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
-
- before(function () {
-
- this.definition = modulejs._private.definitions[ID];
-
- this.xRoot = {$el: null};
- this.applyFn = function () {
-
- return this.definition.fn($, this.xRoot);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xRoot.$el = $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ this.xRoot = {$el: null};
+ this.applyFn = function () {
+ return this.definition.fn($, this.xRoot);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xRoot.$el = $('
').appendTo('body');
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns object with 3 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 3);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds HTML #topbar to #root', function () {
+ this.applyFn();
+ assert.lengthOf($('#root > #topbar'), 1);
+ });
+
+ it('adds HTML #toolbar to #topbar', function () {
+ this.applyFn();
+ assert.lengthOf($('#topbar > #toolbar'), 1);
+ });
+
+ it('adds HTML #flowbar to #topbar', function () {
+ this.applyFn();
+ assert.lengthOf($('#topbar > #flowbar'), 1);
+ });
+
+ it('adds HTML #backlink to #topbar', function () {
+ this.applyFn();
+ assert.lengthOf($('#topbar > #backlink'), 1);
+ });
+
+ it('#backlink has correct href', function () {
+ this.applyFn();
+ assert.strictEqual($('#backlink').attr('href'), 'https://larsjung.de/h5ai/');
+ });
+
+ it('#backlink has correct title', function () {
+ this.applyFn();
+ assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai - https://larsjung.de/h5ai/');
+ });
+
+ it('#backlink has correct text', function () {
+ this.applyFn();
+ assert.strictEqual($('#backlink > div').eq(0).text(), 'powered');
+ assert.strictEqual($('#backlink > div').eq(1).text(), 'by h5ai');
+ });
});
- it('inits without errors', function () {
+ describe('.$el', function () {
+ it('is $(\'#topbar\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'topbar');
+ });
+ });
- this.applyFn();
+ describe('.$toolbar', function () {
+ it('is $(\'#toolbar\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$toolbar);
+ assert.lengthOf(instance.$toolbar, 1);
+ assert.isString(instance.$toolbar.jquery);
+ assert.strictEqual(instance.$toolbar.attr('id'), 'toolbar');
+ });
+ });
+
+ describe('.$flowbar', function () {
+ it('is $(\'#flowbar\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$flowbar);
+ assert.lengthOf(instance.$flowbar, 1);
+ assert.isString(instance.$flowbar.jquery);
+ assert.strictEqual(instance.$flowbar.attr('id'), 'flowbar');
+ });
});
});
-
- describe('application', function () {
-
- it('returns object with 3 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 3);
- });
-
- it('adds HTML #topbar to #root', function () {
-
- this.applyFn();
- assert.lengthOf($('#root > #topbar'), 1);
- });
-
- it('adds HTML #toolbar to #topbar', function () {
-
- this.applyFn();
- assert.lengthOf($('#topbar > #toolbar'), 1);
- });
-
- it('adds HTML #flowbar to #topbar', function () {
-
- this.applyFn();
- assert.lengthOf($('#topbar > #flowbar'), 1);
- });
-
- it('adds HTML #backlink to #topbar', function () {
-
- this.applyFn();
- assert.lengthOf($('#topbar > #backlink'), 1);
- });
-
- it('#backlink has correct href', function () {
-
- this.applyFn();
- assert.strictEqual($('#backlink').attr('href'), 'https://larsjung.de/h5ai/');
- });
-
- it('#backlink has correct title', function () {
-
- this.applyFn();
- assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai - https://larsjung.de/h5ai/');
- });
-
- it('#backlink has correct text', function () {
-
- this.applyFn();
- assert.strictEqual($('#backlink > div').eq(0).text(), 'powered');
- assert.strictEqual($('#backlink > div').eq(1).text(), 'by h5ai');
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#topbar\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'topbar');
- });
- });
-
- describe('.$toolbar', function () {
-
- it('is $(\'#toolbar\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$toolbar);
- assert.lengthOf(instance.$toolbar, 1);
- assert.isString(instance.$toolbar.jquery);
- assert.strictEqual(instance.$toolbar.attr('id'), 'toolbar');
- });
- });
-
- describe('.$flowbar', function () {
-
- it('is $(\'#flowbar\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$flowbar);
- assert.lengthOf(instance.$flowbar, 1);
- assert.isString(instance.$flowbar.jquery);
- assert.strictEqual(instance.$flowbar.attr('id'), 'flowbar');
- });
- });
-});
-
}());
diff --git a/test/tests/unit/view/view.js b/test/tests/unit/view/view.js
index 2009bf0e..a5cef8a7 100644
--- a/test/tests/unit/view/view.js
+++ b/test/tests/unit/view/view.js
@@ -1,455 +1,385 @@
(function () {
-'use strict';
+ var ID = 'view/view';
+ var DEPS = ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'];
-var ID = 'view/view';
-var DEPS = ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xEvent = {
+ sub: sinon.stub(),
+ pub: sinon.stub()
+ };
+ this.xFormat = {
+ setDefaultMetric: sinon.stub(),
+ formatDate: sinon.stub().returns(uniq.id()),
+ formatSize: sinon.stub().returns(uniq.id())
+ };
+ this.xLocation = {
+ setLink: sinon.stub().returns(uniq.id())
+ };
+ this.xResource = {
+ icon: sinon.stub().returns(uniq.id())
+ };
+ this.xSettings = {view: {
+ binaryPrefix: false,
+ hideFolders: false,
+ hideParentFolder: false,
+ modes: ['details', 'grid', 'icons'],
+ setParentFolderLabels: false,
+ sizes: [20, 40, 60, 80, 100, 150, 200, 250, 300, 350, 400]
+ }};
+ this.xStore = {
+ get: sinon.stub(),
+ put: sinon.stub()
+ };
+ this.xContent = {$el: null};
- before(function () {
+ this.applyFn = function () {
+ this.xEvent.sub.reset();
+ this.xEvent.pub.reset();
+ this.xFormat.setDefaultMetric.reset();
+ this.xFormat.formatDate.reset();
+ this.xFormat.formatSize.reset();
+ this.xLocation.setLink.reset();
+ this.xResource.icon.reset();
- this.definition = modulejs._private.definitions[ID];
+ return this.definition.fn(_, $, this.xEvent, this.xFormat, this.xLocation, this.xResource, this.xSettings, this.xStore, this.xContent);
+ };
+ });
- this.xEvent = {
- sub: sinon.stub(),
- pub: sinon.stub()
- };
- this.xFormat = {
- setDefaultMetric: sinon.stub(),
- formatDate: sinon.stub().returns(uniq.id()),
- formatSize: sinon.stub().returns(uniq.id())
- };
- this.xLocation = {
- setLink: sinon.stub().returns(uniq.id())
- };
- this.xResource = {
- icon: sinon.stub().returns(uniq.id())
- };
- this.xSettings = {view: {
- binaryPrefix: false,
- hideFolders: false,
- hideParentFolder: false,
- modes: ['details', 'grid', 'icons'],
- setParentFolderLabels: false,
- sizes: [20, 40, 60, 80, 100, 150, 200, 250, 300, 350, 400]
- }};
- this.xStore = {
- get: sinon.stub(),
- put: sinon.stub()
- };
- this.xContent = {$el: null};
+ after(function () {
+ util.restoreHtml();
+ });
- this.applyFn = function () {
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xContent.$el = $('
').appendTo('body');
+ });
- this.xEvent.sub.reset();
- this.xEvent.pub.reset();
- this.xFormat.setDefaultMetric.reset();
- this.xFormat.formatDate.reset();
- this.xFormat.formatSize.reset();
- this.xLocation.setLink.reset();
- this.xResource.icon.reset();
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- return this.definition.fn(_, $, this.xEvent, this.xFormat, this.xLocation, this.xResource, this.xSettings, this.xStore, this.xContent);
- };
+ 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 object with 12 properties', function () {
+ var instance = this.applyFn();
+ assert.isPlainObject(instance);
+ assert.lengthOfKeys(instance, 12);
+ });
+
+ it('adds HTML #view to #content', function () {
+ this.applyFn();
+ assert.lengthOf($('#content > #view'), 1);
+ });
+
+ it('adds HTML #items to #view', function () {
+ this.applyFn();
+ assert.lengthOf($('#view > #items'), 1);
+ });
+
+ it('adds HTML #view-hint to #view', function () {
+ this.applyFn();
+ assert.lengthOf($('#view > #view-hint'), 1);
+ });
+
+ it('adds style to head', function () {
+ var styleTagCount = $('head > style').length;
+ this.applyFn();
+ assert.lengthOf($('head > style'), styleTagCount + 1);
+ });
+
+ it('style contains possibly correct text', function () {
+ this.xSettings.sizes = [20];
+ this.applyFn();
+ var text = $('head > style').eq(0).text();
+ assert.isTrue(text.indexOf('#view.view-details.view-size-20 ') >= 0);
+ assert.isTrue(text.indexOf('#view.view-grid.view-size-20 ') >= 0);
+ assert.isTrue(text.indexOf('#view.view-icons.view-size-20 ') >= 0);
+ });
+
+ it('sets default metric', function () {
+ this.applyFn();
+ assert.isTrue(this.xFormat.setDefaultMetric.calledOnce);
+ });
+
+ it('subscribes to 2 events', function () {
+ this.applyFn();
+ assert.isTrue(this.xEvent.sub.calledTwice);
+ });
+
+ 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]);
+ });
+
+ it('subscribes to location.refreshed', function () {
+ this.applyFn();
+ assert.strictEqual(this.xEvent.sub.secondCall.args[0], 'location.refreshed');
+ assert.isFunction(this.xEvent.sub.secondCall.args[1]);
+ });
+ });
+
+ describe('.$el', function () {
+ it('is $(\'#view\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$el);
+ assert.lengthOf(instance.$el, 1);
+ assert.isString(instance.$el.jquery);
+ assert.strictEqual(instance.$el.attr('id'), 'view');
+ });
+ });
+
+ describe('.$items', function () {
+ it('is $(\'#items\')', function () {
+ var instance = this.applyFn();
+ assert.isObject(instance.$items);
+ assert.lengthOf(instance.$items, 1);
+ assert.isString(instance.$items.jquery);
+ assert.strictEqual(instance.$items.attr('id'), 'items');
+ });
+ });
+
+ describe('.setItems()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.setItems));
+ });
+
+ it('publishes view.changed', function () {
+ var instance = this.applyFn();
+ instance.setItems();
+ assert.isTrue(this.xEvent.pub.calledTwice);
+ assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed');
+ });
+ });
+
+ describe('.changeItems()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.changeItems));
+ });
+
+ it('publishes view.changed', function () {
+ var instance = this.applyFn();
+ instance.setItems();
+ assert.isTrue(this.xEvent.pub.calledTwice);
+ assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed');
+ });
+ });
+
+ describe('.setLocation()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.setLocation));
+ });
+
+ it('publishes view.changed', function () {
+ var instance = this.applyFn();
+ instance.setItems();
+ assert.isTrue(this.xEvent.pub.calledTwice);
+ assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed');
+ });
+ });
+
+ describe('.setHint()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.setHint));
+ });
+
+ it('sets correct class to #view-hint', function () {
+ var key = uniq.id();
+ var instance = this.applyFn();
+ instance.setHint(key);
+ assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key);
+ });
+
+ it('removes all other classes from #view-hint', function () {
+ var key = uniq.id();
+ var instance = this.applyFn();
+ $('#view-hint').addClass('a');
+ instance.setHint(key);
+ assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key);
+ });
+ });
+
+ describe('.getModes()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.getModes));
+ });
+ });
+
+ describe('.getMode()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.getMode));
+ });
+ });
+
+ describe('.setMode()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.setMode));
+ });
+
+ it('.setMode(\'details\') changes #view class to .view-details', function () {
+ this.xSettings.view.modes = ['details', 'grid', 'icons'];
+ var instance = this.applyFn();
+ instance.setMode('details');
+ assert.isTrue($('#view').hasClass('view-details'));
+ assert.isFalse($('#view').hasClass('view-grid'));
+ assert.isFalse($('#view').hasClass('view-icons'));
+ });
+
+ it('.setMode(\'grid\') changes #view class to .view-grid', function () {
+ this.xSettings.view.modes = ['details', 'grid', 'icons'];
+ var instance = this.applyFn();
+ instance.setMode('grid');
+ assert.isFalse($('#view').hasClass('view-details'));
+ assert.isTrue($('#view').hasClass('view-grid'));
+ assert.isFalse($('#view').hasClass('view-icons'));
+ });
+
+ it('.setMode(\'icons\') changes #view class to .view-icons', function () {
+ this.xSettings.view.modes = ['details', 'grid', 'icons'];
+ var instance = this.applyFn();
+ instance.setMode('icons');
+ assert.isFalse($('#view').hasClass('view-details'));
+ assert.isFalse($('#view').hasClass('view-grid'));
+ assert.isTrue($('#view').hasClass('view-icons'));
+ });
+ });
+
+ describe('.getSizes()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.getSizes));
+ });
+
+ it('returns sorted sizes', function () {
+ this.xSettings.view.sizes = [20, 60, 40];
+ var instance = this.applyFn();
+ assert.deepEqual(instance.getSizes(), [20, 40, 60]);
+ });
+
+ it('returns sorted sizes', function () {
+ this.xSettings.view.sizes = [60, 40, 20];
+ var instance = this.applyFn();
+ assert.deepEqual(instance.getSizes(), [20, 40, 60]);
+ });
+ });
+
+ describe('.getSize()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.getSize));
+ });
+ });
+
+ describe('.setSize()', function () {
+ it('is function', function () {
+ var instance = this.applyFn();
+ assert.isTrue(_.isFunction(instance.setSize));
+ });
+
+ it('.setSize(20) changes #view class to .view-size-20', function () {
+ this.xSettings.view.sizes = [20, 40, 60];
+ var instance = this.applyFn();
+ instance.setSize(20);
+ assert.isTrue($('#view').hasClass('view-size-20'), 20);
+ assert.isFalse($('#view').hasClass('view-size-40'), 40);
+ assert.isFalse($('#view').hasClass('view-size-60'), 60);
+ });
+
+ it('.setSize(40) changes #view class to .view-size-40', function () {
+ this.xSettings.view.sizes = [20, 40, 60];
+ var instance = this.applyFn();
+ instance.setSize(20);
+ instance.setSize(40);
+ assert.isFalse($('#view').hasClass('view-size-20'), 20);
+ assert.isTrue($('#view').hasClass('view-size-40'), 40);
+ assert.isFalse($('#view').hasClass('view-size-60'), 60);
+ });
+
+ it('.setSize(60) changes #view class to .view-size-60', function () {
+ this.xSettings.view.sizes = [20, 40, 60];
+ var instance = this.applyFn();
+ instance.setSize(20);
+ instance.setSize(60);
+ assert.isFalse($('#view').hasClass('view-size-20'), 20);
+ assert.isFalse($('#view').hasClass('view-size-40'), 40);
+ assert.isTrue($('#view').hasClass('view-size-60'), 60);
+ });
+ });
+
+ // describe('._.createHtml()', function () {
+ // before(function () {
+ // this.createItem = function () {
+ // return {
+ // isFolder: sinon.stub().returns(false),
+ // label: uniq.id(),
+ // time: 0,
+ // size: 0,
+ // type: uniq.id(),
+ // isManaged: false,
+ // icon: null,
+ // isCurrentParentFolder: sinon.stub().returns(false)
+ // };
+ // };
+ // });
+
+ // it('is function', function () {
+ // var instance = this.applyFn();
+ // assert.isFunction(instance._.createHtml);
+ // });
+
+ // it('returns jQuery instance of single HTML element', function () {
+ // var item = this.createItem();
+ // var instance = this.applyFn();
+ // var $item = instance._.createHtml(item);
+ // assert.isObject($item);
+ // assert.lengthOf($item, 1);
+ // assert.isString($item.jquery);
+ // });
+
+ // it('$item.data(\'item\') is back reference to item', function () {
+ // var item = this.createItem();
+ // var instance = this.applyFn();
+ // var $item = instance._.createHtml(item);
+ // assert.strictEqual($item.data('item'), item);
+ // });
+
+ // it('sets item.$view as reference to $item', function () {
+ // var item = this.createItem();
+ // var instance = this.applyFn();
+ // var $item = instance._.createHtml(item);
+ // assert.strictEqual(item.$view, $item);
+ // });
+ // });
});
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xContent.$el = $('
').appendTo('body');
- });
-
- 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 object with 12 properties', function () {
-
- var instance = this.applyFn();
- assert.isPlainObject(instance);
- assert.lengthOfKeys(instance, 12);
- });
-
- it('adds HTML #view to #content', function () {
-
- this.applyFn();
- assert.lengthOf($('#content > #view'), 1);
- });
-
- it('adds HTML #items to #view', function () {
-
- this.applyFn();
- assert.lengthOf($('#view > #items'), 1);
- });
-
- it('adds HTML #view-hint to #view', function () {
-
- this.applyFn();
- assert.lengthOf($('#view > #view-hint'), 1);
- });
-
- it('adds style to head', function () {
-
- var styleTagCount = $('head > style').length;
- this.applyFn();
- assert.lengthOf($('head > style'), styleTagCount + 1);
- });
-
- it('style contains possibly correct text', function () {
-
- this.xSettings.sizes = [20];
- this.applyFn();
- var text = $('head > style').eq(0).text();
- assert.isTrue(text.indexOf('#view.view-details.view-size-20 ') >= 0);
- assert.isTrue(text.indexOf('#view.view-grid.view-size-20 ') >= 0);
- assert.isTrue(text.indexOf('#view.view-icons.view-size-20 ') >= 0);
- });
-
- it('sets default metric', function () {
-
- this.applyFn();
- assert.isTrue(this.xFormat.setDefaultMetric.calledOnce);
- });
-
- it('subscribes to 2 events', function () {
-
- this.applyFn();
- assert.isTrue(this.xEvent.sub.calledTwice);
- });
-
- 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]);
- });
-
- it('subscribes to location.refreshed', function () {
-
- this.applyFn();
- assert.strictEqual(this.xEvent.sub.secondCall.args[0], 'location.refreshed');
- assert.isFunction(this.xEvent.sub.secondCall.args[1]);
- });
- });
-
- describe('.$el', function () {
-
- it('is $(\'#view\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$el);
- assert.lengthOf(instance.$el, 1);
- assert.isString(instance.$el.jquery);
- assert.strictEqual(instance.$el.attr('id'), 'view');
- });
- });
-
- describe('.$items', function () {
-
- it('is $(\'#items\')', function () {
-
- var instance = this.applyFn();
- assert.isObject(instance.$items);
- assert.lengthOf(instance.$items, 1);
- assert.isString(instance.$items.jquery);
- assert.strictEqual(instance.$items.attr('id'), 'items');
- });
- });
-
- describe('.setItems()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.setItems));
- });
-
- it('publishes view.changed', function () {
-
- var instance = this.applyFn();
- instance.setItems();
- assert.isTrue(this.xEvent.pub.calledTwice);
- assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed');
- });
- });
-
- describe('.changeItems()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.changeItems));
- });
-
- it('publishes view.changed', function () {
-
- var instance = this.applyFn();
- instance.setItems();
- assert.isTrue(this.xEvent.pub.calledTwice);
- assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed');
- });
- });
-
- describe('.setLocation()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.setLocation));
- });
-
- it('publishes view.changed', function () {
-
- var instance = this.applyFn();
- instance.setItems();
- assert.isTrue(this.xEvent.pub.calledTwice);
- assert.strictEqual(this.xEvent.pub.lastCall.args[0], 'view.changed');
- });
- });
-
- describe('.setHint()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.setHint));
- });
-
- it('sets correct class to #view-hint', function () {
-
- var key = uniq.id();
- var instance = this.applyFn();
- instance.setHint(key);
- assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key);
- });
-
- it('removes all other classes from #view-hint', function () {
-
- var key = uniq.id();
- var instance = this.applyFn();
- $('#view-hint').addClass('a');
- instance.setHint(key);
- assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key);
- });
- });
-
- describe('.getModes()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.getModes));
- });
- });
-
- describe('.getMode()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.getMode));
- });
- });
-
- describe('.setMode()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.setMode));
- });
-
- it('.setMode(\'details\') changes #view class to .view-details', function () {
-
- this.xSettings.view.modes = ['details', 'grid', 'icons'];
- var instance = this.applyFn();
- instance.setMode('details');
- assert.isTrue($('#view').hasClass('view-details'));
- assert.isFalse($('#view').hasClass('view-grid'));
- assert.isFalse($('#view').hasClass('view-icons'));
- });
-
- it('.setMode(\'grid\') changes #view class to .view-grid', function () {
-
- this.xSettings.view.modes = ['details', 'grid', 'icons'];
- var instance = this.applyFn();
- instance.setMode('grid');
- assert.isFalse($('#view').hasClass('view-details'));
- assert.isTrue($('#view').hasClass('view-grid'));
- assert.isFalse($('#view').hasClass('view-icons'));
- });
-
- it('.setMode(\'icons\') changes #view class to .view-icons', function () {
-
- this.xSettings.view.modes = ['details', 'grid', 'icons'];
- var instance = this.applyFn();
- instance.setMode('icons');
- assert.isFalse($('#view').hasClass('view-details'));
- assert.isFalse($('#view').hasClass('view-grid'));
- assert.isTrue($('#view').hasClass('view-icons'));
- });
- });
-
- describe('.getSizes()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.getSizes));
- });
-
- it('returns sorted sizes', function () {
-
- this.xSettings.view.sizes = [20, 60, 40];
- var instance = this.applyFn();
- assert.deepEqual(instance.getSizes(), [20, 40, 60]);
- });
-
- it('returns sorted sizes', function () {
-
- this.xSettings.view.sizes = [60, 40, 20];
- var instance = this.applyFn();
- assert.deepEqual(instance.getSizes(), [20, 40, 60]);
- });
- });
-
- describe('.getSize()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.getSize));
- });
- });
-
- describe('.setSize()', function () {
-
- it('is function', function () {
-
- var instance = this.applyFn();
- assert.isTrue(_.isFunction(instance.setSize));
- });
-
- it('.setSize(20) changes #view class to .view-size-20', function () {
-
- this.xSettings.view.sizes = [20, 40, 60];
- var instance = this.applyFn();
- instance.setSize(20);
- assert.isTrue($('#view').hasClass('view-size-20'), 20);
- assert.isFalse($('#view').hasClass('view-size-40'), 40);
- assert.isFalse($('#view').hasClass('view-size-60'), 60);
- });
-
- it('.setSize(40) changes #view class to .view-size-40', function () {
-
- this.xSettings.view.sizes = [20, 40, 60];
- var instance = this.applyFn();
- instance.setSize(20);
- instance.setSize(40);
- assert.isFalse($('#view').hasClass('view-size-20'), 20);
- assert.isTrue($('#view').hasClass('view-size-40'), 40);
- assert.isFalse($('#view').hasClass('view-size-60'), 60);
- });
-
- it('.setSize(60) changes #view class to .view-size-60', function () {
-
- this.xSettings.view.sizes = [20, 40, 60];
- var instance = this.applyFn();
- instance.setSize(20);
- instance.setSize(60);
- assert.isFalse($('#view').hasClass('view-size-20'), 20);
- assert.isFalse($('#view').hasClass('view-size-40'), 40);
- assert.isTrue($('#view').hasClass('view-size-60'), 60);
- });
- });
-
- // describe('._.createHtml()', function () {
-
- // before(function () {
-
- // this.createItem = function () {
-
- // return {
- // isFolder: sinon.stub().returns(false),
- // label: uniq.id(),
- // time: 0,
- // size: 0,
- // type: uniq.id(),
- // isManaged: false,
- // icon: null,
- // isCurrentParentFolder: sinon.stub().returns(false)
- // };
- // };
- // });
-
- // it('is function', function () {
-
- // var instance = this.applyFn();
- // assert.isFunction(instance._.createHtml);
- // });
-
- // it('returns jQuery instance of single HTML element', function () {
-
- // var item = this.createItem();
- // var instance = this.applyFn();
- // var $item = instance._.createHtml(item);
- // assert.isObject($item);
- // assert.lengthOf($item, 1);
- // assert.isString($item.jquery);
- // });
-
- // it('$item.data(\'item\') is back reference to item', function () {
-
- // var item = this.createItem();
- // var instance = this.applyFn();
- // var $item = instance._.createHtml(item);
- // assert.strictEqual($item.data('item'), item);
- // });
-
- // it('sets item.$view as reference to $item', function () {
-
- // var item = this.createItem();
- // var instance = this.applyFn();
- // var $item = instance._.createHtml(item);
- // assert.strictEqual(item.$view, $item);
- // });
- // });
-});
-
}());
diff --git a/test/tests/unit/view/viewmode.js b/test/tests/unit/view/viewmode.js
index b117f14d..ad0dd6a2 100644
--- a/test/tests/unit/view/viewmode.js
+++ b/test/tests/unit/view/viewmode.js
@@ -1,219 +1,189 @@
(function () {
-'use strict';
+ var ID = 'view/viewmode';
+ var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'];
-var ID = 'view/viewmode';
-var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'];
+ describe('module \'' + ID + '\'', function () {
+ before(function () {
+ this.definition = modulejs._private.definitions[ID];
-describe('module \'' + ID + '\'', function () {
+ this.xEvent = {
+ sub: sinon.stub(),
+ pub: sinon.stub()
+ };
+ this.xResource = {
+ image: sinon.stub().returns(uniq.path('-image.png'))
+ };
+ this.xSettings = {view: {
+ modeToggle: false
+ }};
+ this.xSidebar = {$el: null};
+ this.xTopbar = {$el: null};
+ this.xView = {
+ $el: null,
+ getModes: sinon.stub().returns(['details', 'grid', 'icons']),
+ getMode: sinon.stub(),
+ setMode: sinon.stub(),
+ getSizes: sinon.stub().returns([20, 30, 40]),
+ getSize: sinon.stub(),
+ setSize: sinon.stub()
+ };
- before(function () {
+ this.applyFn = function () {
+ this.xEvent.sub.reset();
+ this.xEvent.pub.reset();
+ this.xResource.image.reset();
+ this.xView.getModes.reset();
+ this.xView.getMode.reset();
+ this.xView.setMode.reset();
+ this.xView.getSizes.reset();
+ this.xView.getSize.reset();
+ this.xView.setSize.reset();
- this.definition = modulejs._private.definitions[ID];
-
- this.xEvent = {
- sub: sinon.stub(),
- pub: sinon.stub()
- };
- this.xResource = {
- image: sinon.stub().returns(uniq.path('-image.png'))
- };
- this.xSettings = {view: {
- modeToggle: false
- }};
- this.xSidebar = {$el: null};
- this.xTopbar = {$el: null};
- this.xView = {
- $el: null,
- getModes: sinon.stub().returns(['details', 'grid', 'icons']),
- getMode: sinon.stub(),
- setMode: sinon.stub(),
- getSizes: sinon.stub().returns([20, 30, 40]),
- getSize: sinon.stub(),
- setSize: sinon.stub()
- };
-
- this.applyFn = function () {
-
- this.xEvent.sub.reset();
- this.xEvent.pub.reset();
- this.xResource.image.reset();
- this.xView.getModes.reset();
- this.xView.getMode.reset();
- this.xView.setMode.reset();
- this.xView.getSizes.reset();
- this.xView.getSize.reset();
- this.xView.setSize.reset();
-
- return this.definition.fn(_, $, this.xEvent, this.xResource, this.xSettings, this.xSidebar, this.xTopbar, this.xView);
- };
- });
-
- after(function () {
-
- util.restoreHtml();
- });
-
- beforeEach(function () {
-
- util.restoreHtml();
- this.xSidebar.$el = $('').appendTo('body');
- this.xTopbar.$el = $('
').appendTo('body');
- this.xView.$el = $('
').appendTo('body');
- });
-
- describe('definition', function () {
-
- it('is defined', function () {
-
- assert.isPlainObject(this.definition);
+ return this.definition.fn(_, $, this.xEvent, this.xResource, this.xSettings, this.xSidebar, this.xTopbar, this.xView);
+ };
});
- it('has correct id', function () {
-
- assert.strictEqual(this.definition.id, ID);
+ after(function () {
+ util.restoreHtml();
});
- it('requires correct', function () {
-
- assert.deepEqual(this.definition.deps, DEPS);
+ beforeEach(function () {
+ util.restoreHtml();
+ this.xSidebar.$el = $('').appendTo('body');
+ this.xTopbar.$el = $('
').appendTo('body');
+ this.xView.$el = $('
').appendTo('body');
});
- it('args for each request', function () {
+ describe('definition', function () {
+ it('is defined', function () {
+ assert.isPlainObject(this.definition);
+ });
- assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
+ 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();
+ });
});
- it('has no instance', function () {
+ describe('application', function () {
+ it('returns undefined', function () {
+ var instance = this.applyFn();
+ assert.isUndefined(instance);
+ });
- assert.notProperty(modulejs._private.instances, ID);
+ it('adds HTML #viewmode-settings to #sidebar', function () {
+ this.applyFn();
+ assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
+ });
+
+ it('adds HTML #viewmode-details to #viewmode-settings', function () {
+ this.applyFn();
+ assert.lengthOf($('#viewmode-settings > #viewmode-details'), 1);
+ });
+
+ it('adds HTML #viewmode-grid to #viewmode-settings', function () {
+ this.applyFn();
+ assert.lengthOf($('#viewmode-settings > #viewmode-grid'), 1);
+ });
+
+ it('adds HTML #viewmode-icons to #viewmode-settings', function () {
+ this.applyFn();
+ assert.lengthOf($('#viewmode-settings > #viewmode-icons'), 1);
+ });
+
+ it('adds HTML #viewmode-size to #viewmode-settings', function () {
+ this.applyFn();
+ assert.lengthOf($('#viewmode-settings > #viewmode-size'), 1);
+ });
+
+ it('does not add HTML #viewmode-details, #viewmode-grid, #viewmode-icons when only one mode', function () {
+ this.xView.getModes.returns(['details']);
+ this.applyFn();
+ assert.lengthOf($('#viewmode-details'), 0);
+ assert.lengthOf($('#viewmode-grid'), 0);
+ assert.lengthOf($('#viewmode-icons'), 0);
+ });
+
+ it('does not add HTML #viewmode-size when only one size', function () {
+ this.xView.getSizes.returns([20]);
+ this.applyFn();
+ assert.lengthOf($('#viewmode-size'), 0);
+ });
});
- it('inits without errors', function () {
+ describe('works', function () {
+ it('clicking #viewmode-details triggers view.setMode(\'details\')', function () {
+ this.xView.getModes.returns(['details', 'grid', 'icons']);
+ this.applyFn();
+ $('#viewmode-details').trigger('click');
+ assert.isTrue(this.xView.setMode.calledOnce);
+ assert.deepEqual(this.xView.setMode.lastCall.args, ['details']);
+ });
- this.applyFn();
+ it('clicking #viewmode-grid triggers view.setMode(\'grid\')', function () {
+ this.xView.getModes.returns(['details', 'grid', 'icons']);
+ this.applyFn();
+ $('#viewmode-grid').trigger('click');
+ assert.isTrue(this.xView.setMode.calledOnce);
+ assert.deepEqual(this.xView.setMode.lastCall.args, ['grid']);
+ });
+
+ it('clicking #viewmode-icons triggers view.setMode(\'icons\')', function () {
+ this.xView.getModes.returns(['details', 'grid', 'icons']);
+ this.applyFn();
+ $('#viewmode-icons').trigger('click');
+ assert.isTrue(this.xView.setMode.calledOnce);
+ assert.deepEqual(this.xView.setMode.lastCall.args, ['icons']);
+ });
+
+ it('changing #viewmode-size triggers view.setSize(*)', function () {
+ this.xView.getSizes.returns([20, 40, 60]);
+ this.applyFn();
+
+ $('#viewmode-size').val(0).trigger('change');
+ assert.isTrue(this.xView.setSize.calledOnce);
+ assert.deepEqual(this.xView.setSize.lastCall.args, [20]);
+
+ $('#viewmode-size').val(1).trigger('change');
+ assert.isTrue(this.xView.setSize.calledTwice);
+ assert.deepEqual(this.xView.setSize.lastCall.args, [40]);
+
+ $('#viewmode-size').val(2).trigger('change');
+ assert.isTrue(this.xView.setSize.calledThrice);
+ assert.deepEqual(this.xView.setSize.lastCall.args, [60]);
+ });
+
+ it('inputing #viewmode-size triggers view.setSize(*)', function () {
+ this.xView.getSizes.returns([20, 40, 60]);
+ this.applyFn();
+
+ $('#viewmode-size').val(0).trigger('input');
+ assert.isTrue(this.xView.setSize.calledOnce);
+ assert.deepEqual(this.xView.setSize.lastCall.args, [20]);
+
+ $('#viewmode-size').val(1).trigger('input');
+ assert.isTrue(this.xView.setSize.calledTwice);
+ assert.deepEqual(this.xView.setSize.lastCall.args, [40]);
+
+ $('#viewmode-size').val(2).trigger('input');
+ assert.isTrue(this.xView.setSize.calledThrice);
+ assert.deepEqual(this.xView.setSize.lastCall.args, [60]);
+ });
});
});
-
- describe('application', function () {
-
- it('returns undefined', function () {
-
- var instance = this.applyFn();
- assert.isUndefined(instance);
- });
-
- it('adds HTML #viewmode-settings to #sidebar', function () {
-
- this.applyFn();
- assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
- });
-
- it('adds HTML #viewmode-details to #viewmode-settings', function () {
-
- this.applyFn();
- assert.lengthOf($('#viewmode-settings > #viewmode-details'), 1);
- });
-
- it('adds HTML #viewmode-grid to #viewmode-settings', function () {
-
- this.applyFn();
- assert.lengthOf($('#viewmode-settings > #viewmode-grid'), 1);
- });
-
- it('adds HTML #viewmode-icons to #viewmode-settings', function () {
-
- this.applyFn();
- assert.lengthOf($('#viewmode-settings > #viewmode-icons'), 1);
- });
-
- it('adds HTML #viewmode-size to #viewmode-settings', function () {
-
- this.applyFn();
- assert.lengthOf($('#viewmode-settings > #viewmode-size'), 1);
- });
-
- it('does not add HTML #viewmode-details, #viewmode-grid, #viewmode-icons when only one mode', function () {
-
- this.xView.getModes.returns(['details']);
- this.applyFn();
- assert.lengthOf($('#viewmode-details'), 0);
- assert.lengthOf($('#viewmode-grid'), 0);
- assert.lengthOf($('#viewmode-icons'), 0);
- });
-
- it('does not add HTML #viewmode-size when only one size', function () {
-
- this.xView.getSizes.returns([20]);
- this.applyFn();
- assert.lengthOf($('#viewmode-size'), 0);
- });
- });
-
- describe('works', function () {
-
- it('clicking #viewmode-details triggers view.setMode(\'details\')', function () {
-
- this.xView.getModes.returns(['details', 'grid', 'icons']);
- this.applyFn();
- $('#viewmode-details').trigger('click');
- assert.isTrue(this.xView.setMode.calledOnce);
- assert.deepEqual(this.xView.setMode.lastCall.args, ['details']);
- });
-
- it('clicking #viewmode-grid triggers view.setMode(\'grid\')', function () {
-
- this.xView.getModes.returns(['details', 'grid', 'icons']);
- this.applyFn();
- $('#viewmode-grid').trigger('click');
- assert.isTrue(this.xView.setMode.calledOnce);
- assert.deepEqual(this.xView.setMode.lastCall.args, ['grid']);
- });
-
- it('clicking #viewmode-icons triggers view.setMode(\'icons\')', function () {
-
- this.xView.getModes.returns(['details', 'grid', 'icons']);
- this.applyFn();
- $('#viewmode-icons').trigger('click');
- assert.isTrue(this.xView.setMode.calledOnce);
- assert.deepEqual(this.xView.setMode.lastCall.args, ['icons']);
- });
-
- it('changing #viewmode-size triggers view.setSize(*)', function () {
-
- this.xView.getSizes.returns([20, 40, 60]);
- this.applyFn();
-
- $('#viewmode-size').val(0).trigger('change');
- assert.isTrue(this.xView.setSize.calledOnce);
- assert.deepEqual(this.xView.setSize.lastCall.args, [20]);
-
- $('#viewmode-size').val(1).trigger('change');
- assert.isTrue(this.xView.setSize.calledTwice);
- assert.deepEqual(this.xView.setSize.lastCall.args, [40]);
-
- $('#viewmode-size').val(2).trigger('change');
- assert.isTrue(this.xView.setSize.calledThrice);
- assert.deepEqual(this.xView.setSize.lastCall.args, [60]);
- });
-
- it('inputing #viewmode-size triggers view.setSize(*)', function () {
-
- this.xView.getSizes.returns([20, 40, 60]);
- this.applyFn();
-
- $('#viewmode-size').val(0).trigger('input');
- assert.isTrue(this.xView.setSize.calledOnce);
- assert.deepEqual(this.xView.setSize.lastCall.args, [20]);
-
- $('#viewmode-size').val(1).trigger('input');
- assert.isTrue(this.xView.setSize.calledTwice);
- assert.deepEqual(this.xView.setSize.lastCall.args, [40]);
-
- $('#viewmode-size').val(2).trigger('input');
- assert.isTrue(this.xView.setSize.calledThrice);
- assert.deepEqual(this.xView.setSize.lastCall.args, [60]);
- });
- });
-});
-
}());
diff --git a/test/util/assert.js b/test/util/assert.js
index f5584543..88264001 100644
--- a/test/util/assert.js
+++ b/test/util/assert.js
@@ -1,17 +1,12 @@
(function () {
-'use strict';
+ var assert = window.chai.assert;
-var assert = chai.assert;
-
-assert.lengthOfKeys = function (val, count, msg) {
-
- var keyCount = _.keys(val).length;
- assert(keyCount === count, msg ? msg : 'expected ' + val + ' to have ' + count + ' keys, but has ' + keyCount);
-};
-
-assert.isPlainObject = function (val, msg) {
-
- assert($.isPlainObject(val), msg ? msg : 'expected ' + val + ' to be a plain Object');
-};
+ assert.lengthOfKeys = function (val, count, msg) {
+ var keyCount = _.keys(val).length;
+ assert(keyCount === count, msg ? msg : 'expected ' + val + ' to have ' + count + ' keys, but has ' + keyCount);
+ };
+ assert.isPlainObject = function (val, msg) {
+ assert($.isPlainObject(val), msg ? msg : 'expected ' + val + ' to be a plain Object');
+ };
}());
diff --git a/test/util/mocha.js b/test/util/mocha.js
index 158fd2d7..862d74e2 100644
--- a/test/util/mocha.js
+++ b/test/util/mocha.js
@@ -1,112 +1,107 @@
(function () {
-'use strict';
-
-var showOnlyFailures = false;
-var template =
- '
';
-var $mochaBar = $(template);
-var $mochaStats = $mochaBar.find('.stats');
-var $mochaProgress = $mochaBar.find('.progress');
-
-
-function toggleFailureFilter(ev) {
- ev.stopImmediatePropagation();
-
- showOnlyFailures = !showOnlyFailures;
- if (showOnlyFailures) {
- $('.suite, .test').hide();
- $('.suite.fail, .test.fail').show();
- } else {
- $('.suite, .test').show();
- }
-}
-
-function addSuiteStats() {
- var $suite = $(this);
-
- var tests = $suite.find('.test').length;
- var passed = $suite.find('.test.pass').length;
- var failed = tests - passed;
-
- var $header = $suite.find('> h1 a');
- var $list = $suite.find('> ul');
- var $count = $('
' + passed + '' + failed + '');
- var $toggle = $('
-');
- var visible = true;
-
- $toggle.on('click', function (ev) {
+ var showOnlyFailures = false;
+ var template =
+ '
';
+ var $mochaBar = $(template);
+ var $mochaStats = $mochaBar.find('.stats');
+ var $mochaProgress = $mochaBar.find('.progress');
+ function toggleFailureFilter(ev) {
ev.stopImmediatePropagation();
- visible = !visible;
- if (visible) {
- $toggle.text('-');
- $list.show();
+ showOnlyFailures = !showOnlyFailures;
+ if (showOnlyFailures) {
+ $('.suite, .test').hide();
+ $('.suite.fail, .test.fail').show();
} else {
- $toggle.text('+');
- $list.hide();
+ $('.suite, .test').show();
}
- });
-
- if (!failed) {
- $count.find('.failed').remove();
}
- $suite.addClass(tests === passed ? 'pass' : 'fail');
- // $suite.append($toggle);
- $header.append($count);
-}
+ function addSuiteStats() {
+ var $suite = $(this);
-function fixCodeFormatting() {
- var $code = $(this);
- $code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
-}
+ var tests = $suite.find('.test').length;
+ var passed = $suite.find('.test.pass').length;
+ var failed = tests - passed;
+ var $header = $suite.find('> h1 a');
+ var $list = $suite.find('> ul');
+ var $count = $('
' + passed + '' + failed + '');
+ var $toggle = $('
-');
+ var visible = true;
-function onEnd() {
- var runner = this;
- var failed = runner.stats.failures > 0;
- var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
+ $toggle.on('click', function (ev) {
+ ev.stopImmediatePropagation();
- if (failed) {
- $mochaStats.on('click', toggleFailureFilter);
+ visible = !visible;
+ if (visible) {
+ $toggle.text('-');
+ $list.show();
+ } else {
+ $toggle.text('+');
+ $list.hide();
+ }
+ });
+
+ if (!failed) {
+ $count.find('.failed').remove();
+ }
+
+ $suite.addClass(tests === passed ? 'pass' : 'fail');
+ // $suite.append($toggle);
+ $header.append($count);
}
- $mochaBar.addClass(failed ? 'fail' : 'pass');
- $mochaProgress.hide();
- $mochaStats.text(stats);
- $('#mocha-report .suite').each(addSuiteStats);
- $('#mocha-report code').each(fixCodeFormatting);
-}
-
-function onTest() {
- var runner = this;
- var percent = 100.0 * runner.stats.tests / runner.total;
- var stats = ((new Date().getTime() - runner.stats.start) / 1000.0).toFixed(3) + 's';
-
- if (runner.stats.failures) {
- $mochaBar.addClass('fail');
+ function fixCodeFormatting() {
+ var $code = $(this);
+ $code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
}
- $mochaProgress.css('width', (100 - percent) + '%');
- $mochaStats.text(stats);
-}
-function setupMocha() {
- window.assert = chai.assert;
- mocha.setup('bdd');
- $(function () { $mochaBar.appendTo('#mocha'); });
-}
-function runMocha() {
- mocha.run().on('test', onTest).on('end', onEnd);
-}
+ function onEnd() {
+ var runner = this;
+ var failed = runner.stats.failures > 0;
+ var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
-window.util = window.util || {};
-window.util.setupMocha = setupMocha;
-window.util.runMocha = runMocha;
+ if (failed) {
+ $mochaStats.on('click', toggleFailureFilter);
+ }
+ $mochaBar.addClass(failed ? 'fail' : 'pass');
+ $mochaProgress.hide();
+ $mochaStats.text(stats);
+ $('#mocha-report .suite').each(addSuiteStats);
+ $('#mocha-report code').each(fixCodeFormatting);
+ }
+
+ function onTest() {
+ var runner = this;
+ var percent = 100.0 * runner.stats.tests / runner.total;
+ var stats = ((new Date().getTime() - runner.stats.start) / 1000.0).toFixed(3) + 's';
+
+ if (runner.stats.failures) {
+ $mochaBar.addClass('fail');
+ }
+ $mochaProgress.css('width', 100 - percent + '%');
+ $mochaStats.text(stats);
+ }
+
+ function setupMocha() {
+ window.assert = window.chai.assert;
+ mocha.setup('bdd');
+ $(function () { $mochaBar.appendTo('#mocha'); });
+ }
+
+ function runMocha() {
+ mocha.run().on('test', onTest).on('end', onEnd);
+ }
+
+ window.util = window.util || {};
+ window.util.setupMocha = setupMocha;
+ window.util.runMocha = runMocha;
}());
diff --git a/test/util/modulejs.js b/test/util/modulejs.js
index 32b03d7d..7cc9a111 100644
--- a/test/util/modulejs.js
+++ b/test/util/modulejs.js
@@ -1,21 +1,15 @@
(function () {
-'use strict';
+ function clearModulejs() {
+ _.each(modulejs._private.instances, function (val, key) {
+ delete modulejs._private.instances[key];
+ });
+ }
-function clearModulejs() {
-
- _.each(modulejs._private.instances, function (val, key) {
-
- delete modulejs._private.instances[key];
- });
-}
-
-function mockConfigModule() {
-
- modulejs.define('config', window.uniq.obj());
-}
-
-window.util = window.util || {};
-window.util.clearModulejs = clearModulejs;
-window.util.mockConfigModule = mockConfigModule;
+ function mockConfigModule() {
+ modulejs.define('config', window.uniq.obj());
+ }
+ window.util = window.util || {};
+ window.util.clearModulejs = clearModulejs;
+ window.util.mockConfigModule = mockConfigModule;
}());
diff --git a/test/util/pin.js b/test/util/pin.js
index 51d18811..831d3f1e 100644
--- a/test/util/pin.js
+++ b/test/util/pin.js
@@ -1,38 +1,33 @@
(function () {
-'use strict';
+ var title;
+ var htmlId;
+ var htmlClasses;
+ var bodyId;
+ var bodyClasses;
+ var $pinnedElements;
-var title;
-var htmlId;
-var htmlClasses;
-var bodyId;
-var bodyClasses;
-var $pinnedElements;
-
-function pinHtml() {
-
- title = document.title;
- htmlId = $('html').attr('id');
- htmlClasses = $('html').attr('class');
- bodyId = $('body').attr('id');
- bodyClasses = $('body').attr('class');
- $pinnedElements = $('head,body').children();
-}
-
-function restoreHtml() {
-
- document.title = title;
- $('html').attr('id', htmlId);
- $('html').attr('class', htmlClasses);
- $('body').attr('id', bodyId);
- $('body').attr('class', bodyClasses);
- $('head,body').children().not($pinnedElements).remove();
- if (window.localStorage && window.localStorage.clear) {
- window.localStorage.clear();
+ function pinHtml() {
+ title = document.title;
+ htmlId = $('html').attr('id');
+ htmlClasses = $('html').attr('class');
+ bodyId = $('body').attr('id');
+ bodyClasses = $('body').attr('class');
+ $pinnedElements = $('head,body').children();
}
-}
-window.util = window.util || {};
-window.util.pinHtml = pinHtml;
-window.util.restoreHtml = restoreHtml;
+ function restoreHtml() {
+ document.title = title;
+ $('html').attr('id', htmlId);
+ $('html').attr('class', htmlClasses);
+ $('body').attr('id', bodyId);
+ $('body').attr('class', bodyClasses);
+ $('head,body').children().not($pinnedElements).remove();
+ if (window.localStorage && window.localStorage.clear) {
+ window.localStorage.clear();
+ }
+ }
+ window.util = window.util || {};
+ window.util.pinHtml = pinHtml;
+ window.util.restoreHtml = restoreHtml;
}());