HavenTests.swift

1.0 KB · raw

1import XCTest2@testable import Haven34class HavenTests: XCTestCase {5    6    // MARK: - ImageCache Tests7    8    func testImageCache() {9        let cache = ImageCache.shared10        let url = URL(string: "https://example.com/test.png")!11        let image = NSImage(size: NSSize(width: 10, height: 10))12        13        cache.insertImage(image, for: url)14        15        let retrieved = cache.image(for: url)16        XCTAssertNotNil(retrieved)17        XCTAssertEqual(retrieved?.size, image.size)18    }19    20    // MARK: - API Tests21    // Note: In a real production environment, we would use a Mock URLProtocol to intercept requests.22    // Here we will test the URL construction logic which is accessible if we make helper methods internal/public.23    // Since performSearch is private, we'll test public methods by mocking the session if possible, 24    // or just checking if they throw immediately on bad input.25    26    func testAPIInitialization() {27        let api = WallhavenAPI()28        XCTAssertNotNil(api)29    }30}