Created
May 4, 2019 11:00
-
-
Save SURYAKANTSHARMA/4a6bedd3adf2d5cd655e2af2e633a277 to your computer and use it in GitHub Desktop.
TestDocumentOpener
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
class MockURLOpener: URLOpening { | |
var openedURL: URL? | |
func open(_ url: URL, | |
options: [UIApplication.OpenExternalURLOptionsKey : Any], | |
completionHandler: ((Bool) -> Void)?) { | |
openedURL = url | |
} | |
} | |
func testDocumentOpener() { | |
let mockUrlOpener = MockURLOpener() | |
let documentOpener = DocumentOpener(urlOpener: mockUrlOpener) | |
documentOpener.openUrl(document: Document(identifier: 1), mode: Mode.edit) | |
guard let openedURL = mockUrlOpener.openedURL else { | |
XCTFail("No URL opened") | |
return | |
} | |
XCTAssertEqual(openedURL.absoluteString, "myappscheme://open?id=1&mode=edit", "Open URL Scheme is faulty") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment