mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-31 15:37:51 +01:00
feat(ui): add an explainArtwork data provider method
This commit is contained in:
parent
0fcce273a2
commit
d17ef212ab
2 changed files with 23 additions and 0 deletions
|
|
@ -229,6 +229,10 @@ const wrapperDataProvider = {
|
|||
httpClient(`${REST_URL}/metadata/${REFRESH_KIND[resource]}/${id}/refresh`, {
|
||||
method: 'POST',
|
||||
}).then(() => ({ data: { id } })),
|
||||
explainArtwork: (resource, id) =>
|
||||
httpClient(
|
||||
`${REST_URL}/artwork/explain?kind=${REFRESH_KIND[resource]}&id=${encodeURIComponent(id)}`,
|
||||
).then(({ json }) => ({ data: json })),
|
||||
}
|
||||
|
||||
export default wrapperDataProvider
|
||||
|
|
|
|||
|
|
@ -120,4 +120,23 @@ describe('wrapperDataProvider', () => {
|
|||
).resolves.toEqual({ data: { id: 'al-1' } })
|
||||
})
|
||||
})
|
||||
|
||||
describe('explainArtwork', () => {
|
||||
it('requests the artist kind prefix', async () => {
|
||||
mockHttpClient.mockResolvedValue({ json: { name: 'Radiohead' } })
|
||||
const result = await wrapperDataProvider.explainArtwork('artist', 'ar-1')
|
||||
expect(mockHttpClient).toHaveBeenCalledWith(
|
||||
expect.stringContaining('/artwork/explain?kind=ar&id=ar-1'),
|
||||
)
|
||||
expect(result).toEqual({ data: { name: 'Radiohead' } })
|
||||
})
|
||||
|
||||
it('requests the album kind prefix', async () => {
|
||||
mockHttpClient.mockResolvedValue({ json: {} })
|
||||
await wrapperDataProvider.explainArtwork('album', 'al-1')
|
||||
expect(mockHttpClient).toHaveBeenCalledWith(
|
||||
expect.stringContaining('kind=al&id=al-1'),
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue