From e74bd9efd4f15646ad9a2342ded294b11dc1fd13 Mon Sep 17 00:00:00 2001 From: NahGoKrazy Date: Tue, 24 Sep 2024 18:31:12 -0400 Subject: [PATCH] stuff --- server/services/tests/trackQueue.test.ts | 70 ++++++++++++++++++++++++ server/services/trackQueue.ts | 13 ++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/server/services/tests/trackQueue.test.ts b/server/services/tests/trackQueue.test.ts index 584bf0b..aedb5c2 100644 --- a/server/services/tests/trackQueue.test.ts +++ b/server/services/tests/trackQueue.test.ts @@ -1,5 +1,6 @@ import { TrackQueueItem } from '../trackQueue' import { TrackQueue } from '../trackQueue' +import type { Track } from '@spotify/web-api-ts-sdk' describe('Test TackQue', () => { @@ -14,3 +15,72 @@ describe('Test TackQue', () => { // it('should not pop track if peeked', () => {}) }) + +//sample track +const sometrack: Track = { + id: '1', + name: 'Test Track', + duration_ms: 300000, // The track's duration in milliseconds + album: { + id: 'album-id', + name: 'Test Album', + album_type: 'album', + album_group: 'album', + artists: [], + available_markets: [], + href: 'https://api.spotify.com/v1/albums/album-id', + images: [], + release_date: '2021-01-01', + release_date_precision: 'day', + total_tracks: 10, + type: 'album', + uri: 'spotify:album:album-id', + copyrights: [ + { text: '© 2021 Test Label', type: 'C' }, + { text: '℗ 2021 Test Label', type: 'P' } + ], + external_ids: { + upc: '123456789012', // Example UPC + ean: '1234567890123', // Example EAN + isrc: 'USUM71702776' // Example ISRC + }, + external_urls: { + spotify: 'https://open.spotify.com/album/album-id' + }, + genres: ['pop'], + label: 'Test Label', + popularity: 75 + }, + external_ids: { + upc: '123456789012', // Required UPC field + ean: '1234567890123', // Required EAN field + isrc: 'USUM71702776' // Required ISRC field + }, + popularity: 0, + artists: [ + { + id: 'artist1', + name: 'Artist 1', + href: '', + external_urls: { + spotify: 'https://open.spotify.com/artist/1' + }, + type: 'artist', + uri: 'spotify:artist:1' + } + ], + available_markets: [], + disc_number: 1, + episode: false, + explicit: false, + external_urls: { + spotify: 'https://open.spotify.com/track/1' + }, + href: 'https://api.spotify.com/v1/tracks/1', + is_local: false, + preview_url: null, + track: true, + track_number: 1, + type: 'track', + uri: 'spotify:track:1' +}; diff --git a/server/services/trackQueue.ts b/server/services/trackQueue.ts index db02960..c03848a 100644 --- a/server/services/trackQueue.ts +++ b/server/services/trackQueue.ts @@ -11,13 +11,24 @@ export class TrackQueue { constructor(readonly groupId: string) {} public push(track: Track): number { - throw new NotImplementedError('TrackQueue.push') + this.tracks.push(new TrackQueueItem(track)); + return 0; + // throw new NotImplementedError('TrackQueue.push') } public pop(): Track { + this.tracks.pop(); throw new NotImplementedError('TrackQueue.pop') } public peek(): Track { + return this.tracks[-1].track; throw new NotImplementedError('TrackQueue.peek') } public setPosition(track: Track, pos: number) {} + } + +// export interface Track extends SimplifiedTrack { +// album: SimplifiedAlbum; +// external_ids: ExternalIds; +// popularity: number; +// } \ No newline at end of file