Add most recently played

This commit is contained in:
simojenki
2021-04-09 10:01:57 +10:00
parent 8a45bf6c11
commit efe4b4238b
2 changed files with 59 additions and 2 deletions

View File

@@ -552,9 +552,14 @@ describe("api", () => {
id: "recentlyPlayed",
title: "Recently Played",
},
{
itemType: "container",
id: "mostPlayed",
title: "Most Played",
},
],
index: 0,
total: 6,
total: 7,
})
);
});
@@ -968,6 +973,49 @@ describe("api", () => {
})
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "recent",
_index: paging.index,
_count: paging.count,
});
});
});
describe("asking for most played albums", () => {
const mostPlayed = [rock2, rock1, pop2];
beforeEach(() => {
musicLibrary.albums.mockResolvedValue({
results: mostPlayed,
total: allAlbums.length,
});
});
it("should return some", async () => {
const paging = {
index: 0,
count: 100,
};
const result = await ws.getMetadataAsync({
id: "mostPlayed",
...paging,
});
expect(result[0]).toEqual(
getMetadataResult({
mediaCollection: mostPlayed.map((it) => ({
itemType: "album",
id: `album:${it.id}`,
title: it.name,
albumArtURI: defaultAlbumArtURI(rootUrl, accessToken, it),
canPlay: true,
})),
index: 0,
total: 6,
})
);
expect(musicLibrary.albums).toHaveBeenCalledWith({
type: "frequent",
_index: paging.index,