I think we're done
This commit is contained in:
@@ -157,5 +157,43 @@ import Testing
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let artist = try JSONDecoder().decode(Artist.self, from: json)
|
||||
#expect(artist.imageURL?.absoluteString == "https://commons.wikimedia.org/wiki/File:Michael_Jackson_1984.jpg")
|
||||
#expect(artist.imageURL?.absoluteString == "https://commons.wikimedia.org/wiki/Special:FilePath/Michael_Jackson_1984.jpg")
|
||||
}
|
||||
|
||||
@Test func testRecordingYouTubeURL() throws {
|
||||
let json = """
|
||||
{
|
||||
"id": "abc",
|
||||
"title": "Billie Jean",
|
||||
"relations": [
|
||||
{
|
||||
"type": "video",
|
||||
"direction": "forward",
|
||||
"url": {
|
||||
"id": "456",
|
||||
"resource": "https://www.youtube.com/watch?v=Zi_XLOBDo_Y"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let recording = try JSONDecoder().decode(Recording.self, from: json)
|
||||
#expect(recording.youtubeURL?.absoluteString == "https://www.youtube.com/watch?v=Zi_XLOBDo_Y")
|
||||
}
|
||||
|
||||
@Test func testReleaseFormatDecoding() throws {
|
||||
let json = """
|
||||
[
|
||||
"CD",
|
||||
"Digital Media",
|
||||
"Unknown Format XY"
|
||||
]
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let formats = try JSONDecoder().decode([ReleaseFormat].self, from: json)
|
||||
#expect(formats.count == 3)
|
||||
#expect(formats[0] == .cd)
|
||||
#expect(formats[1] == .digitalMedia)
|
||||
#expect(formats[2] == .other)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user