Skip to content

Commit 5631350

Browse files
committed
Test improvements
1 parent 90ebf7a commit 5631350

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

test/unit/pjax.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -752,42 +752,39 @@ if ($.support.pjax) {
752752
asyncTest("clicking back while loading cancels XHR", function() {
753753
var frame = this.frame
754754

755-
frame.$("#main").one('pjax:complete', function() {
756-
757-
frame.$("#main").one('pjax:send', function() {
758-
759-
// Check that our request is aborted (need to check
760-
// how robust this is across browsers)
761-
frame.$("#main").one('pjax:complete', function(e, xhr, textStatus) {
762-
equal(xhr.status, 0)
763-
equal(textStatus, 'abort')
764-
})
755+
frame.$('#main').on('pjax:timeout', function(event) {
756+
event.preventDefault()
757+
})
765758

766-
// Make sure the URL and content remain the same after the
767-
// XHR would have arrived (delay on timeout.html is 1s)
768-
setTimeout(function() {
769-
var afterBackLocation = frame.location.pathname
770-
var afterBackTitle = frame.document.title
759+
frame.$("#main").one('pjax:send', function() {
771760

772-
setTimeout(function() {
773-
equal(frame.location.pathname, afterBackLocation)
774-
equal(frame.document.title, afterBackTitle)
775-
start()
776-
}, 1000)
777-
}, 500)
761+
// Check that our request is aborted (need to check
762+
// how robust this is across browsers)
763+
frame.$("#main").one('pjax:complete', function(e, xhr, textStatus) {
764+
equal(xhr.status, 0)
765+
equal(textStatus, 'abort')
766+
})
778767

768+
setTimeout(function() {
779769
frame.history.back()
770+
}, 250)
780771

781-
})
772+
// Make sure the URL and content remain the same after the
773+
// XHR would have arrived (delay on timeout.html is 1s)
774+
setTimeout(function() {
775+
var afterBackLocation = frame.location.pathname
776+
var afterBackTitle = frame.document.title
782777

783-
frame.$.pjax({
784-
url: "timeout.html",
785-
container: "#main"
786-
})
778+
setTimeout(function() {
779+
equal(frame.location.pathname, afterBackLocation)
780+
equal(frame.document.title, afterBackTitle)
781+
start()
782+
}, 1000)
783+
}, 500)
787784
})
788785

789786
frame.$.pjax({
790-
url: "hello.html",
787+
url: "timeout.html",
791788
container: "#main"
792789
})
793790
})

0 commit comments

Comments
 (0)