Add X-PJAX-Selectors header

This commit was merged in pull request #144.
This commit is contained in:
Behind The Math
2018-03-20 11:40:49 -04:00
committed by BehindTheMath
parent 75eb83dbc2
commit 17d8262025
3 changed files with 53 additions and 5 deletions

View File

@@ -38,3 +38,22 @@ tape("test xhr request", function(t) {
})
t.end()
})
tape("request headers are sent properly", function(t) {
var url = "https://httpbin.org/headers"
var options = {
selectors: ["div.pjax", "div.container"]
}
sendRequest(url, options, function(responseText) {
var headers = JSON.parse(responseText).headers
t.equals(headers["X-Requested-With"], "XMLHttpRequest", "X-Requested-With header is set correctly")
// Httpbin.org changes the case to 'X-Pjax'
t.equals(headers["X-Pjax"], "true", "X-PJAX header is set correctly")
t.equals(headers["X-Pjax-Selectors"], "[\"div.pjax\",\"div.container\"]", "X-PJAX-Selectors header is set correctly")
t.end()
})
})