blob: 59c659810f0c3b1c492ac1d869c1a8e69a01419e (
plain) (
blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
(function(module) {
function FakeXhr() {
this.openArgs = null;
this.sendArgs = null;
this.headers = {};
this.responseHeaders = {};
this.constructorArgs = arguments;
FakeXhr.instances.push(this);
}
FakeXhr.instances = [];
FakeXhr.prototype = {
open: function() {
this.openArgs = Array.prototype.slice.call(arguments);
},
getResponseHeader: function(key) {
return this.responseHeaders[key];
},
setRequestHeader: function(key, value) {
this.headers[key] = value;
},
send: function() {
this.sendArgs = Array.prototype.slice.call(arguments);
},
respond: function(data, code, headers) {
if (headers) {
this.responseHeaders = headers;
} else {
this.responseHeaders['content-type'] = 'text/xml';
}
this.readyState = 4;
this.responseText = data;
this.status = code || 200;
this.onreadystatechange();
}
};
module.exports = FakeXhr;
}.apply(
this,
(this.Caldav) ?
[Caldav('support/fake_xhr'), Caldav] :
[module, require('../../lib/caldav/caldav')]
));
|