From 0fead2b2b94ef05dfffa81895b2dfb456cb9ac05 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Thu, 16 May 2013 21:16:39 +0200 Subject: [PATCH] Adds testEnqueueBatchOfHTTPRequestOperationsWithRequests. --- Tests/AFHTTPClientTests.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Tests/AFHTTPClientTests.m b/Tests/AFHTTPClientTests.m index 7f4a4a9..5fb8334 100644 --- a/Tests/AFHTTPClientTests.m +++ b/Tests/AFHTTPClientTests.m @@ -86,6 +86,32 @@ expect([operation class]).to.equal([AFImageRequestOperation class]); } +- (void)testEnqueueBatchOfHTTPRequestOperationsWithRequests { + [Expecta setAsynchronousTestTimeout:5.0]; + + __block NSDate *firstCallbackTime = nil; + __block NSDate *batchCallbackTime = nil; + + NSMutableURLRequest *request = [self.client requestWithMethod:@"GET" path:@"/" parameters:nil]; + AFHTTPRequestOperation *firstOperation = [self.client HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { + firstCallbackTime = [NSDate date]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + firstCallbackTime = [NSDate date]; + }]; + + AFHTTPRequestOperation *secondOperation = [self.client HTTPRequestOperationWithRequest:request success:NULL failure:NULL]; + + [self.client enqueueBatchOfHTTPRequestOperations:@[ firstOperation, secondOperation ] progressBlock:NULL completionBlock:^(NSArray *operations) { + batchCallbackTime = [NSDate date]; + }]; + + expect(self.client.operationQueue.operationCount).to.equal(@3); + expect(firstCallbackTime).willNot.beNil(); + expect(batchCallbackTime).willNot.beNil(); + + expect(batchCallbackTime).beGreaterThan(firstCallbackTime); +} + - (void)testThatTheDefaultStringEncodingIsUTF8 { expect(self.client.stringEncoding).to.equal(NSUTF8StringEncoding); }