describe("getEpisode", async () => {
test("returns an episode object", async () => {
const episode_id = "123";
const market = "EN" as Market;
const spotify_episode_response = {
description:
"A Spotify podcast sharing fresh insights on important topics of the moment—in a way only Spotify can. You’ll hear from experts in the music, podcast and tech industries as we discover and uncover stories about our work and the world around us.",
html_description:
"<p>A Spotify podcast sharing fresh insights on important topics of the moment—in a way only Spotify can. You’ll hear from experts in the music, podcast and tech industries as we discover and uncover stories about our work and the world around us.</p>",
duration_ms: 1686230,
explicit: false,
external_urls: {
spotify: "string"
},
href: "https://api.spotify.com/v1/episodes/5Xt5DXGzch68nYYamXrNxZ",
id: "5Xt5DXGzch68nYYamXrNxZ",
images: [
{
url: "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228",
height: 300,
width: 300
}
],
is_externally_hosted: false,
is_playable: false,
language: "en",
languages: ["fr", "en"],
name: "Starting Your Own Podcast: Tips, Tricks, and Advice From Anchor Creators",
release_date: "1981-12-15",
release_date_precision: "day",
resume_point: {
fully_played: false,
resume_position_ms: 0
},
type: "episode",
uri: "spotify:episode:0zLhl3WsOCQHbe1BPTiHgr",
restrictions: {
reason: "string"
},
show: {
available_markets: ["string"],
copyrights: [
{
text: "string",
type: "string"
}
],
description: "string",
html_description: "string",
explicit: false,
external_urls: {
spotify: "string"
},
href: "string",
id: "string",
images: [
{
url: "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228",
height: 300,
width: 300
}
],
languages: ["string"],
media_type: "string",
name: "string",
publisher: "string",
type: "show",
uri: "string",
total_episodes: 0
}
};
const mockedFetch = vi.fn();
mockedFetch.mockResolvedValue(spotify_episode_response);
const client: HTTPClient = {
fetch: mockedFetch
};
const result = await getEpisode(client, episode_id, market);
expect(client.fetch).toHaveBeenCalledWith(
`/episodes/${episode_id}`,
"json",
{ query: { market } }
);
expect(result).toBeDefined();
expect(result).toMatchObject(spotify_episode_response);
});
});
There is what i got for getEpisode, wanna see you opinion is this enough or we need more tests for api methods. Because I think it's not full. Or, I just want to see you @MellKam code for this tests as a example.