-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from gini/IPC-194-GiniHealthSDK-UnitTests
feat(GiniHealthSDK): UnitTests for GiniHealthSDK IPC-196
- Loading branch information
Showing
29 changed files
with
2,083 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,4 +155,4 @@ | |
} | ||
] | ||
} | ||
} | ||
} |
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
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
39 changes: 39 additions & 0 deletions
39
HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/URLOpener.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,39 @@ | ||
// | ||
// URLOpener.swift | ||
// | ||
// Copyright © 2024 Gini GmbH. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
// URLOpener helper structure for better testing of the open AppStore links functionality | ||
public struct URLOpener { | ||
private let application: URLOpenerProtocol | ||
|
||
public init(_ application: URLOpenerProtocol) { | ||
self.application = application | ||
} | ||
|
||
/// Opens AppStore with the provided URL | ||
/// | ||
/// - Parameters: | ||
/// - url: link that will be opened | ||
/// - completion: called after opening is completed | ||
/// param is true if website was opened successfully | ||
/// param is false if opening failed | ||
|
||
func openLink(url: URL, completion: ((Bool) -> Void)?) { | ||
if application.canOpenURL(url) { | ||
application.open(url, options: [:], completionHandler: completion) | ||
} else { | ||
completion?(false) | ||
} | ||
} | ||
} | ||
|
||
public protocol URLOpenerProtocol { | ||
func canOpenURL(_ url: URL) -> Bool | ||
func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any], completionHandler completion: ((Bool) -> Void)?) | ||
} | ||
|
||
extension UIApplication: URLOpenerProtocol {} |
Oops, something went wrong.