mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Fix bug where no genres caused error
This commit is contained in:
@@ -537,7 +537,7 @@ export class Navidrome implements MusicService {
|
|||||||
.getJSON<GenGenresResponse>(credentials, "/rest/getGenres")
|
.getJSON<GenGenresResponse>(credentials, "/rest/getGenres")
|
||||||
.then((it) =>
|
.then((it) =>
|
||||||
pipe(
|
pipe(
|
||||||
it.genres.genre,
|
it.genres.genre || [],
|
||||||
A.map((it) => it.__text),
|
A.map((it) => it.__text),
|
||||||
A.sort(ordString),
|
A.sort(ordString),
|
||||||
A.map((it) => ({ id: it, name: it }))
|
A.map((it) => ({ id: it, name: it }))
|
||||||
|
|||||||
@@ -453,6 +453,29 @@ describe("Navidrome", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("getting genres", () => {
|
describe("getting genres", () => {
|
||||||
|
describe("when there are none", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mockGET
|
||||||
|
.mockImplementationOnce(() => Promise.resolve(ok(PING_OK)))
|
||||||
|
.mockImplementationOnce(() => Promise.resolve(ok(genresXml([]))));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return them alphabetically sorted", async () => {
|
||||||
|
const result = await navidrome
|
||||||
|
.generateToken({ username, password })
|
||||||
|
.then((it) => it as AuthSuccess)
|
||||||
|
.then((it) => navidrome.login(it.authToken))
|
||||||
|
.then((it) => it.genres());
|
||||||
|
|
||||||
|
expect(result).toEqual([]);
|
||||||
|
|
||||||
|
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getGenres`, {
|
||||||
|
params: asURLSearchParams(authParams),
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("when there is only 1", () => {
|
describe("when there is only 1", () => {
|
||||||
const genres = ["genre1"];
|
const genres = ["genre1"];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user