Added error test

This commit is contained in:
Bogdan Poplauschi 2014-06-20 17:51:40 +03:00
parent c1fae30d63
commit e0b3de4357
1 changed files with 14 additions and 4 deletions

View File

@ -39,14 +39,24 @@ static int64_t kAsyncTestTimeout = 5;
- (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"];
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// expect(receivedSize).to.beLessThanOrEqualTo(expectedSize);
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
expect(image).toNot.beNil();
expect(error).to.beNil();
expect(originalImageURL).to.equal(imageURL);
NSLog(@"xxxx");
XCAsyncSuccess();
}];
XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out");
}
- (void)testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"];
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
expect(image).to.beNil();
expect(error).toNot.beNil();
expect(originalImageURL).to.equal(imageURL);
XCAsyncSuccess();
}];