@@ -146,6 +146,42 @@ - (void)testAddPaymentSuccessWithMockQueue {
146146 XCTAssertEqual (transactionForUpdateBlock.transactionState , SKPaymentTransactionStatePurchased);
147147}
148148
149+ - (void )testAddPaymentWithNullSandboxArgument {
150+ XCTestExpectation* expectation =
151+ [self expectationWithDescription: @" result should return success state" ];
152+ FlutterMethodCall* call =
153+ [FlutterMethodCall methodCallWithMethodName: @" -[InAppPurchasePlugin addPayment:result:]"
154+ arguments: @{
155+ @" productIdentifier" : @" 123" ,
156+ @" quantity" : @(1 ),
157+ @" simulatesAskToBuyInSandbox" : [NSNull null ],
158+ }];
159+ SKPaymentQueueStub* queue = [SKPaymentQueueStub new ];
160+ queue.testState = SKPaymentTransactionStatePurchased;
161+ __block SKPaymentTransaction* transactionForUpdateBlock;
162+ self.plugin .paymentQueueHandler = [[FIAPaymentQueueHandler alloc ] initWithQueue: queue
163+ transactionsUpdated: ^(NSArray <SKPaymentTransaction*>* _Nonnull transactions) {
164+ SKPaymentTransaction* transaction = transactions[0 ];
165+ if (transaction.transactionState == SKPaymentTransactionStatePurchased) {
166+ transactionForUpdateBlock = transaction;
167+ [expectation fulfill ];
168+ }
169+ }
170+ transactionRemoved: nil
171+ restoreTransactionFailed: nil
172+ restoreCompletedTransactionsFinished: nil
173+ shouldAddStorePayment: ^BOOL (SKPayment* _Nonnull payment, SKProduct* _Nonnull product) {
174+ return YES ;
175+ }
176+ updatedDownloads: nil ];
177+ [queue addTransactionObserver: self .plugin.paymentQueueHandler];
178+ [self .plugin handleMethodCall: call
179+ result: ^(id r){
180+ }];
181+ [self waitForExpectations: @[ expectation ] timeout: 5 ];
182+ XCTAssertEqual (transactionForUpdateBlock.transactionState , SKPaymentTransactionStatePurchased);
183+ }
184+
149185- (void )testRestoreTransactions {
150186 XCTestExpectation* expectation =
151187 [self expectationWithDescription: @" result successfully restore transactions" ];
0 commit comments