Further refactoring of the queue controller and view

- Removes queue-related functions from the main controller. They are now handled by queue.js, which delegates them to player-service.js
- Fixes problem in scrobbling. A song is no longer scrobbled every time it is paused. A song will not be scrobbled upon loading, only while it is playing.
- Moves the entire html for the sidebar queue to queue.html. It replaces a template that was no longer used.
- Most queue-related functions in player return player itself to make them chainable just like in jQuery, e.g. : player.shuffleQueue().playFirstSong();
This commit is contained in:
Hyzual 2015-01-03 14:07:22 +01:00
parent 83869b7808
commit c787c468b9
12 changed files with 85 additions and 89 deletions

View file

@ -22,49 +22,41 @@ describe("Queue controller", function() {
});
});
it("When I call playSong, it calls play in the player service", function() {
it("When I play a song, it calls play in the player service", function() {
spyOn(player, "play");
var songIndexInQueue = 3;
scope.playSong(songIndexInQueue);
expect(player.play).toHaveBeenCalledWith(songIndexInQueue);
scope.playSong(song);
expect(player.play).toHaveBeenCalledWith(song);
});
it("When I call queueEmpty, it calls emptyQueue in the player service", function() {
it("When I empty the queue, it calls emptyQueue in the player service", function() {
spyOn(player, "emptyQueue");
scope.queueEmpty();
scope.emptyQueue();
expect(player.emptyQueue).toHaveBeenCalled();
});
it("When I call queueShuffle, it calls shuffleQueue in the player service", function() {
it("When I shuffle the queue, it calls shuffleQueue in the player service", function() {
spyOn(player, "shuffleQueue");
scope.queueShuffle();
scope.shuffleQueue();
expect(player.shuffleQueue).toHaveBeenCalled();
});
it("When I add one song to the queue, it calls addSong in the player service", function() {
spyOn(player, "addSong");
scope.addSongToQueue(song);
expect(player.addSong).toHaveBeenCalledWith(song);
});
xit("When I add many songs to the queue, it calls addSong in the player service", function() {
spyOn(player, "addSong");
});
it("When I remove a song from the queue, it calls removeSong in the player service", function() {
spyOn(player, "removeSong");
scope.removeSongFromQueue(song);
expect(player.removeSong).toHaveBeenCalledWith(song);
});
it("When I remove all the selected songs from the queue, it calls removeSongs in the player service", function() {
spyOn(player, "removeSongs");
var secondSong = { id: 6791 };
scope.selectedSongs = [song, secondSong];
scope.removeSelectedSongsFromQueue();
expect(player.removeSongs).toHaveBeenCalledWith([song, secondSong]);
});
});