move scrobble into subsonic

This commit is contained in:
simon
2025-02-15 22:56:22 +00:00
parent ddde55d02b
commit 5009732da2
4 changed files with 86 additions and 127 deletions

View File

@@ -3549,116 +3549,6 @@ describe("SubsonicMusicLibrary", () => {
});
});
describe("scrobble", () => {
describe("when succeeds", () => {
it("should return true", async () => {
const id = uuid();
mockGET.mockImplementationOnce(() => Promise.resolve(ok(EMPTY)));
const result = await subsonic.scrobble(id);
expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(
url.append({ pathname: "/rest/scrobble" }).href(),
{
params: asURLSearchParams({
...authParamsPlusJson,
id,
submission: true,
}),
headers,
}
);
});
});
describe("when fails", () => {
it("should return false", async () => {
const id = uuid();
mockGET.mockImplementationOnce(() =>
Promise.resolve({
status: 500,
data: {},
})
);
const result = await subsonic.scrobble(id);
expect(result).toEqual(false);
expect(mockGET).toHaveBeenCalledWith(
url.append({ pathname: "/rest/scrobble" }).href(),
{
params: asURLSearchParams({
...authParamsPlusJson,
id,
submission: true,
}),
headers,
}
);
});
});
});
describe("nowPlaying", () => {
describe("when succeeds", () => {
it("should return true", async () => {
const id = uuid();
mockGET.mockImplementationOnce(() => Promise.resolve(ok(EMPTY)));
const result = await subsonic.nowPlaying(id);
expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(
url.append({ pathname: "/rest/scrobble" }).href(),
{
params: asURLSearchParams({
...authParamsPlusJson,
id,
submission: false,
}),
headers,
}
);
});
});
describe("when fails", () => {
it("should return false", async () => {
const id = uuid();
mockGET.mockImplementationOnce(() =>
Promise.resolve({
status: 500,
data: {},
})
);
const result = await subsonic.nowPlaying(id);
expect(result).toEqual(false);
expect(mockGET).toHaveBeenCalledWith(
url.append({ pathname: "/rest/scrobble" }).href(),
{
params: asURLSearchParams({
...authParamsPlusJson,
id,
submission: false,
}),
headers,
}
);
});
});
});
describe("searchArtists", () => {
describe("when there is 1 search results", () => {
it("should return true", async () => {