-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
524b891
commit a140553
Showing
12 changed files
with
150 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...nnect/Source/Internal/Webview/MessageHandlers/FetchInitComponentPropsMessageHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// FetchInitComponentPropsMessageHandler.swift | ||
// StripeConnect | ||
// | ||
// Created by Mel Ludowise on 9/27/24. | ||
// | ||
|
||
import Foundation | ||
|
||
// Fetches initial property values specific to this component. | ||
@available(iOS 15, *) | ||
class FetchInitComponentPropsMessageHandler: ScriptMessageHandlerWithReply<VoidPayload, ComponentType> { | ||
init(componentType: ComponentType) { | ||
super.init(name: "fetchInitComponentProps") { _ in | ||
componentType | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ctTests/Internal/Webview/MessageHandlers/FetchInitComponentPropsMessageHandlerTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// FetchInitComponentPropsMessageHandlerTests.swift | ||
// StripeConnectTests | ||
// | ||
// Created by Mel Ludowise on 9/27/24. | ||
// | ||
|
||
@_spi(PrivateBetaConnect) @testable import StripeConnect | ||
import XCTest | ||
|
||
class FetchInitComponentPropsMessageHandlerTests: ScriptWebTestBase { | ||
|
||
@MainActor | ||
func testMessageSend() async throws { | ||
let componentType = ComponentType.onboarding(.init( | ||
fullTermsOfServiceUrl: URL(string: "https://fullTermsOfServiceUrl.com")!, | ||
recipientTermsOfServiceUrl: URL(string: "https://recipientTermsOfServiceUrl.com")!, | ||
privacyPolicyUrl: URL(string: "https://privacyPolicyUrl.com")!, | ||
skipTermsOfServiceCollection: true, | ||
collectionOptions: { | ||
var collectionOptions = AccountCollectionOptions() | ||
collectionOptions.fields = .eventuallyDue | ||
collectionOptions.futureRequirements = .include | ||
return collectionOptions | ||
}() | ||
)) | ||
webView.addMessageReplyHandler(messageHandler: FetchInitComponentPropsMessageHandler(componentType: componentType)) | ||
|
||
try await webView.evaluateMessageWithReply(name: "fetchInitComponentProps", | ||
json: "{}", | ||
expectedResponse: """ | ||
{"setCollectionOptions":{"fields":"eventually_due","futureRequirements":"include"},"setFullTermsOfServiceUrl":"https:\\/\\/fullTermsOfServiceUrl.com","setPrivacyPolicyUrl":"https:\\/\\/privacyPolicyUrl.com","setRecipientTermsOfServiceUrl":"https:\\/\\/recipientTermsOfServiceUrl.com","setSkipTermsOfServiceCollection":true} | ||
""") | ||
} | ||
} |