blob: 747fa9df2b78ec6c0e0b85844d0500719299c724 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
var specHelper = (function() {
// HELPERS
function respondXML(request, content) {
header = { "Content-Type": "application/xml;charset=utf-8" };
body = '<?xml version="1.0" encoding="UTF-8"?>\n';
body += content;
request.respond(200, header, body);
}
function respondJSON(request, object) {
header = { "Content-Type": "application/json;charset=utf-8" };
body = JSON.stringify(object);
request.respond(200, header, body);
}
function setupFakeXHR() {
this.xhr = sinon.useFakeXMLHttpRequest();
var requests = this.requests = [];
this.xhr.onCreate = function (xhr) {
requests.push(xhr);
};
}
return {
respondJSON: respondJSON,
respondXML: respondXML,
setupFakeXHR: setupFakeXHR
}
})();
|