diff --git a/src/_h5ai/client/js/scripts.js b/src/_h5ai/client/js/scripts.js
index f950c63f..e1b8b4a4 100644
--- a/src/_h5ai/client/js/scripts.js
+++ b/src/_h5ai/client/js/scripts.js
@@ -10,8 +10,8 @@
'use strict';
var win = window;
- modulejs.define('$', function () { return win.jQuery; });
modulejs.define('_', function () { return win._; });
+ modulejs.define('$', function () { return win.jQuery; });
modulejs.define('marked', function () { return win.marked; });
modulejs.define('modernizr', function () { return win.Modernizr; });
modulejs.define('prism', function () { return win.Prism; });
diff --git a/test/tests/unit/boot.js b/test/tests/unit/boot.js
index 273ecdc2..78f21d1a 100644
--- a/test/tests/unit/boot.js
+++ b/test/tests/unit/boot.js
@@ -4,7 +4,7 @@
var ID = 'boot';
var DEPS = ['$'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
@@ -95,7 +95,7 @@ describe('module "' + ID + '"', function () {
assert.isFalse(this.xRequire.called);
});
- it('data-module="test"', function () {
+ it('data-module=\'test\'', function () {
$('').attr('data-module', 'test').appendTo('head');
this.applyFn();
@@ -104,7 +104,7 @@ describe('module "' + ID + '"', function () {
assert.isFalse(this.xRequire.called);
});
- it('data-module="info"', function () {
+ it('data-module=\'info\'', function () {
$('').attr('data-module', 'info').appendTo('head');
@@ -126,7 +126,7 @@ describe('module "' + ID + '"', function () {
assert.deepEqual(this.xRequire.lastCall.args, ['main/info']);
});
- it('data-module="index"', function () {
+ it('data-module=\'index\'', function () {
$('').attr('data-module', 'index').appendTo('head');
@@ -148,7 +148,7 @@ describe('module "' + ID + '"', function () {
assert.deepEqual(this.xRequire.lastCall.args, ['main/index']);
});
- it('"no-browser"-class and no data-module', function () {
+ it('\'no-browser\'-class and no data-module', function () {
$('html').addClass('no-browser');
this.applyFn();
@@ -157,7 +157,7 @@ describe('module "' + ID + '"', function () {
assert.isFalse(this.xRequire.called);
});
- it('"no-browser"-class and data-module="test"', function () {
+ it('\'no-browser\'-class and data-module=\'test\'', function () {
$('html').addClass('no-browser');
$('').attr('data-module', 'test').appendTo('head');
@@ -167,7 +167,7 @@ describe('module "' + ID + '"', function () {
assert.isFalse(this.xRequire.called);
});
- it('"no-browser"-class and data-module="info"', function () {
+ it('\'no-browser\'-class and data-module=\'info\'', function () {
$('html').addClass('no-browser');
$('').attr('data-module', 'info').appendTo('head');
@@ -177,7 +177,7 @@ describe('module "' + ID + '"', function () {
assert.isFalse(this.xRequire.called);
});
- it('"no-browser"-class and data-module="index"', function () {
+ it('\'no-browser\'-class and data-module=\'index\'', function () {
$('html').addClass('no-browser');
$('').attr('data-module', 'index').appendTo('head');
diff --git a/test/tests/unit/config.js b/test/tests/unit/config.js
index 4d522965..18a166fc 100644
--- a/test/tests/unit/config.js
+++ b/test/tests/unit/config.js
@@ -4,7 +4,7 @@
var ID = 'config';
var DEPS = [];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/event.js b/test/tests/unit/core/event.js
index 38a4778b..2a5d0ea5 100644
--- a/test/tests/unit/core/event.js
+++ b/test/tests/unit/core/event.js
@@ -4,7 +4,7 @@
var ID = 'core/event';
var DEPS = ['_'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/format.js b/test/tests/unit/core/format.js
index 7899945a..b21b74a4 100644
--- a/test/tests/unit/core/format.js
+++ b/test/tests/unit/core/format.js
@@ -4,7 +4,7 @@
var ID = 'core/format';
var DEPS = ['_'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
@@ -112,7 +112,7 @@ describe('module "' + ID + '"', function () {
var arg = data[0];
var exp = data[1];
- it('.formatSize(' + arg + ') => "' + exp + '"', function () {
+ it('.formatSize(' + arg + ') => \'' + exp + '\'', function () {
var instance = this.applyFn();
instance.setDefaultMetric(false);
@@ -148,7 +148,7 @@ describe('module "' + ID + '"', function () {
var arg = data[0];
var exp = data[1];
- it('.formatSize(' + arg + ') => "' + exp + '"', function () {
+ it('.formatSize(' + arg + ') => \'' + exp + '\'', function () {
var instance = this.applyFn();
instance.setDefaultMetric(true);
@@ -209,7 +209,7 @@ describe('module "' + ID + '"', function () {
var arg2 = data[1];
var exp = data[2];
- it('.formatDate(' + arg1 + ', ' + arg2 + ') => "' + exp + '"', function () {
+ it('.formatDate(' + 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 016d6875..8946341c 100644
--- a/test/tests/unit/core/langs.js
+++ b/test/tests/unit/core/langs.js
@@ -4,7 +4,7 @@
var ID = 'core/langs';
var DEPS = ['_', 'config'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/location.js b/test/tests/unit/core/location.js
index 1a3dc367..77b83b64 100644
--- a/test/tests/unit/core/location.js
+++ b/test/tests/unit/core/location.js
@@ -4,7 +4,7 @@
var ID = 'core/location';
var DEPS = ['_', 'modernizr', 'core/event', 'core/notify', 'core/settings'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
@@ -111,7 +111,7 @@ describe('module "' + ID + '"', function () {
var arg = data[0];
var exp = data[1];
- it('.forceEncoding("' + arg + '") => "' + exp + '"', function () {
+ it('.forceEncoding(\'' + arg + '\') => \'' + exp + '\'', function () {
var instance = this.applyFn();
assert.strictEqual(instance.forceEncoding(arg), exp);
@@ -199,7 +199,7 @@ describe('module "' + ID + '"', function () {
assert.strictEqual($el.attr('href'), item.absHref);
});
- it('sets target="_blank" for unmanaged folders', function () {
+ it('sets target=\'_blank\' for unmanaged folders', function () {
this.xSettings.unmanagedInNewWindow = true;
@@ -216,7 +216,7 @@ describe('module "' + ID + '"', function () {
assert.strictEqual($el.attr('target'), '_blank');
});
- it('does not set target="_blank" for managed folders', function () {
+ it('does not set target=\'_blank\' for managed folders', function () {
this.xSettings.unmanagedInNewWindow = true;
@@ -233,7 +233,7 @@ describe('module "' + ID + '"', function () {
assert.isUndefined($el.attr('target'));
});
- it('does not set target="_blank" for unmanaged folders if disabled', function () {
+ it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
this.xSettings.unmanagedInNewWindow = false;
diff --git a/test/tests/unit/core/notify.js b/test/tests/unit/core/notify.js
index 8aa9ece2..20a9a5c0 100644
--- a/test/tests/unit/core/notify.js
+++ b/test/tests/unit/core/notify.js
@@ -4,7 +4,7 @@
var ID = 'core/notify';
var DEPS = ['$'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/resource.js b/test/tests/unit/core/resource.js
index c98b373f..97f40308 100644
--- a/test/tests/unit/core/resource.js
+++ b/test/tests/unit/core/resource.js
@@ -4,7 +4,7 @@
var ID = 'core/resource';
var DEPS = ['_', 'config', 'core/settings'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/server.js b/test/tests/unit/core/server.js
index fb31276f..d5c5cf5c 100644
--- a/test/tests/unit/core/server.js
+++ b/test/tests/unit/core/server.js
@@ -5,7 +5,7 @@ var ID = 'core/server';
var DEPS = ['_', '$', 'config', 'core/location'];
var $submitSnap;
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/settings.js b/test/tests/unit/core/settings.js
index e19262e8..7f3736bc 100644
--- a/test/tests/unit/core/settings.js
+++ b/test/tests/unit/core/settings.js
@@ -4,7 +4,7 @@
var ID = 'core/settings';
var DEPS = ['_', 'config'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/store.js b/test/tests/unit/core/store.js
index 909fda3a..f6d27685 100644
--- a/test/tests/unit/core/store.js
+++ b/test/tests/unit/core/store.js
@@ -4,7 +4,7 @@
var ID = 'core/store';
var DEPS = ['modernizr'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/types.js b/test/tests/unit/core/types.js
index 5ade5555..7c9524d6 100644
--- a/test/tests/unit/core/types.js
+++ b/test/tests/unit/core/types.js
@@ -4,7 +4,7 @@
var ID = 'core/types';
var DEPS = ['_', 'config'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/core/util.js b/test/tests/unit/core/util.js
index e5c2178e..73a555a8 100644
--- a/test/tests/unit/core/util.js
+++ b/test/tests/unit/core/util.js
@@ -4,7 +4,7 @@
var ID = 'core/util';
var DEPS = [];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
@@ -81,7 +81,7 @@ describe('module "' + ID + '"', function () {
var arg2 = data[1];
var exp = data[2];
- it('.regularCmpFn("' + arg1 + '", "' + arg2 + '") => "' + exp + '"', function () {
+ it('.regularCmpFn(\'' + arg1 + '\', \'' + arg2 + '\') => \'' + exp + '\'', function () {
var instance = this.applyFn();
assert.strictEqual(instance.regularCmpFn(arg1, arg2), exp);
@@ -111,7 +111,7 @@ describe('module "' + ID + '"', function () {
var arg2 = data[1];
var exp = data[2];
- it('.naturalCmpFn("' + arg1 + '", "' + arg2 + '") => "' + exp + '"', function () {
+ it('.naturalCmpFn(\'' + arg1 + '\', \'' + arg2 + '\') => \'' + exp + '\'', function () {
var instance = this.applyFn();
assert.strictEqual(instance.naturalCmpFn(arg1, arg2), exp);
diff --git a/test/tests/unit/ext/title.js b/test/tests/unit/ext/title.js
new file mode 100644
index 00000000..baaed42e
--- /dev/null
+++ b/test/tests/unit/ext/title.js
@@ -0,0 +1,133 @@
+(function () {
+'use strict';
+
+var ID = 'ext/title';
+var DEPS = ['_', 'core/event', 'core/settings'];
+
+describe('module \'' + ID + '\'', function () {
+
+ before(function () {
+
+ 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);
+ };
+
+ this.titleBak = document.title;
+ this.dummyTitle = util.uniqId();
+ });
+
+ after(function () {
+
+ document.title = this.titleBak;
+ });
+
+ beforeEach(function () {
+
+ document.title = this.dummyTitle;
+ });
+
+ 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 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(String(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 82761815..f645ed63 100644
--- a/test/tests/unit/libs.js
+++ b/test/tests/unit/libs.js
@@ -13,7 +13,7 @@ describe('libs', function () {
_.each(libs, function (lib, id) {
- describe('module "' + id + '"', function () {
+ describe('module \'' + id + '\'', function () {
it('is defined', function () {
diff --git a/test/tests/unit/main/index.js b/test/tests/unit/main/index.js
index 98499f87..a25bf481 100644
--- a/test/tests/unit/main/index.js
+++ b/test/tests/unit/main/index.js
@@ -4,7 +4,7 @@
var ID = 'main/index';
var DEPS = ['_', 'core/event'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/main/info.js b/test/tests/unit/main/info.js
index 92da399b..4e65627b 100644
--- a/test/tests/unit/main/info.js
+++ b/test/tests/unit/main/info.js
@@ -4,7 +4,7 @@
var ID = 'main/info';
var DEPS = ['$', 'config'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/model/item.js b/test/tests/unit/model/item.js
index d0eac3e2..38c6b08d 100644
--- a/test/tests/unit/model/item.js
+++ b/test/tests/unit/model/item.js
@@ -4,7 +4,7 @@
var ID = 'model/item';
var DEPS = ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/view/base.js b/test/tests/unit/view/base.js
index fd0a3dff..ef57eb3a 100644
--- a/test/tests/unit/view/base.js
+++ b/test/tests/unit/view/base.js
@@ -4,7 +4,7 @@
var ID = 'view/base';
var DEPS = ['$', 'config'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/view/content.js b/test/tests/unit/view/content.js
index d8e7c984..b54d001d 100644
--- a/test/tests/unit/view/content.js
+++ b/test/tests/unit/view/content.js
@@ -4,7 +4,7 @@
var ID = 'view/content';
var DEPS = ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/view/sidebar.js b/test/tests/unit/view/sidebar.js
index 511aaa76..390a5bf7 100644
--- a/test/tests/unit/view/sidebar.js
+++ b/test/tests/unit/view/sidebar.js
@@ -4,7 +4,7 @@
var ID = 'view/sidebar';
var DEPS = ['$', 'core/resource', 'core/store'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {
diff --git a/test/tests/unit/view/viewmode.js b/test/tests/unit/view/viewmode.js
index fc8ba1eb..12d00757 100644
--- a/test/tests/unit/view/viewmode.js
+++ b/test/tests/unit/view/viewmode.js
@@ -4,7 +4,7 @@
var ID = 'view/viewmode';
var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'core/store'];
-describe('module "' + ID + '"', function () {
+describe('module \'' + ID + '\'', function () {
before(function () {