Skip to content

Commit

Permalink
fix unit test after introducing mock
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Nov 19, 2024
1 parent b0f420b commit f6a9414
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions DuckDuckGoTests/WebCacheManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class WebCacheManagerTests: XCTestCase {
@available(iOS 17, *)
@MainActor
func testEnsureIdAllocatedAfterClearing() async throws {
let fireproofing = MockFireproofing(domains: [])
let fireproofing = UserDefaultsFireproofing.shared
fireproofing.clearAll()
let storage = CookieStorage()

let inMemoryDataStoreIdManager = DataStoreIdManager(store: MockKeyValueStore())
Expand All @@ -62,9 +63,9 @@ class WebCacheManagerTests: XCTestCase {
@available(iOS 17, *)
@MainActor
func testWhenCookiesHaveSubDomainsOnSubDomainsAndWidlcardsThenOnlyMatchingCookiesRetained() async throws {
let fireproofing = MockFireproofing(domains: [
"mobile.twitter.com"
])
let fireproofing = UserDefaultsFireproofing.shared
fireproofing.clearAll()
fireproofing.addToAllowed(domain: "mobile.twitter.com")

let defaultStore = WKWebsiteDataStore.default()
await defaultStore.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), modifiedSince: .distantPast)
Expand Down Expand Up @@ -113,9 +114,9 @@ class WebCacheManagerTests: XCTestCase {

@MainActor
func testWhenClearedThenCookiesWithParentDomainsAreRetained() async {
let fireproofing = MockFireproofing(domains: [
"www.example.com"
])
let fireproofing = UserDefaultsFireproofing.shared
fireproofing.clearAll()
fireproofing.addToAllowed(domain: "www.example.com")

let defaultStore = WKWebsiteDataStore.default()
await defaultStore.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), modifiedSince: .distantPast)
Expand Down Expand Up @@ -150,9 +151,9 @@ class WebCacheManagerTests: XCTestCase {

@MainActor
func testWhenClearedWithLegacyContainerThenDDGCookiesAreRetained() async {
let fireproofing = MockFireproofing(domains: [
"www.example.com"
])
let fireproofing = UserDefaultsFireproofing.shared
fireproofing.clearAll()
fireproofing.addToAllowed(domain: "www.example.com")

let cookieStore = WKWebsiteDataStore.default().httpCookieStore
await cookieStore.setCookie(.make(name: "name", value: "value", domain: "duckduckgo.com"))
Expand All @@ -170,9 +171,9 @@ class WebCacheManagerTests: XCTestCase {

@MainActor
func testWhenClearedThenCookiesForLoginsAreRetained() async {
let fireproofing = MockFireproofing(domains: [
"www.example.com"
])
let fireproofing = UserDefaultsFireproofing.shared
fireproofing.clearAll()
fireproofing.addToAllowed(domain: "www.example.com")

let defaultStore = WKWebsiteDataStore.default()
await defaultStore.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), modifiedSince: .distantPast)
Expand Down

0 comments on commit f6a9414

Please sign in to comment.