29
29
#import " PFTestSKProductsRequest.h"
30
30
#import " PFUnitTestCase.h"
31
31
#import " Parse_Private.h"
32
+ #import " BFTask+Private.h"
32
33
33
34
@interface PurchaseControllerTests : PFUnitTestCase
34
35
@end
@@ -233,21 +234,24 @@ - (void)testDownloadAssetAsync {
233
234
234
235
NSString *tempDirectory = [NSTemporaryDirectory () stringByAppendingPathComponent: [[NSUUID UUID ] UUIDString ]];
235
236
236
- OCMStub ([[commandRunner ignoringNonObjectArgs ] runCommandAsync: OCMOCK_ANY withOptions: 0 ]).andReturn (mockedTask);
237
+ OCMStub ([[commandRunner ignoringNonObjectArgs ] runCommandAsync: [OCMArg isNotNil ] withOptions: 0 ]).andReturn (mockedTask);
237
238
OCMStub ([fileManager parseDataItemPathForPathComponent: @" product" ]).andReturn (tempDirectory);
238
239
239
240
XCTestExpectation *expectation = [self currentSelectorTestExpectation ];
241
+ XCTestExpectation *progressExpectation = [self expectationWithDescription: @" progress" ];
240
242
241
243
__block int lastProgress = -1 ;
242
244
[[purchaseController downloadAssetAsyncForTransaction: transaction
243
245
withProgressBlock: ^(int percentDone) {
244
246
XCTAssertGreaterThan (percentDone, lastProgress);
245
-
246
247
lastProgress = percentDone;
248
+
249
+ if (lastProgress == 100 ) {
250
+ [progressExpectation fulfill ];
251
+ }
247
252
}
248
- sessionToken: @" token" ] continueWithExecutor: [BFExecutor mainThreadExecutor ] withBlock : ^id (BFTask *task) {
253
+ sessionToken: @" token" ] continueWithBlock : ^id (BFTask *task) {
249
254
XCTAssertFalse (task.faulted );
250
- XCTAssertEqual (lastProgress, 100 );
251
255
252
256
NSData *contentsOfFile = [NSData dataWithContentsOfFile: task.result];
253
257
XCTAssertEqualObjects (contentsOfFile, [self sampleData ]);
@@ -256,7 +260,6 @@ - (void)testDownloadAssetAsync {
256
260
257
261
return nil ;
258
262
}];
259
-
260
263
[self waitForTestExpectations ];
261
264
}
262
265
0 commit comments