import Foundation @testable import Haven func makeWallpaper( id: String = "abc123", path: String = "https://w.wallhaven.cc/full/ab/wallhaven-abc123.jpg" ) -> Wallpaper { Wallpaper( id: id, url: "https://wallhaven.cc/w/\(id)", path: path, resolution: "1920x1080", purity: "sfw", file_size: 1_024, thumbs: Wallpaper.Thumbs( large: "https://th.wallhaven.cc/lg/\(id).jpg", original: "https://th.wallhaven.cc/orig/\(id).jpg", small: "https://th.wallhaven.cc/small/\(id).jpg" ) ) } func encodedSearchResponse( wallpapers: [Wallpaper] = [makeWallpaper()], currentPage: Int = 1, lastPage: Int = 2 ) throws -> Data { let response = WallhavenResponse( data: wallpapers, meta: Meta(current_page: currentPage, last_page: lastPage, per_page: 24, total: 48) ) return try JSONEncoder().encode(response) }