|
|
|
@ -33,6 +33,22 @@ struct EditableTrackFieldsTests { |
|
|
|
#expect(!mixed.contains(.artist)) |
|
|
|
#expect(!mixed.contains(.artist)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test func sharedAcrossThreeTracksAccumulatesMixed() { |
|
|
|
|
|
|
|
// Step 1: three tracks all share the same album, but title differs on the |
|
|
|
|
|
|
|
// third track and genre differs on the second — so both title and |
|
|
|
|
|
|
|
// genre must end up "mixed", while album stays shared. |
|
|
|
|
|
|
|
let t1 = Track.fixture(title: "Same", album: "One Album", genre: "Rock") |
|
|
|
|
|
|
|
let t2 = Track.fixture(title: "Same", album: "One Album", genre: "Pop") |
|
|
|
|
|
|
|
let t3 = Track.fixture(title: "Different", album: "One Album", genre: "Rock") |
|
|
|
|
|
|
|
// Step 2: shared() over all three. |
|
|
|
|
|
|
|
let (values, mixed) = EditableTrackFields.shared(across: [t1, t2, t3]) |
|
|
|
|
|
|
|
// Step 3: album is shared (not mixed); title + genre are mixed. |
|
|
|
|
|
|
|
#expect(values.album == "One Album") |
|
|
|
|
|
|
|
#expect(!mixed.contains(.album)) |
|
|
|
|
|
|
|
#expect(mixed.contains(.title)) |
|
|
|
|
|
|
|
#expect(mixed.contains(.genre)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test func applyOnlyWritesEditedFields() { |
|
|
|
@Test func applyOnlyWritesEditedFields() { |
|
|
|
// Step 1: a track and a fields object that changes album only. |
|
|
|
// Step 1: a track and a fields object that changes album only. |
|
|
|
let t = Track.fixture(album: "Old", genre: "Rock") |
|
|
|
let t = Track.fixture(album: "Old", genre: "Rock") |
|
|
|
|