Ability to list tracks on an album

This commit is contained in:
simojenki
2021-03-08 11:26:24 +11:00
parent 07b00f00f2
commit 081819f12b
8 changed files with 361 additions and 76 deletions

View File

@@ -83,6 +83,9 @@ export function anArtist(fields: Partial<Artist> = {}): Artist {
};
}
export const SAMPLE_GENRES = ["Metal", "Pop", "Rock", "Hip-Hop"]
export const randomGenre = () => SAMPLE_GENRES[randomInt(SAMPLE_GENRES.length)]
export function aTrack(fields: Partial<Track> = {}): Track {
const id = uuid();
return {
@@ -90,19 +93,21 @@ export function aTrack(fields: Partial<Track> = {}): Track {
name: `Track ${id}`,
mimeType: `audio/mp3-${id}`,
duration: `${randomInt(500)}`,
number: `${randomInt(100)}`,
genre: randomGenre(),
artist: anArtist(),
album: anAlbum(),
...fields
}
}
export function anAlbum(fields: Partial<Album> = {}): Album {
const genres = ["Metal", "Pop", "Rock", "Hip-Hop"];
const id = uuid();
return {
id,
name: `Album ${id}`,
genre: genres[randomInt(genres.length)],
genre: randomGenre(),
year: `19${randomInt(99)}`,
tracks: [aTrack(), aTrack(), aTrack()],
...fields,
};
}