Started off well
This commit is contained in:
30
Tests/MusicBrainzTests/SearchTests.swift
Normal file
30
Tests/MusicBrainzTests/SearchTests.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user