diff --git a/src/parsers/spotify.ts b/src/parsers/spotify.ts index 77da15e..f20fdbc 100644 --- a/src/parsers/spotify.ts +++ b/src/parsers/spotify.ts @@ -36,9 +36,7 @@ export const parseSpotifyMetadata = async ( : metaTagContent(doc, 'og:type', 'property'); if (!title || !description || !type || !image) { - throw new Error( - `Could not parse Spotify metadata. ${title} ${description} ${type} ${image}` - ); + throw new Error(`Could not parse Spotify metadata.`); } return { diff --git a/tests/integration/api.test.ts b/tests/integration/api.test.ts index 9ba330e..72f1013 100644 --- a/tests/integration/api.test.ts +++ b/tests/integration/api.test.ts @@ -615,6 +615,20 @@ describe('Api router', () => { expect(redisSetMock).toHaveBeenCalledTimes(0); }); + it('should return unknown error - could not parse Spotify metadata', async () => { + const request = new Request(`${endpoint}?spotifyLink=${cachedSpotifyLink}`); + + mock.onGet(cachedSpotifyLink).reply(200, ''); + + const response = await app.handle(request).then(res => res.json()); + + expect(response).toEqual({ + code: 'UNKNOWN', + message: + '[Spotify Parser] (https://open.spotify.com/track/2KvHC9z14GSl4YpkNMX384) Error: Could not parse Spotify metadata.', + }); + }); + it('should return bad request - invalid spotifyLink', async () => { const spotifyLink = 'https://open.spotify.com/invalid';