Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Jan 10, 2025
1 parent 0a1ae92 commit f628b0f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions DuckDuckGoTests/YoutublePlayerNavigationHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,23 @@ class DuckPlayerNavigationHandlerTests: XCTestCase {
}
}

@MainActor
func testHandleNavigation_WithReferrerInURL_UpdatesDuckPlayerReferrer() async {
// Arrange
let youtubeURL = URL(string: "https://www.youtube.com/watch?v=abc123&dp_referrer=serp")!
let navigationAction = MockNavigationAction(request: URLRequest(url: youtubeURL))
playerSettings.mode = .alwaysAsk
playerSettings.openInNewTab = true
featureFlagger.enabledFeatures = [.duckPlayer, .duckPlayerOpenInNewTab]

// Act
handler.handleDuckNavigation(navigationAction, webView: mockWebView)

// Assert
XCTAssertEqual(handler.referrer, .serp)

}

@MainActor
func testHandleDelegateNavigation_DuckPlayerURL_CancelNavigationAndLoadsDuckPlayerWithParamsInTab() async {
// Arrange
Expand Down

0 comments on commit f628b0f

Please sign in to comment.