Authored by Bogdan Poplauschi

Added error test

@@ -39,14 +39,24 @@ static int64_t kAsyncTestTimeout = 5; @@ -39,14 +39,24 @@ static int64_t kAsyncTestTimeout = 5;
39 - (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync { 39 - (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
40 NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"]; 40 NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"];
41 41
42 - [[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:^(NSInteger receivedSize, NSInteger expectedSize) {  
43 -// expect(receivedSize).to.beLessThanOrEqualTo(expectedSize);  
44 - } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 42 + [[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
45 expect(image).toNot.beNil(); 43 expect(image).toNot.beNil();
46 expect(error).to.beNil(); 44 expect(error).to.beNil();
47 expect(originalImageURL).to.equal(imageURL); 45 expect(originalImageURL).to.equal(imageURL);
48 46
49 - NSLog(@"xxxx"); 47 + XCAsyncSuccess();
  48 + }];
  49 +
  50 + XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out");
  51 +}
  52 +
  53 +- (void)testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
  54 + NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"];
  55 +
  56 + [[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
  57 + expect(image).to.beNil();
  58 + expect(error).toNot.beNil();
  59 + expect(originalImageURL).to.equal(imageURL);
50 60
51 XCAsyncSuccess(); 61 XCAsyncSuccess();
52 }]; 62 }];