Jamstash/app/queue/queue_test.js
Hyzual 3c809d1903 Adds back displaying the currently playing song as such in the queue
We no longer alter the song, the queue gets this from the player.
That way we can't have two songs marked as 'playing' at the same time.
2015-01-17 19:15:07 +01:00

67 lines
2.3 KiB
JavaScript

describe("Queue controller", function() {
'use strict';
var player, scope, globals;
var song;
beforeEach(function() {
module('jamstash.queue.controller');
inject(function ($controller, $rootScope, _globals_, _player_) {
scope = $rootScope.$new();
globals = _globals_;
player = _player_;
$controller('QueueController', {
$scope: scope,
globals: globals,
player: player
});
});
song = { id: 7310 };
});
it("When I play a song, it calls play in the player service", function() {
spyOn(player, "play");
scope.playSong(song);
expect(player.play).toHaveBeenCalledWith(song);
});
it("When I empty the queue, it calls emptyQueue in the player service", function() {
spyOn(player, "emptyQueue");
scope.emptyQueue();
expect(player.emptyQueue).toHaveBeenCalled();
});
it("When I shuffle the queue, it calls shuffleQueue in the player service", function() {
spyOn(player, "shuffleQueue");
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);
});
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]);
});
it("asks the player service if a given song is the currently playing song", function() {
spyOn(player, "getPlayingSong").and.returnValue(song);
expect(scope.isPlayingSong(song)).toBeTruthy();
expect(player.getPlayingSong).toHaveBeenCalled();
});
});