@@ -419,6 +419,71 @@ - (void)testGetPendingTransactions {
419
419
XCTAssertEqualObjects (resultArray, @[ transactionMap ]);
420
420
}
421
421
422
+ - (void )testPaymentQueueStorefront {
423
+ if (@available (iOS 13 , macOS 10.15 , *)) {
424
+ // storefront is not nil
425
+ XCTestExpectation *expectation = [self expectationWithDescription: @" expect success" ];
426
+ FlutterMethodCall *call =
427
+ [FlutterMethodCall methodCallWithMethodName: @" -[SKPaymentQueue storefront]" arguments: nil ];
428
+ SKPaymentQueue *mockQueue = OCMClassMock (SKPaymentQueue.class );
429
+ NSDictionary *storefrontMap = @{
430
+ @" countryCode" : @" USA" ,
431
+ @" identifier" : @" unique_identifier" ,
432
+ };
433
+ OCMStub (mockQueue.storefront ).andReturn ([[SKStorefrontStub alloc ] initWithMap: storefrontMap]);
434
+
435
+ __block NSDictionary *resultMap;
436
+ self.plugin .paymentQueueHandler =
437
+ [[FIAPaymentQueueHandler alloc ] initWithQueue: mockQueue
438
+ transactionsUpdated: nil
439
+ transactionRemoved: nil
440
+ restoreTransactionFailed: nil
441
+ restoreCompletedTransactionsFinished: nil
442
+ shouldAddStorePayment: nil
443
+ updatedDownloads: nil
444
+ transactionCache: OCMClassMock (FIATransactionCache.class)];
445
+ [self .plugin handleMethodCall: call
446
+ result: ^(id r) {
447
+ resultMap = r;
448
+ [expectation fulfill ];
449
+ }];
450
+ [self waitForExpectations: @[ expectation ] timeout: 5 ];
451
+ XCTAssertEqualObjects (resultMap, storefrontMap);
452
+ } else {
453
+ NSLog (@" Skip testPaymentQueueStorefront for iOS lower than 13.0 or macOS lower than 10.15." );
454
+ }
455
+ }
456
+
457
+ - (void )testPaymentQueueStorefrontReturnsNil {
458
+ if (@available (iOS 13 , macOS 10.15 , *)) {
459
+ XCTestExpectation *expectation = [self expectationWithDescription: @" expect success" ];
460
+ FlutterMethodCall *call =
461
+ [FlutterMethodCall methodCallWithMethodName: @" -[SKPaymentQueue storefront]" arguments: nil ];
462
+ SKPaymentQueue *mockQueue = OCMClassMock (SKPaymentQueue.class );
463
+ OCMStub (mockQueue.storefront ).andReturn (nil );
464
+
465
+ __block NSDictionary *resultMap;
466
+ self.plugin .paymentQueueHandler =
467
+ [[FIAPaymentQueueHandler alloc ] initWithQueue: mockQueue
468
+ transactionsUpdated: nil
469
+ transactionRemoved: nil
470
+ restoreTransactionFailed: nil
471
+ restoreCompletedTransactionsFinished: nil
472
+ shouldAddStorePayment: nil
473
+ updatedDownloads: nil
474
+ transactionCache: OCMClassMock (FIATransactionCache.class)];
475
+ [self .plugin handleMethodCall: call
476
+ result: ^(id r) {
477
+ resultMap = r;
478
+ [expectation fulfill ];
479
+ }];
480
+ [self waitForExpectations: @[ expectation ] timeout: 5 ];
481
+ XCTAssertNil (resultMap);
482
+ } else {
483
+ NSLog (@" Skip testPaymentQueueStorefront for iOS lower than 13.0 or macOS lower than 10.15." );
484
+ }
485
+ }
486
+
422
487
- (void )testStartObservingPaymentQueue {
423
488
XCTestExpectation *expectation =
424
489
[self expectationWithDescription: @" Should return success result" ];
0 commit comments