pjax-test.js revision ada82c4ef0c7cb8d4f382c1831121f433025f5e5
/*
These tests test Y.Plugin.Pjax, since it sits at the top of a stack that
includes Y.PjaxBase and Y.Pjax, giving us full coverage of all three.
Note: These tests should ideally be run from an HTTP URL. If run from the local
filesystem, the tests that require XHR will be skipped.
*/
// Tests that require XHR are ignored when the protocol isn't http or https,
// since the XHR requests will fail.
name: 'Pjax',
setUp: function () {
this.oldPath = originalUrl;
},
tearDown: function () {
if (html5) {
}
}
});
// -- Lifecycle ----------------------------------------------------------------
name: 'Lifecycle',
setUp: function () {
},
tearDown: function () {
delete this.node;
},
'should plug into a Node instance': function () {
}
}));
// -- Attributes and Properties ------------------------------------------------
name: 'Attributes and Properties',
setUp: function () {
},
tearDown: function () {
delete this.node;
delete this.pjax;
},
'`container` should be null by default': function () {
},
'container` should always be `null` or a Node instance': function () {
},
'`contentSelector` should be null by default': function () {
},
'`linkSelector` should select links with class "yui3-pjax" by default': function () {
},
'`scrollToTop` should be true by default': function () {
},
'`timeout` should default to 30000ms': function () {
},
'`titleSelector` should select the title tag by default': function () {
}
}));
// -- Events -------------------------------------------------------------------
name: 'Events',
_should: {
ignore: {
}
},
setUp: function () {
this.oldPath = originalUrl;
},
tearDown: function () {
if (html5) {
}
delete this.node;
delete this.pjax;
delete this.oldPath;
},
'should attach events on init in HTML5 browsers': function () {
if (html5) {
} else {
}
},
'`error` event should fire on Ajax failure': function () {
var test = this;
});
});
this.wait(1000);
},
'`error` event should be preventable': function () {
this.pjax._defCompletefn = function () {
};
e.preventDefault();
});
},
'`load` event should fire on Ajax success': function () {
var test = this;
e.preventDefault();
});
});
this.wait(1000);
},
'`load` event should be preventable': function () {
this.pjax._defCompleteFn = function () {
};
e.preventDefault();
});
},
'`navigate` event facade should contain the options passed to `navigate()`': function () {
var called = 0,
options = {
title: 'Bogus Page'
},
called++;
});
},
'`navigate` event should fire when a pjax link is clicked': function () {
var event = {
button : 1,
preventDefault: function () {}
},
called = 1;
e.preventDefault();
});
// Fake click event.
},
'`navigate` event should be preventable': function () {
var called;
e.preventDefault();
});
// Fake click event.
this.pjax._onLinkClick({
button : 1,
preventDefault: function () {
called = 1;
}
});
},
'`navigate` event should not fire when a link is clicked with a button other than the left button': function () {
});
// Fake click event.
this.pjax._onLinkClick({
button : 2,
preventDefault: function () {}
});
},
'`navigate` event should not fire when a modifier key is pressed': function () {
});
// Fake click event.
this.pjax._onLinkClick({
button : 1,
ctrlKey : true,
preventDefault: function () {}
});
this.pjax._onLinkClick({
button : 1,
metaKey : true,
preventDefault: function () {}
});
}
}));
// -- Methods ------------------------------------------------------------------
name: 'Methods',
_should: {
ignore: {
}
},
setUp: function () {
this.oldPath = originalUrl;
},
tearDown: function () {
if (html5) {
}
delete this.node;
delete this.pjax;
delete this.oldPath;
},
'`navigate()` should load the specified URL and fire a `load` event': function () {
var test = this;
e.preventDefault();
});
this.wait(1000);
}
}));
// -- General Behavior ---------------------------------------------------------
name: 'General Behavior',
_should: {
ignore: {
'Page title should be updated if the `titleSelector` matches an element': disableXHR || !Y.config.doc || !html5,
'Host element content should be updated with page content when `contentSelector` is null': disableXHR || !html5,
'Host element content should be updated with partial content when `contentSelector` selects a node': disableXHR || !html5
}
},
setUp: function () {
this.oldPath = originalUrl;
},
tearDown: function () {
if (html5) {
}
delete this.node;
delete this.pjax;
delete this.oldPath;
},
'Page title should be updated if the `titleSelector` matches an element': function () {
var test = this;
});
});
this.wait(1000);
},
'Host element content should be updated with page content when `contentSelector` is null': function () {
var test = this;
});
});
this.wait(1000);
},
'Host element content should be updated with partial content when `contentSelector` selects a node': function () {
var test = this;
});
});
this.wait(1000);
}
}));
}, '@VERSION@', {
});