From a741b9e561512e258fe4a589ac074c548eb37e3a Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Wed, 25 Aug 2010 21:06:07 +0100 Subject: Add a test for successful binary download --- jarmon/jarmon.test.js | 22 ++++++++++++++++++++++ testfile.bin | Bin 0 -> 1 bytes 2 files changed, 22 insertions(+) create mode 100644 testfile.bin diff --git a/jarmon/jarmon.test.js b/jarmon/jarmon.test.js index b6ee035..4a5c273 100644 --- a/jarmon/jarmon.test.js +++ b/jarmon/jarmon.test.js @@ -15,6 +15,10 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { }, 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) { @@ -26,6 +30,24 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { 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(); + }, + })); //initialize the console diff --git a/testfile.bin b/testfile.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/testfile.bin differ -- cgit v1.1-4-g5e80