Prettier fixes

This commit is contained in:
Behind The Math
2019-03-03 01:37:45 -05:00
parent 3c1a4b2e18
commit c13149626b
32 changed files with 1318 additions and 903 deletions

View File

@@ -1,18 +1,18 @@
var tape = require("tape")
var tape = require("tape");
var abortRequest = require("../../lib/abort-request.js")
var sendRequest = require("../../lib/send-request.js")
var abortRequest = require("../../lib/abort-request.js");
var sendRequest = require("../../lib/send-request.js");
// Polyfill responseURL property into XMLHttpRequest if it doesn't exist,
// just for the purposes of this test
// This polyfill is not complete; it won't show the updated location if a
// redirection occurred, but it's fine for our purposes.
if (!("responseURL" in XMLHttpRequest.prototype)) {
var nativeOpen = XMLHttpRequest.prototype.open
var nativeOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url) {
this.responseURL = url
return nativeOpen.apply(this, arguments)
}
this.responseURL = url;
return nativeOpen.apply(this, arguments);
};
}
tape("test aborting xhr request", function(t) {
@@ -20,37 +20,36 @@ tape("test aborting xhr request", function(t) {
options: {
cacheBust: true
}
})
});
t.test("- pending request is aborted", function(t) {
var r = requestCacheBust("https://httpbin.org/delay/10", {}, function() {
t.fail("xhr was not aborted")
})
t.equal(r.readyState, 1, "xhr readyState is '1' (SENT)")
abortRequest(r)
t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)")
t.equal(r.status, 0, "xhr HTTP status is '0' (ABORTED)")
t.equal(r.responseText, "", "xhr response is empty")
t.end()
})
t.fail("xhr was not aborted");
});
t.equal(r.readyState, 1, "xhr readyState is '1' (SENT)");
abortRequest(r);
t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)");
t.equal(r.status, 0, "xhr HTTP status is '0' (ABORTED)");
t.equal(r.responseText, "", "xhr response is empty");
t.end();
});
t.test("- request is not aborted if it has already completed", function(t) {
var r = requestCacheBust("https://httpbin.org/get", {}, function() {
abortRequest(r)
t.equal(r.readyState, 4, "xhr readyState is '4' (DONE)")
t.equal(r.status, 200, "xhr HTTP status is '200' (OK)")
t.end()
})
})
abortRequest(r);
t.equal(r.readyState, 4, "xhr readyState is '4' (DONE)");
t.equal(r.status, 200, "xhr HTTP status is '200' (OK)");
t.end();
});
});
t.test("- request is not aborted if it is undefined", function(t) {
var r
var r;
try {
abortRequest(r)
abortRequest(r);
} catch (e) {
t.fail("aborting an undefined request threw an error");
}
catch (e) {
t.fail("aborting an undefined request threw an error")
}
t.equal(typeof r, "undefined", "undefined xhr was ignored")
t.end()
})
t.end()
})
t.equal(typeof r, "undefined", "undefined xhr was ignored");
t.end();
});
t.end();
});