diff --git a/src/_h5ai/client/js/inc/core/location.js b/src/_h5ai/client/js/inc/core/location.js index f0e9b99f..5a5c6e5e 100644 --- a/src/_h5ai/client/js/inc/core/location.js +++ b/src/_h5ai/client/js/inc/core/location.js @@ -186,11 +186,6 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/event', 'core/notify', }; } - event.sub('ready', function () { - - setLocation(document.location.href, true); - }); - return { forceEncoding: forceEncoding, diff --git a/src/_h5ai/client/js/inc/main/index.js b/src/_h5ai/client/js/inc/main/index.js index 6c59eee4..57f00370 100644 --- a/src/_h5ai/client/js/inc/main/index.js +++ b/src/_h5ai/client/js/inc/main/index.js @@ -1,4 +1,4 @@ -modulejs.define('main/index', ['_', 'core/event'], function (_, event) { +modulejs.define('main/index', ['_', 'core/location'], function (_, location) { modulejs.require('view/viewmode'); @@ -9,5 +9,5 @@ modulejs.define('main/index', ['_', 'core/event'], function (_, event) { } }); - event.pub('ready'); + location.setLocation(document.location.href, true); }); diff --git a/test/styles.less b/test/styles.less index 4d202d52..365cc84e 100644 --- a/test/styles.less +++ b/test/styles.less @@ -188,12 +188,10 @@ pre { display: block; - float: left; - clear: left; - font: 12px monospace; + font-family: monospace; + font-size: 12px; margin: 4px 0 16px 18px; padding: 0 8px; - max-width: 80%; word-wrap: break-word; border-left: 2px solid @col-grey-800; diff --git a/test/tests/unit/main/index.js b/test/tests/unit/main/index.js index 779463ac..e26ca33a 100644 --- a/test/tests/unit/main/index.js +++ b/test/tests/unit/main/index.js @@ -2,7 +2,7 @@ 'use strict'; var ID = 'main/index'; -var DEPS = ['_', 'core/event']; +var DEPS = ['_', 'core/location']; describe('module \'' + ID + '\'', function () { @@ -10,22 +10,19 @@ describe('module \'' + ID + '\'', function () { this.definition = modulejs._private.definitions[ID]; - this.xEvent = {pub: sinon.stub()}; - this.xDefine = sinon.stub(modulejs, 'define'); + this.xLocation = {setLocation: sinon.stub()}; this.xRequire = sinon.stub(modulejs, 'require'); this.applyFn = function () { - this.xEvent.pub.reset(); - this.xDefine.reset(); + this.xLocation.setLocation.reset(); this.xRequire.reset(); - return this.definition.fn(_, this.xEvent); + return this.definition.fn(_, this.xLocation); }; }); after(function () { - this.xDefine.restore(); this.xRequire.restore(); }); @@ -70,13 +67,6 @@ describe('module \'' + ID + '\'', function () { assert.isUndefined(instance); }); - it('publishes ready event', function () { - - this.applyFn(); - assert.isTrue(this.xEvent.pub.calledOnce); - assert.deepEqual(this.xEvent.pub.firstCall.args, ['ready']); - }); - it('requires view/viewmode', function () { this.applyFn(); @@ -121,6 +111,14 @@ describe('module \'' + ID + '\'', function () { } }); }); + + 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)); + }); }); });