2015-12-13 04:42:28 +00:00
|
|
|
require('chai').should();
|
|
|
|
|
|
|
|
import queueStore from '../../stores/queue';
|
|
|
|
import artists from '../blobs/media';
|
|
|
|
|
2016-03-28 13:38:14 +00:00
|
|
|
const songs = artists[2].albums[0].songs;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
describe('stores/queue', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
queueStore.state.songs = songs;
|
|
|
|
queueStore.state.current = songs[1];
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#all', () => {
|
|
|
|
it('correctly returns all queued songs', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.all.should.equal(songs);
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#first', () => {
|
|
|
|
it('correctly returns the first queued song', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.first.title.should.equal('No bravery');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#last', () => {
|
|
|
|
it('correctly returns the last queued song', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.last.title.should.equal('Tears and rain');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#queue', () => {
|
2015-12-14 13:13:12 +00:00
|
|
|
beforeEach(() => queueStore.state.songs = songs);
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-03-28 13:38:14 +00:00
|
|
|
const song = artists[0].albums[0].songs[0];
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
it('correctly appends a song to end of the queue', () => {
|
|
|
|
queueStore.queue(song);
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.last.title.should.equal('I Swear');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly prepends a song to top of the queue', () => {
|
|
|
|
queueStore.queue(song, false, true);
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.first.title.should.equal('I Swear');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly replaces the whole queue', () => {
|
|
|
|
queueStore.queue(song, true);
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.all.length.should.equal(1);
|
|
|
|
queueStore.first.title.should.equal('I Swear');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#unqueue', () => {
|
2015-12-14 13:13:12 +00:00
|
|
|
beforeEach(() => queueStore.state.songs = songs);
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
it('correctly removes a song from queue', () => {
|
|
|
|
queueStore.unqueue(queueStore.state.songs[0]);
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.first.title.should.equal('So long, Jimmy'); // Oh the irony.
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly removes mutiple songs from queue', () => {
|
|
|
|
queueStore.unqueue([queueStore.state.songs[0], queueStore.state.songs[1]]);
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.first.title.should.equal('Wisemen');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#clear', () => {
|
|
|
|
it('correctly clears all songs from queue', () => {
|
|
|
|
queueStore.clear();
|
|
|
|
queueStore.state.songs.length.should.equal(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#current', () => {
|
|
|
|
it('returns the correct current song', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.current.title.should.equal('So long, Jimmy');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('successfully sets the current song', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.current = queueStore.state.songs[0];
|
|
|
|
queueStore.current.title.should.equal('No bravery');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#getNextSong', () => {
|
|
|
|
it('correctly gets the next song in queue', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.next.title.should.equal('Wisemen');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly returns null if at end of queue', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.current = queueStore.state.songs[queueStore.state.songs.length - 1];
|
|
|
|
(queueStore.next === null).should.be.true;
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#getPrevSong', () => {
|
|
|
|
it('correctly gets the previous song in queue', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.previous.title.should.equal('No bravery');
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly returns null if at end of queue', () => {
|
2016-03-18 04:45:12 +00:00
|
|
|
queueStore.current = queueStore.state.songs[0];
|
|
|
|
(queueStore.previous === null).should.be.true;
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|