-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose "checkoutDidClickLink" handler, implement sensible defaults (#6)
* BREAKING CHANGE: only expose one clicked link function on delegate * Create default action for delegate functions, starting with checkoutDidClickLink --------- Co-authored-by: Mark Murray <[email protected]>
- Loading branch information
1 parent
137786a
commit f4982c4
Showing
9 changed files
with
92 additions
and
34 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
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 |
---|---|---|
|
@@ -36,33 +36,50 @@ class CheckoutViewTests: XCTestCase { | |
let link = URL(string: "mailto:[email protected]")! | ||
|
||
let delegate = MockCheckoutViewDelegate() | ||
let didClickContactLinkExpectation = expectation( | ||
description: "checkoutViewDidClickContactLink was called" | ||
let didClickLinkExpectation = expectation( | ||
description: "checkoutViewDidClickLink was called" | ||
) | ||
delegate.didClickContactLinkExpectation = didClickContactLinkExpectation | ||
delegate.didClickLinkExpectation = didClickLinkExpectation | ||
view.delegate = delegate | ||
|
||
view.webView(view, decidePolicyFor: MockNavigationAction(url: link)) { policy in | ||
XCTAssertEqual(policy, .cancel) | ||
} | ||
|
||
wait(for: [didClickContactLinkExpectation], timeout: 1) | ||
wait(for: [didClickLinkExpectation], timeout: 1) | ||
} | ||
|
||
func testPhoneContactLinkDelegation() { | ||
let link = URL(string: "tel:1234567890")! | ||
|
||
let delegate = MockCheckoutViewDelegate() | ||
let didClickContactLinkExpectation = expectation( | ||
description: "checkoutViewDidClickContactLink was called" | ||
let didCLickLinkExpectation = expectation( | ||
description: "checkoutViewDidClickLink was called" | ||
) | ||
delegate.didClickContactLinkExpectation = didClickContactLinkExpectation | ||
delegate.didClickLinkExpectation = didCLickLinkExpectation | ||
view.delegate = delegate | ||
|
||
view.webView(view, decidePolicyFor: MockNavigationAction(url: link)) { policy in | ||
XCTAssertEqual(policy, .cancel) | ||
} | ||
|
||
wait(for: [didClickContactLinkExpectation], timeout: 1) | ||
wait(for: [didCLickLinkExpectation], timeout: 1) | ||
} | ||
|
||
func testURLLinkDelegation() { | ||
let link = URL(string: "https://www.shopify.com/legal/privacy/app-users")! | ||
|
||
let delegate = MockCheckoutViewDelegate() | ||
let didClickLinkExpectation = expectation( | ||
description: "checkoutViewDidClickLink was called" | ||
) | ||
delegate.didClickLinkExpectation = didClickLinkExpectation | ||
view.delegate = delegate | ||
|
||
view.webView(view, decidePolicyFor: MockExternalNavigationAction(url: link)) { policy in | ||
XCTAssertEqual(policy, .cancel) | ||
} | ||
|
||
wait(for: [didClickLinkExpectation], timeout: 1) | ||
} | ||
} |
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