Compare commits

...

7 Commits

Author SHA1 Message Date
dependabot[bot]
e522caeb29 Bump axios from 1.5.1 to 1.6.0
Bumps [axios](https://github.com/axios/axios) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-11 10:51:37 +00:00
Simon J
5ce2e4efb7 Bump libs (#179) 2023-10-11 17:19:24 +11:00
Simon J
8ef9ca80b6 Fix issue #177 (#178) 2023-10-11 12:45:27 +11:00
Simon J
a5689c3d4b Feature/move close stream (#176)
* Move stream destroy closer to where stream is retrieved

* Change BNB_SUBSONIC_URL to be of type URLBuilder to better handle URL construction rather than string concat, should addresse #169
2023-10-10 11:25:55 +11:00
dependabot[bot]
b8caf90e06 Bump semver from 5.7.1 to 5.7.2 (#165)
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-10 10:59:57 +11:00
dependabot[bot]
9b01f07484 Bump get-func-name from 2.0.0 to 2.0.2 (#173)
Bumps [get-func-name](https://github.com/chaijs/get-func-name) from 2.0.0 to 2.0.2.
- [Release notes](https://github.com/chaijs/get-func-name/releases)
- [Commits](https://github.com/chaijs/get-func-name/commits/v2.0.2)

---
updated-dependencies:
- dependency-name: get-func-name
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-10 10:59:46 +11:00
Simon J
fb5f8e81ec Ensure streams and destroyed on end of /stream request to see if addressess TCP leak issue (#175) 2023-10-09 16:19:00 +11:00
10 changed files with 1009 additions and 725 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
.vscode .vscode
build build
ignore ignore
.ignore
node_modules node_modules
.yarn/* .yarn/*
!.yarn/patches !.yarn/patches

View File

@@ -7,53 +7,52 @@
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"@svrooij/sonos": "^2.5.0", "@svrooij/sonos": "^2.5.0",
"@types/express": "^4.17.17", "@types/express": "^4.17.19",
"@types/fs-extra": "^11.0.1", "@types/fs-extra": "^11.0.2",
"@types/jsonwebtoken": "^9.0.1", "@types/jsonwebtoken": "^9.0.3",
"@types/jws": "^3.2.5", "@types/jws": "^3.2.6",
"@types/morgan": "^1.9.4", "@types/morgan": "^1.9.6",
"@types/node": "^16.11.7", "@types/node": "^16.11.7",
"@types/randomstring": "^1.1.8", "@types/randomstring": "^1.1.9",
"@types/sharp": "^0.31.1", "@types/underscore": "^1.11.11",
"@types/underscore": "^1.11.4", "@types/uuid": "^9.0.5",
"@types/uuid": "^9.0.1", "@types/xmldom": "0.1.32",
"@types/xmldom": "0.1.31", "axios": "^1.6.0",
"axios": "^1.3.4", "dayjs": "^1.11.10",
"dayjs": "^1.11.7",
"eta": "^2.0.1", "eta": "^2.0.1",
"express": "^4.18.2", "express": "^4.18.2",
"fp-ts": "^2.13.1", "fp-ts": "^2.16.1",
"fs-extra": "^11.1.0", "fs-extra": "^11.1.1",
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.2",
"jws": "^4.0.0", "jws": "^4.0.0",
"libxmljs2": "^0.31.0", "libxmljs2": "^0.32.0",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"node-html-parser": "^6.1.5", "node-html-parser": "^6.1.10",
"randomstring": "^1.2.3", "randomstring": "^1.3.0",
"sharp": "^0.31.3", "sharp": "^0.32.6",
"soap": "^1.0.0", "soap": "^1.0.0",
"ts-md5": "^1.3.1", "ts-md5": "^1.3.1",
"typescript": "^4.9.5", "typescript": "^5.2.2",
"underscore": "^1.13.6", "underscore": "^1.13.6",
"urn-lib": "^2.0.0", "urn-lib": "^2.0.0",
"uuid": "^9.0.0", "uuid": "^9.0.1",
"winston": "^3.8.2", "winston": "^3.11.0",
"xmldom-ts": "^0.3.1" "xmldom-ts": "^0.3.1"
}, },
"devDependencies": { "devDependencies": {
"@types/chai": "^4.3.4", "@types/chai": "^4.3.7",
"@types/jest": "^29.4.0", "@types/jest": "^29.5.5",
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.2",
"@types/supertest": "^2.0.12", "@types/supertest": "^2.0.14",
"@types/tmp": "^0.2.3", "@types/tmp": "^0.2.4",
"chai": "^4.3.7", "chai": "^4.3.10",
"get-port": "^6.1.2", "get-port": "^7.0.0",
"image-js": "^0.35.3", "image-js": "^0.35.4",
"jest": "^29.4.3", "jest": "^29.7.0",
"nodemon": "^2.0.21", "nodemon": "^3.0.1",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"tmp": "^0.2.1", "tmp": "^0.2.1",
"ts-jest": "^29.0.5", "ts-jest": "^29.1.1",
"ts-mockito": "^2.6.1", "ts-mockito": "^2.6.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"xmldom-ts": "^0.3.1", "xmldom-ts": "^0.3.1",
@@ -62,7 +61,7 @@
"scripts": { "scripts": {
"clean": "rm -Rf build node_modules", "clean": "rm -Rf build node_modules",
"build": "tsc", "build": "tsc",
"dev": "BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SEED_HOST=$BNB_DEV_SONOS_DEVICE_IP BNB_SONOS_SERVICE_NAME=z_bonobDev BNB_SONOS_DEVICE_DISCOVERY=true BNB_URL=\"http://${BNB_DEV_HOST_IP}:4534\" BNB_SUBSONIC_URL=\"${BNB_DEV_SUBSONIC_URL}\" nodemon -V ./src/app.ts", "dev": "BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_SONOS_SEED_HOST=$BNB_DEV_SONOS_DEVICE_IP BNB_SONOS_SERVICE_NAME=z_bonobDev BNB_URL=\"http://${BNB_DEV_HOST_IP}:4534\" BNB_SUBSONIC_URL=\"${BNB_DEV_SUBSONIC_URL}\" nodemon -V ./src/app.ts",
"devr": "BNB_DISABLE_PLAYLIST_ART=true BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SEED_HOST=$BNB_DEV_SONOS_DEVICE_IP BNB_SONOS_SERVICE_NAME=z_bonobDev BNB_SONOS_DEVICE_DISCOVERY=true BNB_SONOS_AUTO_REGISTER=true BNB_URL=\"http://${BNB_DEV_HOST_IP}:4534\" BNB_SUBSONIC_URL=\"${BNB_DEV_SUBSONIC_URL}\" nodemon -V ./src/app.ts", "devr": "BNB_DISABLE_PLAYLIST_ART=true BNB_LOG_LEVEL=debug BNB_DEBUG=true BNB_SCROBBLE_TRACKS=false BNB_REPORT_NOW_PLAYING=false BNB_ICON_FOREGROUND_COLOR=white BNB_ICON_BACKGROUND_COLOR=darkgrey BNB_SONOS_SEED_HOST=$BNB_DEV_SONOS_DEVICE_IP BNB_SONOS_SERVICE_NAME=z_bonobDev BNB_SONOS_DEVICE_DISCOVERY=true BNB_SONOS_AUTO_REGISTER=true BNB_URL=\"http://${BNB_DEV_HOST_IP}:4534\" BNB_SUBSONIC_URL=\"${BNB_DEV_SUBSONIC_URL}\" nodemon -V ./src/app.ts",
"register-dev": "ts-node ./src/register.ts http://${BNB_DEV_HOST_IP}:4534", "register-dev": "ts-node ./src/register.ts http://${BNB_DEV_HOST_IP}:4534",
"test": "jest", "test": "jest",

View File

@@ -98,7 +98,7 @@ export default function () {
sid: bnbEnvVar<number>("SONOS_SERVICE_ID", { default: 246, parser: asInt }), sid: bnbEnvVar<number>("SONOS_SERVICE_ID", { default: 246, parser: asInt }),
}, },
subsonic: { subsonic: {
url: bnbEnvVar("SUBSONIC_URL", { legacy: ["BONOB_NAVIDROME_URL"], default: `http://${hostname()}:4533` })!, url: url(bnbEnvVar("SUBSONIC_URL", { legacy: ["BONOB_NAVIDROME_URL"], default: `http://${hostname()}:4533` })!),
customClientsFor: bnbEnvVar<string>("SUBSONIC_CUSTOM_CLIENTS", { legacy: ["BONOB_NAVIDROME_CUSTOM_CLIENTS"] }), customClientsFor: bnbEnvVar<string>("SUBSONIC_CUSTOM_CLIENTS", { legacy: ["BONOB_NAVIDROME_CUSTOM_CLIENTS"] }),
artistImageCache: bnbEnvVar<string>("SUBSONIC_ARTIST_IMAGE_CACHE"), artistImageCache: bnbEnvVar<string>("SUBSONIC_ARTIST_IMAGE_CACHE"),
}, },

View File

@@ -307,13 +307,13 @@ function server(
return `<Match propname="rating" value="${value}"> return `<Match propname="rating" value="${value}">
<Ratings> <Ratings>
<Rating Id="${ratingAsInt( <Rating Id="${ratingAsInt(
nextLove nextLove
)}" AutoSkip="NEVER" OnSuccessStringId="LOVE_SUCCESS" StringId="LOVE"> )}" AutoSkip="NEVER" OnSuccessStringId="LOVE_SUCCESS" StringId="LOVE">
<Icon Controller="universal" LastModified="${LastModified}" Uri="${loveRatingIcon}" /> <Icon Controller="universal" LastModified="${LastModified}" Uri="${loveRatingIcon}" />
</Rating> </Rating>
<Rating Id="${-ratingAsInt( <Rating Id="${-ratingAsInt(
nextStar nextStar
)}" AutoSkip="NEVER" OnSuccessStringId="STAR_SUCCESS" StringId="STAR"> )}" AutoSkip="NEVER" OnSuccessStringId="STAR_SUCCESS" StringId="STAR">
<Icon Controller="universal" LastModified="${LastModified}" Uri="${starsRatingIcon}" /> <Icon Controller="universal" LastModified="${LastModified}" Uri="${starsRatingIcon}" />
</Rating> </Rating>
</Ratings> </Ratings>
@@ -327,9 +327,9 @@ function server(
<Match> <Match>
<imageSizeMap> <imageSizeMap>
${SONOS_RECOMMENDED_IMAGE_SIZES.map( ${SONOS_RECOMMENDED_IMAGE_SIZES.map(
(size) => (size) =>
`<sizeEntry size="${size}" substitution="/size/${size}"/>` `<sizeEntry size="${size}" substitution="/size/${size}"/>`
).join("")} ).join("")}
</imageSizeMap> </imageSizeMap>
</Match> </Match>
</PresentationMap> </PresentationMap>
@@ -338,9 +338,9 @@ function server(
<browseIconSizeMap> <browseIconSizeMap>
<sizeEntry size="0" substitution="/size/legacy"/> <sizeEntry size="0" substitution="/size/legacy"/>
${SONOS_RECOMMENDED_IMAGE_SIZES.map( ${SONOS_RECOMMENDED_IMAGE_SIZES.map(
(size) => (size) =>
`<sizeEntry size="${size}" substitution="/size/${size}"/>` `<sizeEntry size="${size}" substitution="/size/${size}"/>`
).join("")} ).join("")}
</browseIconSizeMap> </browseIconSizeMap>
</Match> </Match>
</PresentationMap> </PresentationMap>
@@ -406,13 +406,17 @@ function server(
trackId: id, trackId: id,
range: req.headers["range"] || undefined, range: req.headers["range"] || undefined,
}) })
.then((stream) => {
res.on('close', () => {
stream.stream.destroy()
});
return stream;
})
.then((stream) => ({ musicLibrary: it, stream })) .then((stream) => ({ musicLibrary: it, stream }))
) )
.then(({ musicLibrary, stream }) => { .then(({ musicLibrary, stream }) => {
logger.debug( logger.debug(
`${trace} bnb<- stream response from music service for ${id}, status=${ `${trace} bnb<- stream response from music service for ${id}, status=${stream.status}, headers=(${JSON.stringify(stream.headers)})`
stream.status
}, headers=(${JSON.stringify(stream.headers)})`
); );
const sonosisfyContentType = (contentType: string) => const sonosisfyContentType = (contentType: string) =>
@@ -436,9 +440,7 @@ function server(
nowPlaying: boolean; nowPlaying: boolean;
}) => { }) => {
logger.debug( logger.debug(
`${trace} bnb-> ${ `${trace} bnb-> ${req.path}, status=${status}, headers=${JSON.stringify(headers)}`
req.path
}, status=${status}, headers=${JSON.stringify(headers)}`
); );
(nowPlaying (nowPlaying
? musicLibrary.nowPlaying(id) ? musicLibrary.nowPlaying(id)
@@ -450,8 +452,8 @@ function server(
.forEach(([header, value]) => { .forEach(([header, value]) => {
res.setHeader(header, value!); res.setHeader(header, value!);
}); });
if (sendStream) stream.stream.pipe(filter).pipe(res); if (sendStream) stream.stream.pipe(filter).pipe(res)
else res.send(); else res.send()
}); });
}; };
@@ -513,15 +515,15 @@ function server(
const spec = const spec =
size == "legacy" size == "legacy"
? { ? {
mimeType: "image/png", mimeType: "image/png",
responseFormatter: (svg: string): Promise<Buffer | string> => responseFormatter: (svg: string): Promise<Buffer | string> =>
sharp(Buffer.from(svg)).resize(80).png().toBuffer(), sharp(Buffer.from(svg)).resize(80).png().toBuffer(),
} }
: { : {
mimeType: "image/svg+xml", mimeType: "image/svg+xml",
responseFormatter: (svg: string): Promise<Buffer | string> => responseFormatter: (svg: string): Promise<Buffer | string> =>
Promise.resolve(svg), Promise.resolve(svg),
}; };
return Promise.resolve( return Promise.resolve(
icon icon

View File

@@ -32,6 +32,7 @@ import { b64Encode, b64Decode } from "./b64";
import logger from "./logger"; import logger from "./logger";
import { assertSystem, BUrn } from "./burn"; import { assertSystem, BUrn } from "./burn";
import { artist } from "./smapi"; import { artist } from "./smapi";
import { URLBuilder } from "./url_builder";
export const BROWSER_HEADERS = { export const BROWSER_HEADERS = {
accept: accept:
@@ -344,28 +345,28 @@ export type ImageFetcher = (url: string) => Promise<CoverArt | undefined>;
export const cachingImageFetcher = export const cachingImageFetcher =
(cacheDir: string, delegate: ImageFetcher) => (cacheDir: string, delegate: ImageFetcher) =>
async (url: string): Promise<CoverArt | undefined> => { async (url: string): Promise<CoverArt | undefined> => {
const filename = path.join(cacheDir, `${Md5.hashStr(url)}.png`); const filename = path.join(cacheDir, `${Md5.hashStr(url)}.png`);
return fse return fse
.readFile(filename) .readFile(filename)
.then((data) => ({ contentType: "image/png", data })) .then((data) => ({ contentType: "image/png", data }))
.catch(() => .catch(() =>
delegate(url).then((image) => { delegate(url).then((image) => {
if (image) { if (image) {
return sharp(image.data) return sharp(image.data)
.png() .png()
.toBuffer() .toBuffer()
.then((png) => { .then((png) => {
return fse return fse
.writeFile(filename, png) .writeFile(filename, png)
.then(() => ({ contentType: "image/png", data: png })); .then(() => ({ contentType: "image/png", data: png }));
}); });
} else { } else {
return undefined; return undefined;
} }
}) })
); );
}; };
export const axiosImageFetcher = (url: string): Promise<CoverArt | undefined> => export const axiosImageFetcher = (url: string): Promise<CoverArt | undefined> =>
axios axios
@@ -412,12 +413,12 @@ interface SubsonicMusicLibrary extends MusicLibrary {
} }
export class Subsonic implements MusicService { export class Subsonic implements MusicService {
url: string; url: URLBuilder;
streamClientApplication: StreamClientApplication; streamClientApplication: StreamClientApplication;
externalImageFetcher: ImageFetcher; externalImageFetcher: ImageFetcher;
constructor( constructor(
url: string, url: URLBuilder,
streamClientApplication: StreamClientApplication = DEFAULT, streamClientApplication: StreamClientApplication = DEFAULT,
externalImageFetcher: ImageFetcher = axiosImageFetcher externalImageFetcher: ImageFetcher = axiosImageFetcher
) { ) {
@@ -433,7 +434,7 @@ export class Subsonic implements MusicService {
config: AxiosRequestConfig | undefined = {} config: AxiosRequestConfig | undefined = {}
) => ) =>
axios axios
.get(`${this.url}${path}`, { .get(this.url.append({ pathname: path }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
u: username, u: username,
v: "1.16.1", v: "1.16.1",
@@ -955,6 +956,7 @@ export class Subsonic implements MusicService {
}; };
if (credentials.type == "navidrome") { if (credentials.type == "navidrome") {
// todo: there does not seem to be a test for this??
return Promise.resolve({ return Promise.resolve({
...genericSubsonic, ...genericSubsonic,
flavour: () => "navidrome", flavour: () => "navidrome",
@@ -963,7 +965,7 @@ export class Subsonic implements MusicService {
TE.tryCatch( TE.tryCatch(
() => () =>
axios.post( axios.post(
`${this.url}/auth/login`, this.url.append({ pathname: '/auth/login' }).href(),
_.pick(credentials, "username", "password") _.pick(credentials, "username", "password")
), ),
() => new AuthFailure("Failed to get bearerToken") () => new AuthFailure("Failed to get bearerToken")

View File

@@ -374,23 +374,31 @@ describe("config", () => {
"BONOB_NAVIDROME_URL", "BONOB_NAVIDROME_URL",
])("%s", (k) => { ])("%s", (k) => {
describe(`when ${k} is not specified`, () => { describe(`when ${k} is not specified`, () => {
it(`should default to http://${hostname()}:4533`, () => { it(`should default to http://${hostname()}:4533/`, () => {
expect(config().subsonic.url).toEqual(`http://${hostname()}:4533`); expect(config().subsonic.url.href()).toEqual(`http://${hostname()}:4533/`);
}); });
}); });
describe(`when ${k} is ''`, () => { describe(`when ${k} is ''`, () => {
it(`should default to http://${hostname()}:4533`, () => { it(`should default to http://${hostname()}:4533/`, () => {
process.env[k] = ""; process.env[k] = "";
expect(config().subsonic.url).toEqual(`http://${hostname()}:4533`); expect(config().subsonic.url.href()).toEqual(`http://${hostname()}:4533/`);
}); });
}); });
describe(`when ${k} is specified`, () => { describe(`when ${k} is specified`, () => {
it(`should use it for ${k}`, () => { it(`should use it for ${k}`, () => {
const url = "http://navidrome.example.com:1234"; const url = "http://navidrome.example.com:1234/some-context-path";
process.env[k] = url; process.env[k] = url;
expect(config().subsonic.url).toEqual(url); expect(config().subsonic.url.href()).toEqual(url);
});
});
describe(`when ${k} is specified with trailing slash`, () => {
it(`should maintain the trailing slash as URLBuilder will remove it when required ${k}`, () => {
const url = "http://navidrome.example.com:1234/";
process.env[k] = url;
expect(config().subsonic.url.href()).toEqual(url);
}); });
}); });
}); });

View File

@@ -755,15 +755,22 @@ describe("server", () => {
const trackId = `t-${uuid()}`; const trackId = `t-${uuid()}`;
const smapiAuthToken: SmapiToken = { token: `token-${uuid()}`, key: `key-${uuid()}` }; const smapiAuthToken: SmapiToken = { token: `token-${uuid()}`, key: `key-${uuid()}` };
const streamContent = (content: string) => ({ const streamContent = (content: string) => {
pipe: (_: Transform) => { const self = {
return { destroyed: false,
pipe: (res: Response) => { pipe: (_: Transform) => {
res.send(content); return {
}, pipe: (res: Response) => {
}; res.send(content);
}, }
}); };
},
destroy: () => {
self.destroyed = true;
}
};
return self;
};
describe("HEAD requests", () => { describe("HEAD requests", () => {
describe("when there is no Bearer token", () => { describe("when there is no Bearer token", () => {
@@ -829,6 +836,8 @@ describe("server", () => {
); );
expect(res.headers["content-length"]).toEqual("123"); expect(res.headers["content-length"]).toEqual("123");
expect(res.body).toEqual({}); expect(res.body).toEqual({});
expect(trackStream.stream.destroyed).toBe(true);
}); });
}); });
@@ -854,6 +863,8 @@ describe("server", () => {
expect(res.status).toEqual(404); expect(res.status).toEqual(404);
expect(res.body).toEqual({}); expect(res.body).toEqual({});
expect(trackStream.stream.destroyed).toBe(true);
}); });
}); });
}); });
@@ -916,6 +927,8 @@ describe("server", () => {
expect(musicLibrary.nowPlaying).not.toHaveBeenCalled(); expect(musicLibrary.nowPlaying).not.toHaveBeenCalled();
expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId }); expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
@@ -959,6 +972,8 @@ describe("server", () => {
expect(musicService.login).toHaveBeenCalledWith(serviceToken); expect(musicService.login).toHaveBeenCalledWith(serviceToken);
expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId); expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId);
expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId }); expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
@@ -1000,6 +1015,8 @@ describe("server", () => {
expect(musicService.login).toHaveBeenCalledWith(serviceToken); expect(musicService.login).toHaveBeenCalledWith(serviceToken);
expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId); expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId);
expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId }); expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
@@ -1040,6 +1057,8 @@ describe("server", () => {
expect(musicService.login).toHaveBeenCalledWith(serviceToken); expect(musicService.login).toHaveBeenCalledWith(serviceToken);
expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId); expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId);
expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId }); expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
@@ -1083,6 +1102,8 @@ describe("server", () => {
expect(musicService.login).toHaveBeenCalledWith(serviceToken); expect(musicService.login).toHaveBeenCalledWith(serviceToken);
expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId); expect(musicLibrary.nowPlaying).toHaveBeenCalledWith(trackId);
expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId }); expect(musicLibrary.stream).toHaveBeenCalledWith({ trackId });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
}); });
@@ -1131,6 +1152,8 @@ describe("server", () => {
trackId, trackId,
range: requestedRange, range: requestedRange,
}); });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
@@ -1178,6 +1201,8 @@ describe("server", () => {
trackId, trackId,
range: "4000-5000", range: "4000-5000",
}); });
expect(stream.stream.destroyed).toBe(true);
}); });
}); });
}); });

View File

@@ -62,6 +62,7 @@ import {
} from "./builders"; } from "./builders";
import { b64Encode } from "../src/b64"; import { b64Encode } from "../src/b64";
import { BUrn } from "../src/burn"; import { BUrn } from "../src/burn";
import { URLBuilder } from "../src/url_builder";
describe("t", () => { describe("t", () => {
it("should be an md5 of the password and the salt", () => { it("should be an md5 of the password and the salt", () => {
@@ -688,7 +689,7 @@ describe("asTrack", () => {
}); });
describe("Subsonic", () => { describe("Subsonic", () => {
const url = "http://127.0.0.22:4567"; const url = new URLBuilder("http://127.0.0.22:4567/some-context-path");
const username = `user1-${uuid()}`; const username = `user1-${uuid()}`;
const password = `pass1-${uuid()}`; const password = `pass1-${uuid()}`;
const salt = "saltysalty"; const salt = "saltysalty";
@@ -756,7 +757,7 @@ describe("Subsonic", () => {
expect(parseToken(token.serviceToken)).toEqual({ username, password, type: PING_OK["subsonic-response"].type }) expect(parseToken(token.serviceToken)).toEqual({ username, password, type: PING_OK["subsonic-response"].type })
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/ping.view`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/ping.view' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -777,7 +778,7 @@ describe("Subsonic", () => {
expect(parseToken(token.serviceToken)).toEqual({ username, password, type }) expect(parseToken(token.serviceToken)).toEqual({ username, password, type })
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/ping.view`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/ping.view' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -802,11 +803,11 @@ describe("Subsonic", () => {
expect(parseToken(token.serviceToken)).toEqual({ username, password, type: "navidrome", bearer: navidromeToken }) expect(parseToken(token.serviceToken)).toEqual({ username, password, type: "navidrome", bearer: navidromeToken })
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/ping.view`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/ping.view' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.post).toHaveBeenCalledWith(`${url}/auth/login`, { expect(axios.post).toHaveBeenCalledWith(url.append({ pathname: '/auth/login' }).href(), {
username, username,
password, password,
}); });
@@ -848,7 +849,7 @@ describe("Subsonic", () => {
expect(parseToken(refreshedToken.serviceToken)).toEqual({ username, password, type }) expect(parseToken(refreshedToken.serviceToken)).toEqual({ username, password, type })
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/ping.view`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/ping.view' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -876,11 +877,11 @@ describe("Subsonic", () => {
expect(parseToken(refreshedToken.serviceToken)).toEqual({ username, password, type: "navidrome", bearer: navidromeToken }) expect(parseToken(refreshedToken.serviceToken)).toEqual({ username, password, type: "navidrome", bearer: navidromeToken })
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/ping.view`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/ping.view' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.post).toHaveBeenCalledWith(`${url}/auth/login`, { expect(axios.post).toHaveBeenCalledWith(url.append({ pathname: '/auth/login' }).href(), {
username, username,
password, password,
}); });
@@ -927,6 +928,34 @@ describe("Subsonic", () => {
}); });
}); });
describe("bearerToken", () => {
describe("when flavour is generic subsonic", () => {
it("should return undefined", async () => {
const credentials = { username: "foo", password: "bar" };
const token = { ...credentials, type: "subsonic", bearer: undefined }
const client = await subsonic.login(asToken(token));
const bearerToken = await pipe(client.bearerToken(credentials))();
expect(bearerToken).toStrictEqual(E.right(undefined));
});
});
describe("when flavour is navidrome", () => {
it("should get a bearerToken from navidrome", async () => {
const credentials = { username: "foo", password: "bar" };
const token = { ...credentials, type: "navidrome", bearer: undefined }
const client = await subsonic.login(asToken(token));
mockPOST.mockImplementationOnce(() => Promise.resolve(ok({ token: 'theBearerToken' })))
const bearerToken = await pipe(client.bearerToken(credentials))();
expect(bearerToken).toStrictEqual(E.right('theBearerToken'));
expect(axios.post).toHaveBeenCalledWith(url.append({ pathname: '/auth/login' }).href(), credentials)
});
});
});
describe("getting genres", () => { describe("getting genres", () => {
describe("when there are none", () => { describe("when there are none", () => {
beforeEach(() => { beforeEach(() => {
@@ -941,7 +970,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getGenres`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getGenres' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -968,7 +997,7 @@ describe("Subsonic", () => {
expect(result).toEqual([{ id: b64Encode("genre1"), name: "genre1" }]); expect(result).toEqual([{ id: b64Encode("genre1"), name: "genre1" }]);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getGenres`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getGenres' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -1003,7 +1032,7 @@ describe("Subsonic", () => {
{ id: b64Encode("g4"), name: "g4" }, { id: b64Encode("g4"), name: "g4" },
]); ]);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getGenres`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getGenres' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -1059,7 +1088,7 @@ describe("Subsonic", () => {
similarArtists: artist.similarArtists, similarArtists: artist.similarArtists,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1067,7 +1096,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1118,7 +1147,7 @@ describe("Subsonic", () => {
similarArtists: artist.similarArtists, similarArtists: artist.similarArtists,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1126,7 +1155,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1171,7 +1200,7 @@ describe("Subsonic", () => {
similarArtists: artist.similarArtists, similarArtists: artist.similarArtists,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1179,7 +1208,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1225,7 +1254,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1233,7 +1262,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1276,7 +1305,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1284,7 +1313,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1327,7 +1356,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1335,7 +1364,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1379,7 +1408,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1387,7 +1416,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1432,7 +1461,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1440,7 +1469,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1483,7 +1512,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1491,7 +1520,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1532,7 +1561,7 @@ describe("Subsonic", () => {
similarArtists: [], similarArtists: [],
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtist`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1540,7 +1569,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtistInfo2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtistInfo2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: artist.id, id: artist.id,
@@ -1661,7 +1690,7 @@ describe("Subsonic", () => {
total: 1, total: 1,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -1702,7 +1731,7 @@ describe("Subsonic", () => {
total: 4, total: 4,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -1730,7 +1759,7 @@ describe("Subsonic", () => {
expect(artists).toEqual({ results: expectedResults, total: 4 }); expect(artists).toEqual({ results: expectedResults, total: 4 });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -1786,12 +1815,12 @@ describe("Subsonic", () => {
total: 2, total: 2,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "byGenre", type: "byGenre",
@@ -1838,12 +1867,12 @@ describe("Subsonic", () => {
total: 3, total: 3,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "newest", type: "newest",
@@ -1889,12 +1918,12 @@ describe("Subsonic", () => {
total: 2, total: 2,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "recent", type: "recent",
@@ -1931,12 +1960,12 @@ describe("Subsonic", () => {
total: 1, total: 1,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "frequent", type: "frequent",
@@ -1973,12 +2002,12 @@ describe("Subsonic", () => {
total: 1, total: 1,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "highest", type: "highest",
@@ -2024,12 +2053,12 @@ describe("Subsonic", () => {
total: 1, total: 1,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "alphabeticalByArtist", type: "alphabeticalByArtist",
@@ -2074,12 +2103,12 @@ describe("Subsonic", () => {
total: 0, total: 0,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "alphabeticalByArtist", type: "alphabeticalByArtist",
@@ -2139,12 +2168,12 @@ describe("Subsonic", () => {
total: 6, total: 6,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "alphabeticalByArtist", type: "alphabeticalByArtist",
@@ -2190,12 +2219,12 @@ describe("Subsonic", () => {
total: 6, total: 6,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbumList2`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbumList2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
type: "alphabeticalByArtist", type: "alphabeticalByArtist",
@@ -2263,13 +2292,13 @@ describe("Subsonic", () => {
total: 4, total: 4,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getAlbumList2`, url.append({ pathname: '/rest/getAlbumList2' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
@@ -2320,13 +2349,13 @@ describe("Subsonic", () => {
total: 4, total: 4,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getAlbumList2`, url.append({ pathname: '/rest/getAlbumList2' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
@@ -2376,13 +2405,13 @@ describe("Subsonic", () => {
total: 4, total: 4,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getAlbumList2`, url.append({ pathname: '/rest/getAlbumList2' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
@@ -2442,13 +2471,13 @@ describe("Subsonic", () => {
total: 5, total: 5,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getAlbumList2`, url.append({ pathname: '/rest/getAlbumList2' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
@@ -2506,13 +2535,13 @@ describe("Subsonic", () => {
total: 5, total: 5,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getAlbumList2`, url.append({ pathname: '/rest/getAlbumList2' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
@@ -2568,13 +2597,13 @@ describe("Subsonic", () => {
total: 5, total: 5,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getArtists`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getArtists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getAlbumList2`, url.append({ pathname: '/rest/getAlbumList2' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
@@ -2620,7 +2649,7 @@ describe("Subsonic", () => {
expect(result).toEqual(album); expect(result).toEqual(album);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbum`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbum' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: album.id, id: album.id,
@@ -2698,7 +2727,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track1, track2, track3, track4]); expect(result).toEqual([track1, track2, track3, track4]);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbum`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbum' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: album.id, id: album.id,
@@ -2745,7 +2774,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track]); expect(result).toEqual([track]);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbum`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbum' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: album.id, id: album.id,
@@ -2780,7 +2809,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbum`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbum' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: album.id, id: album.id,
@@ -2831,7 +2860,7 @@ describe("Subsonic", () => {
rating: { love: true, stars: 4 }, rating: { love: true, stars: 4 },
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getSong`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getSong' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: track.id, id: track.id,
@@ -2839,7 +2868,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbum`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbum' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: album.id, id: album.id,
@@ -2878,7 +2907,7 @@ describe("Subsonic", () => {
rating: { love: false, stars: 0 }, rating: { love: false, stars: 0 },
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getSong`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getSong' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: track.id, id: track.id,
@@ -2886,7 +2915,7 @@ describe("Subsonic", () => {
headers, headers,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getAlbum`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getAlbum' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: album.id, id: album.id,
@@ -3033,7 +3062,7 @@ describe("Subsonic", () => {
}); });
expect(result.stream).toEqual(stream); expect(result.stream).toEqual(stream);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/stream`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/stream' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
id: trackId, id: trackId,
@@ -3139,7 +3168,7 @@ describe("Subsonic", () => {
}); });
expect(result.stream).toEqual(stream); expect(result.stream).toEqual(stream);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/stream`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/stream' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
id: trackId, id: trackId,
@@ -3182,7 +3211,7 @@ describe("Subsonic", () => {
.then((it) => it.stream({ trackId, range: undefined })); .then((it) => it.stream({ trackId, range: undefined }));
expect(streamClientApplication).toHaveBeenCalledWith(track); expect(streamClientApplication).toHaveBeenCalledWith(track);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/stream`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/stream' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
id: trackId, id: trackId,
@@ -3224,7 +3253,7 @@ describe("Subsonic", () => {
.then((it) => it.stream({ trackId, range })); .then((it) => it.stream({ trackId, range }));
expect(streamClientApplication).toHaveBeenCalledWith(track); expect(streamClientApplication).toHaveBeenCalledWith(track);
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/stream`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/stream' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
id: trackId, id: trackId,
@@ -3267,7 +3296,7 @@ describe("Subsonic", () => {
data: streamResponse.data, data: streamResponse.data,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getCoverArt`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getCoverArt' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
id: coverArtId, id: coverArtId,
@@ -3303,7 +3332,7 @@ describe("Subsonic", () => {
data: streamResponse.data, data: streamResponse.data,
}); });
expect(axios.get).toHaveBeenCalledWith(`${url}/rest/getCoverArt`, { expect(axios.get).toHaveBeenCalledWith(url.append({ pathname: '/rest/getCoverArt' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
id: coverArtId, id: coverArtId,
@@ -3429,7 +3458,7 @@ describe("Subsonic", () => {
}); });
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${url}/rest/getCoverArt`, url.append({ pathname: '/rest/getCoverArt' }).href(),
{ {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
@@ -3495,7 +3524,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/star`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/star' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: trackId, id: trackId,
@@ -3528,7 +3557,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/unstar`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/unstar' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: trackId, id: trackId,
@@ -3587,7 +3616,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/setRating`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/setRating' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: trackId, id: trackId,
@@ -3648,14 +3677,14 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/unstar`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/unstar' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: trackId, id: trackId,
}), }),
headers, headers,
}); });
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/setRating`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/setRating' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: trackId, id: trackId,
@@ -3715,7 +3744,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/scrobble`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/scrobble' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id, id,
@@ -3744,7 +3773,7 @@ describe("Subsonic", () => {
expect(result).toEqual(false); expect(result).toEqual(false);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/scrobble`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/scrobble' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id, id,
@@ -3770,7 +3799,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/scrobble`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/scrobble' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id, id,
@@ -3799,7 +3828,7 @@ describe("Subsonic", () => {
expect(result).toEqual(false); expect(result).toEqual(false);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/scrobble`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/scrobble' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id, id,
@@ -3827,7 +3856,7 @@ describe("Subsonic", () => {
expect(result).toEqual([artistToArtistSummary(artist1)]); expect(result).toEqual([artistToArtistSummary(artist1)]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 20, artistCount: 20,
@@ -3861,7 +3890,7 @@ describe("Subsonic", () => {
artistToArtistSummary(artist2), artistToArtistSummary(artist2),
]); ]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 20, artistCount: 20,
@@ -3887,7 +3916,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 20, artistCount: 20,
@@ -3923,7 +3952,7 @@ describe("Subsonic", () => {
expect(result).toEqual([albumToAlbumSummary(album)]); expect(result).toEqual([albumToAlbumSummary(album)]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 0, artistCount: 0,
@@ -3973,7 +4002,7 @@ describe("Subsonic", () => {
albumToAlbumSummary(album2), albumToAlbumSummary(album2),
]); ]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 0, artistCount: 0,
@@ -3999,7 +4028,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 0, artistCount: 0,
@@ -4045,7 +4074,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track]); expect(result).toEqual([track]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 0, artistCount: 0,
@@ -4117,7 +4146,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track1, track2]); expect(result).toEqual([track1, track2]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 0, artistCount: 0,
@@ -4143,7 +4172,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/search3`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/search3' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
artistCount: 0, artistCount: 0,
@@ -4174,7 +4203,7 @@ describe("Subsonic", () => {
expect(result).toEqual([playlist]); expect(result).toEqual([playlist]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getPlaylists`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getPlaylists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -4199,7 +4228,7 @@ describe("Subsonic", () => {
expect(result).toEqual(playlists); expect(result).toEqual(playlists);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getPlaylists`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getPlaylists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -4219,7 +4248,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getPlaylists`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getPlaylists' }).href(), {
params: asURLSearchParams(authParamsPlusJson), params: asURLSearchParams(authParamsPlusJson),
headers, headers,
}); });
@@ -4304,7 +4333,7 @@ describe("Subsonic", () => {
], ],
}); });
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getPlaylist`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getPlaylist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id, id,
@@ -4331,7 +4360,7 @@ describe("Subsonic", () => {
expect(result).toEqual(playlist); expect(result).toEqual(playlist);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getPlaylist`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getPlaylist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id: playlist.id, id: playlist.id,
@@ -4359,7 +4388,7 @@ describe("Subsonic", () => {
expect(result).toEqual({ id, name }); expect(result).toEqual({ id, name });
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/createPlaylist`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/createPlaylist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
f: "json", f: "json",
@@ -4383,7 +4412,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/deletePlaylist`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/deletePlaylist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
id, id,
@@ -4408,7 +4437,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/updatePlaylist`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/updatePlaylist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
playlistId, playlistId,
@@ -4433,7 +4462,7 @@ describe("Subsonic", () => {
expect(result).toEqual(true); expect(result).toEqual(true);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/updatePlaylist`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/updatePlaylist' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParamsPlusJson, ...authParamsPlusJson,
playlistId, playlistId,
@@ -4480,7 +4509,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track1]); expect(result).toEqual([track1]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getSimilarSongs2`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getSimilarSongs2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
f: "json", f: "json",
@@ -4550,7 +4579,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track1, track2, track3]); expect(result).toEqual([track1, track2, track3]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getSimilarSongs2`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getSimilarSongs2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
f: "json", f: "json",
@@ -4577,7 +4606,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getSimilarSongs2`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getSimilarSongs2' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
f: "json", f: "json",
@@ -4644,7 +4673,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track1]); expect(result).toEqual([track1]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getTopSongs`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getTopSongs' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
f: "json", f: "json",
@@ -4711,7 +4740,7 @@ describe("Subsonic", () => {
expect(result).toEqual([track1, track2, track3]); expect(result).toEqual([track1, track2, track3]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getTopSongs`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getTopSongs' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
f: "json", f: "json",
@@ -4751,7 +4780,7 @@ describe("Subsonic", () => {
expect(result).toEqual([]); expect(result).toEqual([]);
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/getTopSongs`, { expect(mockGET).toHaveBeenCalledWith(url.append({ pathname: '/rest/getTopSongs' }).href(), {
params: asURLSearchParams({ params: asURLSearchParams({
...authParams, ...authParams,
f: "json", f: "json",

View File

@@ -50,7 +50,7 @@
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [ "typeRoots": [
"./typings", "./typings",
"node_modules/@types" "./node_modules/@types"
] ]
/* List of folders to include type definitions from. */, /* List of folders to include type definitions from. */,
// "types": ["src/customTypes/scale-that-svg.d.ts"], /* Type declaration files to be included in compilation. */ // "types": ["src/customTypes/scale-that-svg.d.ts"], /* Type declaration files to be included in compilation. */

1238
yarn.lock

File diff suppressed because it is too large Load Diff