From f6a9414fa23597cbf5b3d10f79b82c8ff99b3213 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Tue, 19 Nov 2024 16:59:37 +0000 Subject: [PATCH] fix unit test after introducing mock --- DuckDuckGoTests/WebCacheManagerTests.swift | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/DuckDuckGoTests/WebCacheManagerTests.swift b/DuckDuckGoTests/WebCacheManagerTests.swift index fcda49cf76..bb6af78dcc 100644 --- a/DuckDuckGoTests/WebCacheManagerTests.swift +++ b/DuckDuckGoTests/WebCacheManagerTests.swift @@ -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()) @@ -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) @@ -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) @@ -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")) @@ -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)