Files
swift-musicbrainz/Tests/MusicBrainzTests/SearchTests.swift
2026-03-21 17:25:07 +01:00

31 lines
769 B
Swift

import Foundation
import Testing
@testable import MusicBrainz
@Test func testArtistSearchDecoding() throws {
let json = """
{
"created": "2026-03-20T22:42:03.521Z",
"count": 1,
"offset": 0,
"artists": [
{
"id": "f27ec8db-af05-4f36-916e-3d57f91ecf5e",
"type": "Person",
"name": "Michael Jackson",
"sort-name": "Jackson, Michael",
"country": "US",
"disambiguation": "King of Pop"
}
]
}
""".data(using: .utf8)!
let response = try JSONDecoder().decode(SearchResponse<Artist>.self, from: json)
#expect(response.count == 1)
#expect(response.entities.count == 1)
#expect(response.entities[0].name == "Michael Jackson")
}