Skip to content

Commit 648b4fb

Browse files
committed
Test responseImage on success and failure
1 parent 877a5a4 commit 648b4fb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/AFImageRequestOperationTests.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,22 @@ - (void)testThatImageRequestOperationDoesNotAcceptInvalidFormatTypes {
5656
expect(operation.error).willNot.beNil();
5757
}
5858

59+
- (void)testThatImageResponseIsNotNilWhenRequestSucceeds {
60+
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/response-headers?Content-Type=image/png" relativeToURL:self.baseURL]];
61+
AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:request];
62+
[operation start];
63+
64+
expect([operation isFinished]).will.beTruthy();
65+
expect(operation.responseImage).willNot.beNil();
66+
}
67+
68+
- (void)testThatImageResponseIsNilWhenRequestFails {
69+
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:self.baseURL]];
70+
AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:request];
71+
[operation start];
72+
73+
expect([operation isFinished]).will.beTruthy();
74+
expect(operation.responseImage).will.beNil();
75+
}
76+
5977
@end

0 commit comments

Comments
 (0)