Test instrument catalog metadata
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import MusicAssistantCore
|
||||
import XCTest
|
||||
|
||||
final class InstrumentCatalogItemTests: XCTestCase {
|
||||
func testCatalogItemStoresStructuredInstrumentMetadata() {
|
||||
let item = InstrumentCatalogItem(
|
||||
id: "oud",
|
||||
name: "Oud",
|
||||
familyCategory: "Plucked strings",
|
||||
regionOrigin: "Middle East",
|
||||
aliases: ["Arabic lute"],
|
||||
searchTerms: ["ud", "عود"]
|
||||
)
|
||||
|
||||
XCTAssertEqual(item.id, "oud")
|
||||
XCTAssertEqual(item.name, "Oud")
|
||||
XCTAssertEqual(item.familyCategory, "Plucked strings")
|
||||
XCTAssertEqual(item.regionOrigin, "Middle East")
|
||||
XCTAssertEqual(item.aliases, ["Arabic lute"])
|
||||
XCTAssertEqual(item.searchTerms, ["ud", "عود"])
|
||||
}
|
||||
|
||||
func testCatalogItemSupportsOptionalMetadataAndRoundTripsThroughJSON() throws {
|
||||
let item = InstrumentCatalogItem(
|
||||
id: "synthesizer",
|
||||
name: "Synthesizer",
|
||||
familyCategory: "Electronic"
|
||||
)
|
||||
|
||||
let data = try JSONEncoder().encode(item)
|
||||
let decodedItem = try JSONDecoder().decode(InstrumentCatalogItem.self, from: data)
|
||||
|
||||
XCTAssertNil(item.regionOrigin)
|
||||
XCTAssertEqual(item.aliases, [])
|
||||
XCTAssertEqual(item.searchTerms, [])
|
||||
XCTAssertEqual(decodedItem, item)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user