Ability to see TopRated/starred albums (#63)

This commit is contained in:
Simon J
2021-10-08 00:08:32 +11:00
committed by GitHub
parent 6116975d7a
commit cc95beb4f2
6 changed files with 196 additions and 65 deletions

View File

@@ -977,6 +977,12 @@ describe("api", () => {
albumArtURI: iconArtURI(bonobUrl, "heart").href(),
itemType: "albumList",
},
{
id: "starredAlbums",
title: "Top Rated",
albumArtURI: iconArtURI(bonobUrl, "star").href(),
itemType: "albumList",
},
{
id: "playlists",
title: "Playlists",
@@ -1064,6 +1070,12 @@ describe("api", () => {
albumArtURI: iconArtURI(bonobUrl, "heart").href(),
itemType: "albumList",
},
{
id: "starredAlbums",
title: "Best beoordeeld",
albumArtURI: iconArtURI(bonobUrl, "star").href(),
itemType: "albumList",
},
{
id: "playlists",
title: "Afspeellijsten",
@@ -1705,6 +1717,54 @@ describe("api", () => {
})
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "favourited",
_index: paging.index,
_count: paging.count,
});
});
});
describe("asking for starred albums", () => {
const albums = [rock2, rock1, pop2];
beforeEach(() => {
musicLibrary.albums.mockResolvedValue({
results: albums,
total: allAlbums.length,
});
});
it("should return some", async () => {
const paging = {
index: 0,
count: 100,
};
const result = await ws.getMetadataAsync({
id: "starredAlbums",
...paging,
});
expect(result[0]).toEqual(
getMetadataResult({
mediaCollection: albums.map((it) => ({
itemType: "album",
id: `album:${it.id}`,
title: it.name,
albumArtURI: defaultAlbumArtURI(
bonobUrlWithAccessToken,
it
).href(),
canPlay: true,
artistId: `artist:${it.artistId}`,
artist: it.artistName,
})),
index: 0,
total: 6,
})
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "starred",
_index: paging.index,
@@ -1754,7 +1814,7 @@ describe("api", () => {
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "recent",
type: "recentlyPlayed",
_index: paging.index,
_count: paging.count,
});
@@ -1802,7 +1862,7 @@ describe("api", () => {
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "frequent",
type: "mostPlayed",
_index: paging.index,
_count: paging.count,
});
@@ -1850,7 +1910,7 @@ describe("api", () => {
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "newest",
type: "recentlyAdded",
_index: paging.index,
_count: paging.count,
});