feat: Add unit-tests #25

Merged
timharek merged 31 commits from feature-testing into main 2024-04-11 19:10:16 +00:00
1 changed files with 5 additions and 1 deletions
Showing only changes of commit d9480096f5 - Show all commits

View File

@ -23,7 +23,7 @@ type UpdatedSeries = {
lastFetch: Date;
episodes: Episode[];
} & Series;
async function updateFetch(existingSeries: Series): Promise<UpdatedSeries | null> {
async function updateFetch(existingSeries: Series): Promise<UpdatedSeries | Series | null> {
const series = await nrkRadio.getSeries(existingSeries.id);
if (!series) {
return null;
@ -32,6 +32,10 @@ async function updateFetch(existingSeries: Series): Promise<UpdatedSeries | null
return !existingSeries.episodes.find((serieEpisode) => serieEpisode.id === episode.id);
});
if (newEpisodes.length === 0) {
return existingSeries;
}
/**
* Since we don't control the API,
* we should not make assumptions about the order,