Skip to content

Commit

Permalink
test: use different id for song suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitkolhe committed Mar 31, 2024
1 parent 7551975 commit c4277e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('GetSongSuggestions', () => {
})

it('should return suggestions for a song', async () => {
const suggestions = await getSongSuggestions.execute({ songId: '8N_6I8Gn', limit: 5 })
const suggestions = await getSongSuggestions.execute({ songId: 'P3qdsetQ', limit: 5 })

expect(() => SongModel.parse(suggestions[0])).not.toThrow()
expect(suggestions.length).toBe(5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class GetSongSuggestionsUseCase implements IUseCase<GetSongSuggestionsArg
async execute({ songId, limit }: GetSongSuggestionsArgs) {
const stationId = await this.createSongStation.execute(songId)

console.log({ stationId })
const { data, ok } = await useFetch<z.infer<typeof SongSuggestionAPIResponseModel>>({
endpoint: Endpoints.songs.suggestions,
params: {
Expand All @@ -31,19 +32,19 @@ export class GetSongSuggestionsUseCase implements IUseCase<GetSongSuggestionsArg
context: 'android'
})

console.log({ data })

if (!data || !ok) {
throw new HTTPException(404, { message: `no suggestions found for the given song` })
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { stationid, ...suggestions } = data // TODO: find a better way to model the response
const { stationid, ...suggestions } = data

const songs =
return (
Object.values(suggestions)
.map((element) => element && createSongPayload(element.song))
.filter(Boolean)
.slice(0, limit) || []

return songs
)
}
}

0 comments on commit c4277e3

Please sign in to comment.