Skip to content

Instantly share code, notes, and snippets.

@SURYAKANTSHARMA
Created May 4, 2019 11:00
Show Gist options
  • Save SURYAKANTSHARMA/4a6bedd3adf2d5cd655e2af2e633a277 to your computer and use it in GitHub Desktop.
Save SURYAKANTSHARMA/4a6bedd3adf2d5cd655e2af2e633a277 to your computer and use it in GitHub Desktop.
TestDocumentOpener
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