-
Notifications
You must be signed in to change notification settings - Fork 0
/
qunit_tests.js
55 lines (50 loc) · 1.45 KB
/
qunit_tests.js
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
53
54
55
var myDataId = -1;
function loadDataId(theResponse) {
if (theResponse.contains("=")) {
var array = theResponse.split("=");
myDataId = array[1];
}
}
var aOnLoadFunc = function(e) {
if (e.target && e.target.response) {
var aResp = e.target.response;
if (aResp.contains("NOOP") || aResp.contains("ERROR")) {
ok(false, aResp);
} else {
loadDataId(aResp);
ok(true, aResp);
}
} else {
ok(false, "malformed response");
}
start();
};
var aOnErrorFunc = function(e) {
var errorMsg = "remote resource error";
if (e.target && e.target.response) {
errorMsg = e.target.response;
}
ok(false, errorMsg);
start();
};
asyncTest("PUT", 1, function() {
var aSBObj_PUT = new SBObj("example");
aSBObj_PUT.setOnLoad(aOnLoadFunc);
aSBObj_PUT.setOnError(aOnErrorFunc);
aSBObj_PUT.setApiBaseUrl("http://localhost:8000");
aSBObj_PUT.PUT("test text data to store", "text/plain");
});
asyncTest("GET", 1, function() {
var aSBObj = new SBObj("example", myDataId);
aSBObj.setOnLoad(aOnLoadFunc);
aSBObj.setOnError(aOnErrorFunc);
aSBObj.setApiBaseUrl("http://localhost:8000");
aSBObj.GET();
});
asyncTest("DELETE", 1, function() {
var aSBObj = new SBObj("example", myDataId);
aSBObj.setOnLoad(aOnLoadFunc);
aSBObj.setOnError(aOnErrorFunc);
aSBObj.setApiBaseUrl("http://localhost:8000");
aSBObj.DELETE();
});