-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Quick/Nimble with XCTest (#139)
* Replace Quick/Nimble with XCTest * Format file * Move last test helper to Test.swift with the rest * Specify latest stable version of Xcode on CI * Don't use async version of expectations in tests * Update CI to latest version of macOS and iOS * Address warnings from latest Xcode * Clean up GitHub action file * Perform all test visits async Increase timeout of failed page load to MORE than Turbo.js timeout so it triggers the invalid configuration error. * Increase XCTest timeout for slow GitHub Actions * Try Silicon on GitHub Actions * Try faster macOS image * Convert Swifter to Embassy * Remove xcpretty formatter - GitHub can't stream it * Move Embassy server config to helper file * Revert back to non-XL box on CI * Update Tests/ScriptMessageTests.swift Co-authored-by: Zoë Smith <zoews@me.com> * Remove force try calls in favor of XCTUnwrap * Move Embassy server outside of class-level * Remove empty test file * Update Tests/SessionTests.swift Co-authored-by: Zoë Smith <zoews@me.com> --------- Co-authored-by: Zoë Smith <zoews@me.com>
- Loading branch information
1 parent
c476bac
commit b975b95
Showing
22 changed files
with
635 additions
and
846 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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
@testable import Turbo | ||
import WebKit | ||
import XCTest | ||
|
||
class ColdBootVisitTests: XCTestCase { | ||
private let webView = WKWebView() | ||
private let visitDelegate = TestVisitDelegate() | ||
private var visit: ColdBootVisit! | ||
|
||
override func setUp() { | ||
let url = URL(string: "http://localhost/")! | ||
let bridge = WebViewBridge(webView: webView) | ||
|
||
visit = ColdBootVisit(visitable: TestVisitable(url: url), options: VisitOptions(), bridge: bridge) | ||
visit.delegate = visitDelegate | ||
} | ||
|
||
func test_start_transitionsToStartState() { | ||
XCTAssertEqual(visit.state, .initialized) | ||
visit.start() | ||
XCTAssertEqual(visit.state, .started) | ||
} | ||
|
||
func test_start_notifiesTheDelegateTheVisitWillStart() { | ||
visit.start() | ||
XCTAssertTrue(visitDelegate.didCall("visitWillStart(_:)")) | ||
} | ||
|
||
func test_start_kicksOffTheWebViewLoad() { | ||
visit.start() | ||
XCTAssertNotNil(visit.navigation) | ||
} | ||
|
||
func test_visit_becomesTheNavigationDelegate() { | ||
visit.start() | ||
XCTAssertIdentical(webView.navigationDelegate, visit) | ||
} | ||
|
||
func test_visit_notifiesTheDelegateTheVisitDidStart() { | ||
visit.start() | ||
XCTAssertTrue(visitDelegate.didCall("visitDidStart(_:)")) | ||
} | ||
|
||
func test_visit_ignoresTheCallIfAlreadyStarted() { | ||
visit.start() | ||
XCTAssertTrue(visitDelegate.methodsCalled.contains("visitDidStart(_:)")) | ||
|
||
visitDelegate.methodsCalled.remove("visitDidStart(_:)") | ||
visit.start() | ||
XCTAssertFalse(visitDelegate.didCall("visitDidStart(_:)")) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
@testable import Turbo | ||
import XCTest | ||
|
||
class JavaScriptExpressionTests: XCTestCase { | ||
func test_string_convertsFunctionAndArgumentsIntoAValidExpression() { | ||
let expression = JavaScriptExpression(function: "console.log", arguments: []) | ||
XCTAssertEqual(expression.string, "console.log()") | ||
|
||
let expression2 = JavaScriptExpression(function: "console.log", arguments: ["one", nil, 2]) | ||
XCTAssertEqual(expression2.string, "console.log(\"one\",null,2)") | ||
} | ||
|
||
func test_wrapped_wrapsExpressionIn_IIFE_AndTryCatch() { | ||
let expression = JavaScriptExpression(function: "console.log", arguments: []) | ||
let expected = """ | ||
(function(result) { | ||
try { | ||
result.value = console.log() | ||
} catch (error) { | ||
result.error = error.toString() | ||
result.stack = error.stack | ||
} | ||
return result | ||
})({}) | ||
""" | ||
|
||
XCTAssertEqual(expression.wrappedString, expected) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.