-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[in_app_purchase_storekit] backfill native tests for more complete test coverage #6209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a834469
8a9faf5
f5e19e2
b3d6706
6e4c13a
de4e798
d2a5f68
a6cddd6
4ebc324
f80f221
35f12a7
aa35c6c
f0fbdbc
4221167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,7 +127,7 @@ - (void)testFinishTransactionSucceeds { | |
|
|
||
| SKPaymentTransactionStub *paymentTransaction = | ||
| [[SKPaymentTransactionStub alloc] initWithMap:transactionMap]; | ||
| NSArray *array = [NSArray arrayWithObjects:paymentTransaction, nil]; | ||
| NSArray *array = @[ paymentTransaction ]; | ||
|
|
||
| FIAPaymentQueueHandler *mockHandler = OCMClassMock(FIAPaymentQueueHandler.class); | ||
| OCMStub([mockHandler getUnfinishedTransactions]).andReturn(array); | ||
|
|
@@ -179,6 +179,8 @@ - (void)testFinishTransactionSucceedsWithNilTransaction { | |
|
|
||
| - (void)testGetProductResponseWithRequestError { | ||
| NSArray *argument = @[ @"123" ]; | ||
| XCTestExpectation *expectation = | ||
| [self expectationWithDescription:@"completion handler successfully called"]; | ||
|
|
||
| id mockHandler = OCMClassMock([FIAPRequestHandler class]); | ||
| InAppPurchasePlugin *plugin = [[InAppPurchasePlugin alloc] | ||
|
|
@@ -199,16 +201,20 @@ - (void)testGetProductResponseWithRequestError { | |
| startProductRequestProductIdentifiers:argument | ||
| completion:^(SKProductsResponseMessage *_Nullable response, | ||
| FlutterError *_Nullable startProductRequestError) { | ||
| [expectation fulfill]; | ||
| XCTAssertNotNil(error); | ||
| XCTAssertNotNil(startProductRequestError); | ||
| XCTAssertEqualObjects( | ||
| startProductRequestError.code, | ||
| @"storekit_getproductrequest_platform_error"); | ||
| }]; | ||
| [self waitForExpectations:@[ expectation ] timeout:5]; | ||
| } | ||
|
|
||
| - (void)testGetProductResponseWithNoResponse { | ||
| NSArray *argument = @[ @"123" ]; | ||
| XCTestExpectation *expectation = | ||
| [self expectationWithDescription:@"completion handler successfully called"]; | ||
|
|
||
| id mockHandler = OCMClassMock([FIAPRequestHandler class]); | ||
|
|
||
|
|
@@ -230,11 +236,13 @@ - (void)testGetProductResponseWithNoResponse { | |
| startProductRequestProductIdentifiers:argument | ||
| completion:^(SKProductsResponseMessage *_Nullable response, | ||
| FlutterError *_Nullable startProductRequestError) { | ||
| [expectation fulfill]; | ||
| XCTAssertNotNil(error); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, you need an expectation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doneee |
||
| XCTAssertNotNil(startProductRequestError); | ||
| XCTAssertEqualObjects(startProductRequestError.code, | ||
| @"storekit_platform_no_response"); | ||
| }]; | ||
| [self waitForExpectations:@[ expectation ] timeout:5]; | ||
| } | ||
|
|
||
| - (void)testAddPaymentShouldReturnFlutterErrorWhenPaymentFails { | ||
|
|
@@ -495,6 +503,8 @@ - (void)testRefreshReceiptRequestWithError { | |
| @"isRevoked" : @NO, | ||
| @"isVolumePurchase" : @NO, | ||
| }; | ||
| XCTestExpectation *expectation = | ||
| [self expectationWithDescription:@"completion handler successfully called"]; | ||
|
|
||
| id mockHandler = OCMClassMock([FIAPRequestHandler class]); | ||
| InAppPurchasePlugin *plugin = [[InAppPurchasePlugin alloc] | ||
|
|
@@ -516,7 +526,9 @@ - (void)testRefreshReceiptRequestWithError { | |
| XCTAssertNotNil(error); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An expectation here too.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. omg this is scary cuz I forgot to replace the handler alloc-ing in the actual refreshReciept function, but the tests were still passing. once i added the expectation, it failed - except the expectation wasnt failing, it was the other asserts. 😱 |
||
| XCTAssertEqualObjects( | ||
| error.code, @"storekit_refreshreceiptrequest_platform_error"); | ||
| [expectation fulfill]; | ||
| }]; | ||
| [self waitForExpectations:@[ expectation ] timeout:5]; | ||
| } | ||
|
|
||
| /// presentCodeRedemptionSheetWithError:error is only available on iOS | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want an expectation here to make sure that this is actually called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doneee