const { Track } = require('../src/track') describe('track basic manipulations', () => { const t1 = new Track() const t2 = new Track({ title: 'HomeoJuliette', url: 'https://www.youtube.com/watch?v=WLXCTvMtY5Y', length: 204, source: 'youtube' }) const t2_clone = t2.clone(); test('empty track', () => { expect(t1.get_url()).toBeFalsy() expect(t1.get_url()).toBeFalsy() expect(t1.get_title()).toBeFalsy() expect(t1.get_full_title()).toBeFalsy() expect(t1.get_length()).toBeFalsy() expect(t1.get_source()).toBeFalsy() expect(t1.toString()).toBe('undefined (NaN:NaN)') expect(t1.toJSON().play_count).toBe(0) expect(t1.toJSON().last_played).toBe(0) }) test('track with metadata', () => { expect(t2.get_url()).toBe('https://www.youtube.com/watch?v=WLXCTvMtY5Y') expect(t2.get_title()).toBe('HomeoJuliette') expect(t2.get_full_title()).toBe('HomeoJuliette') expect(t2.get_length()).toBe(204) expect(t2.get_source()).toBe('youtube') expect(t2.toString()).toBe('HomeoJuliette (3:24)') expect(t2.toJSON().play_count).toBe(0) expect(t2.toJSON().last_played).toBe(0) expect(t2.toJSON()).toEqual(t2_clone.toJSON()) expect(t2 == t2_clone).toBeFalsy() }) test('update play count', () => { t2.update_play_count() expect(t2.toJSON().play_count).toBe(1) expect(t2.toJSON().last_played).toBeGreaterThan(0) }) })