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,22 @@ - (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
+ [progressExpectation fulfill ];
247
250
}
248
251
sessionToken: @" token" ] continueWithExecutor: [BFExecutor mainThreadExecutor ] withBlock: ^id (BFTask *task) {
249
252
XCTAssertFalse (task.faulted );
250
- XCTAssertEqual (lastProgress, 100 );
251
253
252
254
NSData *contentsOfFile = [NSData dataWithContentsOfFile: task.result];
253
255
XCTAssertEqualObjects (contentsOfFile, [self sampleData ]);
@@ -256,8 +258,9 @@ - (void)testDownloadAssetAsync {
256
258
257
259
return nil ;
258
260
}];
259
-
260
261
[self waitForTestExpectations ];
262
+
263
+ XCTAssertEqual (lastProgress, 100 );
261
264
}
262
265
263
266
- (void )testDownloadInvalidReceipt {
0 commit comments