import XCTest @testable import Haven class HavenTests: XCTestCase { // MARK: - ImageCache Tests func testImageCache() { let cache = ImageCache.shared let url = URL(string: "https://example.com/test.png")! let image = NSImage(size: NSSize(width: 10, height: 10)) cache.insertImage(image, for: url) let retrieved = cache.image(for: url) XCTAssertNotNil(retrieved) XCTAssertEqual(retrieved?.size, image.size) } // MARK: - API Tests // Note: In a real production environment, we would use a Mock URLProtocol to intercept requests. // Here we will test the URL construction logic which is accessible if we make helper methods internal/public. // Since performSearch is private, we'll test public methods by mocking the session if possible, // or just checking if they throw immediately on bad input. func testAPIInitialization() { let api = WallhavenAPI() XCTAssertNotNil(api) } }