TestFixtures.swift

871 B · raw

1import Foundation23@testable import Haven45func makeWallpaper(6  id: String = "abc123",7  path: String = "https://w.wallhaven.cc/full/ab/wallhaven-abc123.jpg"8) -> Wallpaper {9  Wallpaper(10    id: id,11    url: "https://wallhaven.cc/w/\(id)",12    path: path,13    resolution: "1920x1080",14    purity: "sfw",15    file_size: 1_024,16    thumbs: Wallpaper.Thumbs(17      large: "https://th.wallhaven.cc/lg/\(id).jpg",18      original: "https://th.wallhaven.cc/orig/\(id).jpg",19      small: "https://th.wallhaven.cc/small/\(id).jpg"20    )21  )22}2324func encodedSearchResponse(25  wallpapers: [Wallpaper] = [makeWallpaper()],26  currentPage: Int = 1,27  lastPage: Int = 228) throws -> Data {29  let response = WallhavenResponse(30    data: wallpapers,31    meta: Meta(current_page: currentPage, last_page: lastPage, per_page: 24, total: 48)32  )33  return try JSONEncoder().encode(response)34}