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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/* Copyright (c) 2010 Richard Wall <richard (at) the-moon.net>
* See LICENSE for details.
*
* Unit tests for Jarmon
**/
YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) {
Y.Test.Runner.add(new Y.Test.Case({
name: "jarmon.downloadBinary",
test_urlNotFound: function () {
/**
* When url cannot be found, the deferred should errback with status
* 404.
**/
var d = new jarmon.downloadBinary('non-existent-file.html');
d.addBoth(
function(self, ret) {
self.resume(function() {
Y.Assert.isInstanceOf(Error, ret);
Y.Assert.areEqual(404, ret.message);
});
}, this);
this.wait();
},
test_urlFound: function () {
/**
* When url is found, the deferred should callback with an instance
* of javascriptrrd.BinaryFile
**/
var d = new jarmon.downloadBinary('testfile.bin');
d.addBoth(
function(self, ret) {
self.resume(function() {
Y.Assert.isInstanceOf(BinaryFile, ret);
Y.Assert.areEqual(String.fromCharCode(0), ret.getRawData());
});
}, this);
this.wait();
}
}));
Y.Test.Runner.add(new Y.Test.Case({
name: "jarmon.RrdQuery",
test_getDataTimeRangeOverlapError: function () {
/**
* The starttime must be less than the endtime
**/
var rq = new jarmon.RrdQuery({}, '');
var error = null;
try {
rq.getData(1, 0);
} catch(e) {
error = e;
}
Y.Assert.isInstanceOf(jarmon.TimeRangeError, error);
}
}));
//initialize the console
var yconsole = new Y.Console({
newestOnTop: false,
width:'600px'
});
yconsole.render('#log');
//run all tests
Y.Test.Runner.run();
});
|