-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into preserve-visit-option…
…s-response * origin/main: Fix obious wrong boolean expression (#159) Replace Quick/Nimble with XCTest (#139)
- Loading branch information
Showing
23 changed files
with
636 additions
and
847 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 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.