Skip to content

Commit

Permalink
Test responseImage on success and failure
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfraser committed Jun 1, 2013
1 parent 877a5a4 commit 648b4fb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/AFImageRequestOperationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,22 @@ - (void)testThatImageRequestOperationDoesNotAcceptInvalidFormatTypes {
expect(operation.error).willNot.beNil();
}

- (void)testThatImageResponseIsNotNilWhenRequestSucceeds {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/response-headers?Content-Type=image/png" relativeToURL:self.baseURL]];
AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:request];
[operation start];

expect([operation isFinished]).will.beTruthy();
expect(operation.responseImage).willNot.beNil();
}

- (void)testThatImageResponseIsNilWhenRequestFails {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:self.baseURL]];
AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:request];
[operation start];

expect([operation isFinished]).will.beTruthy();
expect(operation.responseImage).will.beNil();
}

@end

0 comments on commit 648b4fb

Please sign in to comment.