mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-08-01 11:00:23 +02:00
Adds onpopstate tests.
This commit is contained in:
@@ -13,10 +13,10 @@ describe('module \'' + ID + '\'', function () {
|
||||
this.xModernizr = {
|
||||
history: true
|
||||
};
|
||||
this.xSettings = {
|
||||
smartBrowsing: true,
|
||||
this.xSettings = {view: {
|
||||
fastBrowsing: true,
|
||||
unmanagedInNewWindow: true
|
||||
};
|
||||
}};
|
||||
this.xEvent = {
|
||||
pub: sinon.stub(),
|
||||
sub: sinon.stub()
|
||||
@@ -26,10 +26,24 @@ describe('module \'' + ID + '\'', function () {
|
||||
};
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xEvent.pub.reset();
|
||||
this.xEvent.sub.reset();
|
||||
this.xNotify.set.reset();
|
||||
|
||||
return this.definition.fn(_, this.xModernizr, this.xEvent, this.xNotify, this.xSettings);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
window.onpopstate = null;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
window.onpopstate = null;
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
@@ -71,6 +85,46 @@ describe('module \'' + ID + '\'', function () {
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 7);
|
||||
});
|
||||
|
||||
it('sets window.onpopstate 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('does not set window.onpopstate 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('does not set window.onpopstate 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('does not set window.onpopstate 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 () {
|
||||
@@ -201,7 +255,7 @@ describe('module \'' + ID + '\'', function () {
|
||||
|
||||
it('sets target=\'_blank\' for unmanaged folders', function () {
|
||||
|
||||
this.xSettings.unmanagedInNewWindow = true;
|
||||
this.xSettings.view.unmanagedInNewWindow = true;
|
||||
|
||||
var $el = $('<a/>');
|
||||
var item = {
|
||||
@@ -218,7 +272,7 @@ describe('module \'' + ID + '\'', function () {
|
||||
|
||||
it('does not set target=\'_blank\' for managed folders', function () {
|
||||
|
||||
this.xSettings.unmanagedInNewWindow = true;
|
||||
this.xSettings.view.unmanagedInNewWindow = true;
|
||||
|
||||
var $el = $('<a/>');
|
||||
var item = {
|
||||
@@ -235,7 +289,7 @@ describe('module \'' + ID + '\'', function () {
|
||||
|
||||
it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
|
||||
|
||||
this.xSettings.unmanagedInNewWindow = false;
|
||||
this.xSettings.view.unmanagedInNewWindow = false;
|
||||
|
||||
var $el = $('<a/>');
|
||||
var item = {
|
||||
|
Reference in New Issue
Block a user