diff --git a/Tests/DVRTests/SessionTests.swift b/Tests/DVRTests/SessionTests.swift index 01fd3f6..c961fd4 100644 --- a/Tests/DVRTests/SessionTests.swift +++ b/Tests/DVRTests/SessionTests.swift @@ -41,6 +41,32 @@ class SessionTests: XCTestCase { XCTFail() } } + + func testDataTaskWithUrl() { + let url = URL(string: "http://example.com")! + let dataTask = session.dataTask(with: url) + + XCTAssert(dataTask is SessionDataTask) + + if let dataTask = dataTask as? SessionDataTask, let headers = dataTask.request.allHTTPHeaderFields { + XCTAssert(headers["testSessionHeader"] == "testSessionHeaderValue") + } else { + XCTFail() + } + } + + func testDataTaskWithUrlAndCompletion() { + let url = URL(string: "http://example.com")! + let dataTask = session.dataTask(with: url, completionHandler: { _, _, _ in return }) + + XCTAssert(dataTask is SessionDataTask) + + if let dataTask = dataTask as? SessionDataTask, let headers = dataTask.request.allHTTPHeaderFields { + XCTAssert(headers["testSessionHeader"] == "testSessionHeaderValue") + } else { + XCTFail() + } + } func testPlayback() { session.recordingEnabled = false