Minor code style adjustments to comply with our jscsrc.
This commit is contained in:
parent
66478bf67e
commit
58829facd6
16 changed files with 547 additions and 505 deletions
|
@ -1,10 +1,10 @@
|
||||||
describe("archive service", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("archive service", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var archive, mockBackend, mockGlobals, utils,
|
var archive, mockBackend, mockGlobals, utils;
|
||||||
response;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
|
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
archiveUrl: "http://hysterotomy.com/hippolytus/quercitrin?a=chillagite&b=savour#superfecundation"
|
archiveUrl: "http://hysterotomy.com/hippolytus/quercitrin?a=chillagite&b=savour#superfecundation"
|
||||||
|
@ -32,13 +32,13 @@ describe("archive service", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function () {
|
||||||
mockBackend.verifyNoOutstandingExpectation();
|
mockBackend.verifyNoOutstandingExpectation();
|
||||||
mockBackend.verifyNoOutstandingRequest();
|
mockBackend.verifyNoOutstandingRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("mapAlbum() -", function() {
|
describe("mapAlbum() -", function () {
|
||||||
it("Given album data with a publicDate defined, when I map it to an Album, then utils.formatDate will be called", function() {
|
it("Given album data with a publicDate defined, when I map it to an Album, then utils.formatDate will be called", function () {
|
||||||
var albumData = {
|
var albumData = {
|
||||||
id: 504,
|
id: 504,
|
||||||
publicDate: "2015-03-29T18:22:06.000Z",
|
publicDate: "2015-03-29T18:22:06.000Z",
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
describe("Main controller", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Main controller", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var controllerParams, $controller, $q, scope, mockGlobals, player, utils, persistence, subsonic, notifications,
|
var controllerParams, $controller, $q, scope, mockGlobals, player, utils, persistence, subsonic, notifications,
|
||||||
deferred;
|
deferred;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
settings: {
|
settings: {
|
||||||
SaveTrackPosition: false,
|
SaveTrackPosition: false,
|
||||||
|
@ -13,7 +14,7 @@ describe("Main controller", function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module('JamStash', function($provide) {
|
module('JamStash', function ($provide) {
|
||||||
$provide.value('globals', mockGlobals);
|
$provide.value('globals', mockGlobals);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -77,16 +78,16 @@ describe("Main controller", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
xdescribe("toggleSetting -", function() {
|
xdescribe("toggleSetting -", function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("", function () {
|
describe("", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
$controller('AppController', controllerParams);
|
$controller('AppController', controllerParams);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("given that the global setting 'ShowQueue' is true, when the playing queue's length changes and is not empty, it shows the queue", function() {
|
it("given that the global setting 'ShowQueue' is true, when the playing queue's length changes and is not empty, it shows the queue", function () {
|
||||||
mockGlobals.settings.ShowQueue = true;
|
mockGlobals.settings.ShowQueue = true;
|
||||||
player.queue = [{
|
player.queue = [{
|
||||||
id: 684
|
id: 684
|
||||||
|
@ -98,8 +99,8 @@ describe("Main controller", function() {
|
||||||
expect(scope.showQueue).toHaveBeenCalled();
|
expect(scope.showQueue).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When I toggle pause,", function() {
|
describe("When I toggle pause,", function () {
|
||||||
it("given that we're using the Jukebox mode, it sends a 'stop' command to the jukebox", function() {
|
it("given that we're using the Jukebox mode, it sends a 'stop' command to the jukebox", function () {
|
||||||
mockGlobals.settings.Jukebox = true;
|
mockGlobals.settings.Jukebox = true;
|
||||||
spyOn(scope, "sendToJukebox");
|
spyOn(scope, "sendToJukebox");
|
||||||
|
|
||||||
|
@ -107,13 +108,13 @@ describe("Main controller", function() {
|
||||||
expect(scope.sendToJukebox).toHaveBeenCalledWith('stop');
|
expect(scope.sendToJukebox).toHaveBeenCalledWith('stop');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("it toggles pause using the player service", function() {
|
it("it toggles pause using the player service", function () {
|
||||||
scope.togglePause();
|
scope.togglePause();
|
||||||
expect(player.togglePause).toHaveBeenCalled();
|
expect(player.togglePause).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I turn the volume up, it sets the player's volume up and saves it using the persistence service", function() {
|
it("When I turn the volume up, it sets the player's volume up and saves it using the persistence service", function () {
|
||||||
player.turnVolumeUp.and.returnValue(0.6);
|
player.turnVolumeUp.and.returnValue(0.6);
|
||||||
scope.turnVolumeUp();
|
scope.turnVolumeUp();
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ describe("Main controller", function() {
|
||||||
expect(persistence.saveVolume).toHaveBeenCalledWith(0.6);
|
expect(persistence.saveVolume).toHaveBeenCalledWith(0.6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I turn the volume down, it sets the player's volume down and saves it using the persistence service", function() {
|
it("When I turn the volume down, it sets the player's volume down and saves it using the persistence service", function () {
|
||||||
player.turnVolumeDown.and.returnValue(0.4);
|
player.turnVolumeDown.and.returnValue(0.4);
|
||||||
scope.turnVolumeDown();
|
scope.turnVolumeDown();
|
||||||
|
|
||||||
|
@ -129,57 +130,57 @@ describe("Main controller", function() {
|
||||||
expect(persistence.saveVolume).toHaveBeenCalledWith(0.4);
|
expect(persistence.saveVolume).toHaveBeenCalledWith(0.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I go to the next track, it calls next track on the player", function() {
|
it("When I go to the next track, it calls next track on the player", function () {
|
||||||
scope.nextTrack();
|
scope.nextTrack();
|
||||||
expect(player.nextTrack).toHaveBeenCalled();
|
expect(player.nextTrack).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I go to the previous track, it calls previous track on the player", function() {
|
it("When I go to the previous track, it calls previous track on the player", function () {
|
||||||
scope.previousTrack();
|
scope.previousTrack();
|
||||||
expect(player.previousTrack).toHaveBeenCalled();
|
expect(player.previousTrack).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Given that I am targeting an input,", function() {
|
describe("Given that I am targeting an input,", function () {
|
||||||
var event;
|
var event;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
event = { target: { tagName: "INPUT" } };
|
event = { target: { tagName: "INPUT" } };
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I use a shortcut to toggle pause, it doesn't do anything", function() {
|
it("when I use a shortcut to toggle pause, it doesn't do anything", function () {
|
||||||
scope.togglePause(event);
|
scope.togglePause(event);
|
||||||
expect(player.togglePause).not.toHaveBeenCalled();
|
expect(player.togglePause).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I use a shortcut to turn the volume up, it doesn't do anything", function() {
|
it("when I use a shortcut to turn the volume up, it doesn't do anything", function () {
|
||||||
scope.turnVolumeUp(event);
|
scope.turnVolumeUp(event);
|
||||||
expect(player.turnVolumeUp).not.toHaveBeenCalled();
|
expect(player.turnVolumeUp).not.toHaveBeenCalled();
|
||||||
expect(persistence.saveVolume).not.toHaveBeenCalled();
|
expect(persistence.saveVolume).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I use a shortcut to turn the volume down, it doesn't do anything", function() {
|
it("when I use a shortcut to turn the volume down, it doesn't do anything", function () {
|
||||||
scope.turnVolumeDown(event);
|
scope.turnVolumeDown(event);
|
||||||
expect(player.turnVolumeDown).not.toHaveBeenCalled();
|
expect(player.turnVolumeDown).not.toHaveBeenCalled();
|
||||||
expect(persistence.saveVolume).not.toHaveBeenCalled();
|
expect(persistence.saveVolume).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I use a shortcut to go to the next track, it doesn't do anything", function() {
|
it("when I use a shortcut to go to the next track, it doesn't do anything", function () {
|
||||||
scope.nextTrack(event);
|
scope.nextTrack(event);
|
||||||
expect(player.nextTrack).not.toHaveBeenCalled();
|
expect(player.nextTrack).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I use a shortcut to go to the previous track, it doesn't do anything", function() {
|
it("when I use a shortcut to go to the previous track, it doesn't do anything", function () {
|
||||||
scope.previousTrack(event);
|
scope.previousTrack(event);
|
||||||
expect(player.previousTrack).not.toHaveBeenCalled();
|
expect(player.previousTrack).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("loadSettings() -", function() {
|
describe("loadSettings() -", function () {
|
||||||
it("Given user settings were saved using persistence, when I load the settings, the globals object will be completed with them, excluding the Url setting", function() {
|
it("Given user settings were saved using persistence, when I load the settings, the globals object will be completed with them, excluding the Url setting", function () {
|
||||||
persistence.getSettings.and.returnValue({
|
persistence.getSettings.and.returnValue({
|
||||||
"Url": "http://gmelinite.com/contrastive/hypercyanotic?a=overdrive&b=chirpling#postjugular",
|
Url: "http://gmelinite.com/contrastive/hypercyanotic?a=overdrive&b=chirpling#postjugular",
|
||||||
"Username": "Hollingshead",
|
Username: "Hollingshead",
|
||||||
"AutoPlaylistSize": 25,
|
AutoPlaylistSize: 25,
|
||||||
"AutoPlay": true
|
AutoPlay: true
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.loadSettings();
|
scope.loadSettings();
|
||||||
|
@ -191,12 +192,12 @@ describe("Main controller", function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("toggleStar() -", function() {
|
describe("toggleStar() -", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
subsonic.toggleStar.and.returnValue(deferred.promise);
|
subsonic.toggleStar.and.returnValue(deferred.promise);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given an artist that was not starred, when I toggle its star, then subsonic service will be called, the artist will be starred and a notification will be displayed", function() {
|
it("Given an artist that was not starred, when I toggle its star, then subsonic service will be called, the artist will be starred and a notification will be displayed", function () {
|
||||||
var artist = { id: 4218, starred: false };
|
var artist = { id: 4218, starred: false };
|
||||||
scope.toggleStar(artist);
|
scope.toggleStar(artist);
|
||||||
deferred.resolve(true);
|
deferred.resolve(true);
|
||||||
|
@ -207,7 +208,7 @@ describe("Main controller", function() {
|
||||||
expect(notifications.updateMessage).toHaveBeenCalledWith('Favorite Updated!', true);
|
expect(notifications.updateMessage).toHaveBeenCalledWith('Favorite Updated!', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a song that was starred, when I toggle its star, then subsonic service will be called, the song will be starred and a notification will be displayed", function() {
|
it("Given a song that was starred, when I toggle its star, then subsonic service will be called, the song will be starred and a notification will be displayed", function () {
|
||||||
var song = { id: 784, starred: true };
|
var song = { id: 784, starred: true };
|
||||||
scope.toggleStar(song);
|
scope.toggleStar(song);
|
||||||
deferred.resolve(false);
|
deferred.resolve(false);
|
||||||
|
@ -220,8 +221,8 @@ describe("Main controller", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When starting up,", function() {
|
describe("When starting up,", function () {
|
||||||
it("it loads the volume from the persistence service and sets the player service's volume with it", function() {
|
it("it loads the volume from the persistence service and sets the player service's volume with it", function () {
|
||||||
persistence.getVolume.and.returnValue(0.551835);
|
persistence.getVolume.and.returnValue(0.551835);
|
||||||
|
|
||||||
$controller('AppController', controllerParams);
|
$controller('AppController', controllerParams);
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
describe("model service", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("model service", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var model, map, utils;
|
var model, map, utils;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.model', function ($provide) {
|
module('jamstash.model', function ($provide) {
|
||||||
$provide.decorator('utils', function ($delegate) {
|
$provide.decorator('utils', function ($delegate) {
|
||||||
$delegate.formatDate = jasmine.createSpy("formatDate");
|
$delegate.formatDate = jasmine.createSpy("formatDate");
|
||||||
|
@ -16,7 +17,7 @@ describe("model service", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("given all the arguments, when calling Song() then the composite attributes are computed", function() {
|
it("given all the arguments, when calling Song() then the composite attributes are computed", function () {
|
||||||
model.Song(21, 43, 3, "Know Your Enemy", "Yoko Kanno", "27", "Ghost in the Shell - Stand Alone Complex OST 3",
|
model.Song(21, 43, 3, "Know Your Enemy", "Yoko Kanno", "27", "Ghost in the Shell - Stand Alone Complex OST 3",
|
||||||
"51", "cover.jpg", "big-cover.jpg", "385", "5", true, "mp3", "specs", "url", "0", "Awesome track");
|
"51", "cover.jpg", "big-cover.jpg", "385", "5", true, "mp3", "specs", "url", "0", "Awesome track");
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ describe("model service", function() {
|
||||||
expect(model.displayName).toBe("Know Your Enemy - Ghost in the Shell - Stand Alone Complex OST 3 - Yoko Kanno");
|
expect(model.displayName).toBe("Know Your Enemy - Ghost in the Shell - Stand Alone Complex OST 3 - Yoko Kanno");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given multiple songs, when I map them, then mapSong is called for each song", function() {
|
it("Given multiple songs, when I map them, then mapSong is called for each song", function () {
|
||||||
var songs = [
|
var songs = [
|
||||||
{ id: 2912 },
|
{ id: 2912 },
|
||||||
{ id: 1450 },
|
{ id: 1450 },
|
||||||
|
@ -36,13 +37,13 @@ describe("model service", function() {
|
||||||
|
|
||||||
var result = map.mapSongs(songs);
|
var result = map.mapSongs(songs);
|
||||||
expect(map.mapSong.calls.count()).toEqual(3);
|
expect(map.mapSong.calls.count()).toEqual(3);
|
||||||
expect(map.mapSong).toHaveBeenCalledWith({id: 2912});
|
expect(map.mapSong).toHaveBeenCalledWith({ id: 2912 });
|
||||||
expect(map.mapSong).toHaveBeenCalledWith({id: 1450});
|
expect(map.mapSong).toHaveBeenCalledWith({ id: 1450 });
|
||||||
expect(map.mapSong).toHaveBeenCalledWith({id: 6663});
|
expect(map.mapSong).toHaveBeenCalledWith({ id: 6663 });
|
||||||
expect(result).toEqual(songs);
|
expect(result).toEqual(songs);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given multiple podcast episodes, when I map them, then mapPodcast is called for each episode", function() {
|
it("Given multiple podcast episodes, when I map them, then mapPodcast is called for each episode", function () {
|
||||||
var episodes = [
|
var episodes = [
|
||||||
{ id: 63 },
|
{ id: 63 },
|
||||||
{ id: 24 },
|
{ id: 24 },
|
||||||
|
@ -58,7 +59,7 @@ describe("model service", function() {
|
||||||
expect(result).toEqual(episodes);
|
expect(result).toEqual(episodes);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given album data without artist info, when I map it to an Album, then an Album with an empty artist name will be returned", function() {
|
it("Given album data without artist info, when I map it to an Album, then an Album with an empty artist name will be returned", function () {
|
||||||
var albumData = {
|
var albumData = {
|
||||||
id: 584,
|
id: 584,
|
||||||
artist: undefined,
|
artist: undefined,
|
||||||
|
@ -69,7 +70,7 @@ describe("model service", function() {
|
||||||
expect(result.artist).toEqual('');
|
expect(result.artist).toEqual('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given multiple albums, when I map them, then mapAlbum is called for each album", function() {
|
it("Given multiple albums, when I map them, then mapAlbum is called for each album", function () {
|
||||||
var albums = [
|
var albums = [
|
||||||
{ id: 941 },
|
{ id: 941 },
|
||||||
{ id: 967 },
|
{ id: 967 },
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
describe("Notifications service - ", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Notifications service - ", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var notifications, $window, $interval, player, utils, mockGlobals,
|
var notifications, $window, $interval, player, utils, mockGlobals,
|
||||||
NotificationObj;
|
NotificationObj;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
settings: {
|
settings: {
|
||||||
Timeout: 30000
|
Timeout: 30000
|
||||||
|
@ -34,21 +35,21 @@ describe("Notifications service - ", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can check whether we have the permission to display notifications in the current browser", function() {
|
it("can check whether we have the permission to display notifications in the current browser", function () {
|
||||||
$window.Notify.needsPermission.and.returnValue(false);
|
$window.Notify.needsPermission.and.returnValue(false);
|
||||||
|
|
||||||
expect(notifications.hasPermission()).toBeTruthy();
|
expect(notifications.hasPermission()).toBeTruthy();
|
||||||
expect($window.Notify.needsPermission).toHaveBeenCalled();
|
expect($window.Notify.needsPermission).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can check whether the current browser supports notifications", function() {
|
it("can check whether the current browser supports notifications", function () {
|
||||||
$window.Notify.isSupported.and.returnValue(true);
|
$window.Notify.isSupported.and.returnValue(true);
|
||||||
|
|
||||||
expect(notifications.isSupported()).toBeTruthy();
|
expect(notifications.isSupported()).toBeTruthy();
|
||||||
expect($window.Notify.isSupported).toHaveBeenCalled();
|
expect($window.Notify.isSupported).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can request Notification permission for the current browser", function() {
|
it("can request Notification permission for the current browser", function () {
|
||||||
spyOn(notifications, "isSupported").and.returnValue(true);
|
spyOn(notifications, "isSupported").and.returnValue(true);
|
||||||
spyOn(notifications, "hasPermission").and.returnValue(false);
|
spyOn(notifications, "hasPermission").and.returnValue(false);
|
||||||
|
|
||||||
|
@ -57,9 +58,9 @@ describe("Notifications service - ", function() {
|
||||||
expect($window.Notify.requestPermission).toHaveBeenCalled();
|
expect($window.Notify.requestPermission).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When I show a notification, given a song,", function() {
|
describe("When I show a notification, given a song,", function () {
|
||||||
var song;
|
var song;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
song = {
|
song = {
|
||||||
coverartthumb: "https://backjaw.com/overquantity/outpitch?a=redredge&b=omnivoracious#promotement",
|
coverartthumb: "https://backjaw.com/overquantity/outpitch?a=redredge&b=omnivoracious#promotement",
|
||||||
name: "Unhorny",
|
name: "Unhorny",
|
||||||
|
@ -68,7 +69,7 @@ describe("Notifications service - ", function() {
|
||||||
};
|
};
|
||||||
spyOn(notifications, "hasPermission").and.returnValue(true);
|
spyOn(notifications, "hasPermission").and.returnValue(true);
|
||||||
});
|
});
|
||||||
it("it checks the permissions, displays the title, the artist's name and the album picture in a notification", function() {
|
it("it checks the permissions, displays the title, the artist's name and the album picture in a notification", function () {
|
||||||
notifications.showNotification(song);
|
notifications.showNotification(song);
|
||||||
|
|
||||||
expect(notifications.hasPermission).toHaveBeenCalled();
|
expect(notifications.hasPermission).toHaveBeenCalled();
|
||||||
|
@ -80,7 +81,7 @@ describe("Notifications service - ", function() {
|
||||||
expect(NotificationObj.show).toHaveBeenCalled();
|
expect(NotificationObj.show).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I click on it, it plays the next track of the queue", function() {
|
it("when I click on it, it plays the next track of the queue", function () {
|
||||||
notifications.showNotification(song);
|
notifications.showNotification(song);
|
||||||
NotificationObj.simulateClick();
|
NotificationObj.simulateClick();
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ describe("Notifications service - ", function() {
|
||||||
expect(NotificationObj.close).toHaveBeenCalled();
|
expect(NotificationObj.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("given that the global Timeout setting is set to 10 seconds, it closes itself after 10 seconds", function() {
|
it("given that the global Timeout setting is set to 10 seconds, it closes itself after 10 seconds", function () {
|
||||||
mockGlobals.settings.Timeout = 10000;
|
mockGlobals.settings.Timeout = 10000;
|
||||||
|
|
||||||
notifications.showNotification(song);
|
notifications.showNotification(song);
|
||||||
|
@ -97,7 +98,7 @@ describe("Notifications service - ", function() {
|
||||||
expect(NotificationObj.close).toHaveBeenCalled();
|
expect(NotificationObj.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if we don't have the permission to display notifications, nothing happens", function() {
|
it("if we don't have the permission to display notifications, nothing happens", function () {
|
||||||
notifications.hasPermission.and.returnValue(false);
|
notifications.hasPermission.and.returnValue(false);
|
||||||
|
|
||||||
notifications.showNotification(song);
|
notifications.showNotification(song);
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
describe("Page service", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Page service", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var mockGlobals, Page, utils, $interval;
|
var mockGlobals, Page, utils, $interval;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
|
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
settings: {
|
settings: {
|
||||||
|
@ -22,21 +23,21 @@ describe("Page service", function() {
|
||||||
spyOn(utils.toHTML, "un").and.callFake(function (arg) { return arg; });
|
spyOn(utils.toHTML, "un").and.callFake(function (arg) { return arg; });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Given a song,", function() {
|
describe("Given a song,", function () {
|
||||||
var song;
|
var song;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
song = {
|
song = {
|
||||||
artist: 'Merlyn Nurse',
|
artist: 'Merlyn Nurse',
|
||||||
name: 'Exsiccator tumble'
|
name: 'Exsiccator tumble'
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("it displays its artist and its name as the page's title", function() {
|
it("it displays its artist and its name as the page's title", function () {
|
||||||
Page.setTitleSong(song);
|
Page.setTitleSong(song);
|
||||||
expect(Page.title()).toBe('Merlyn Nurse - Exsiccator tumble');
|
expect(Page.title()).toBe('Merlyn Nurse - Exsiccator tumble');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the global setting 'ScrollTitle' is true, it scrolls the page title", function() {
|
it("if the global setting 'ScrollTitle' is true, it scrolls the page title", function () {
|
||||||
spyOn(Page, "scrollTitle");
|
spyOn(Page, "scrollTitle");
|
||||||
mockGlobals.settings.ScrollTitle = true;
|
mockGlobals.settings.ScrollTitle = true;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ describe("Page service", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a title, it can scroll it", function() {
|
it("Given a title, it can scroll it", function () {
|
||||||
Page.setTitle('unbeloved omnificent supergravitate').scrollTitle();
|
Page.setTitle('unbeloved omnificent supergravitate').scrollTitle();
|
||||||
$interval.flush(1201);
|
$interval.flush(1201);
|
||||||
expect(Page.title()).toBe('nbeloved omnificent supergravitate u');
|
expect(Page.title()).toBe('nbeloved omnificent supergravitate u');
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
describe("utils service", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("utils service", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var $rootScope, utils, mockGlobals;
|
var $rootScope, utils, mockGlobals;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.utils', function ($provide) {
|
module('jamstash.utils', function ($provide) {
|
||||||
$provide.value('globals', mockGlobals);
|
$provide.value('globals', mockGlobals);
|
||||||
});
|
});
|
||||||
|
@ -13,37 +14,37 @@ describe("utils service", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("parseVersionString() -", function() {
|
describe("parseVersionString() -", function () {
|
||||||
it("Given a version string '2.0.1', when I parse it into a version object, then the result will be {major: 2, minor: 0, patch: 1}", function() {
|
it("Given a version string '2.0.1', when I parse it into a version object, then the result will be {major: 2, minor: 0, patch: 1}", function () {
|
||||||
var result = utils.parseVersionString('2.0.1');
|
var result = utils.parseVersionString('2.0.1');
|
||||||
expect(result).toEqual({major: 2, minor: 0, patch: 1});
|
expect(result).toEqual({ major: 2, minor: 0, patch: 1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a random string 'IHtd8EAL9HeLdc', when I parse it into a version object, then the result will be {major: 0, minor: 0, patch: 0}", function() {
|
it("Given a random string 'IHtd8EAL9HeLdc', when I parse it into a version object, then the result will be {major: 0, minor: 0, patch: 0}", function () {
|
||||||
var result = utils.parseVersionString('IHtd8EAL9HeLdc');
|
var result = utils.parseVersionString('IHtd8EAL9HeLdc');
|
||||||
expect(result).toEqual({major: 0, minor: 0, patch: 0});
|
expect(result).toEqual({ major: 0, minor: 0, patch: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given something other than a number, when I parse it into a version object, then the result will be false", function() {
|
it("Given something other than a number, when I parse it into a version object, then the result will be false", function () {
|
||||||
var result = utils.parseVersionString(84.1061);
|
var result = utils.parseVersionString(84.1061);
|
||||||
expect(result).toBeFalsy();
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("checkVersion() -", function() {
|
describe("checkVersion() -", function () {
|
||||||
var running, required;
|
var running, required;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
running = '';
|
running = '';
|
||||||
required = '';
|
required = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '2.0.1' and '1.2.3', when I check the version required, the result will be true", function() {
|
it("Given two version strings '2.0.1' and '1.2.3', when I check the version required, the result will be true", function () {
|
||||||
running = '2.0.1';
|
running = '2.0.1';
|
||||||
required = '1.2.3';
|
required = '1.2.3';
|
||||||
expect(utils.checkVersion(running, required)).toBeTruthy();
|
expect(utils.checkVersion(running, required)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version objects {major: 2, minor: 0, patch: 1} and {major: 1, minor: 2, patch: 3}, when I check the version required, the result will be true", function() {
|
it("Given two version objects {major: 2, minor: 0, patch: 1} and {major: 1, minor: 2, patch: 3}, when I check the version required, the result will be true", function () {
|
||||||
running = {
|
running = {
|
||||||
major: 2,
|
major: 2,
|
||||||
minor: 0,
|
minor: 0,
|
||||||
|
@ -57,51 +58,51 @@ describe("utils service", function() {
|
||||||
expect(utils.checkVersion(running, required)).toBeTruthy();
|
expect(utils.checkVersion(running, required)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.3.0' and '1.2.3', when I check the version required, the result will be true", function() {
|
it("Given two version strings '1.3.0' and '1.2.3', when I check the version required, the result will be true", function () {
|
||||||
running = '1.3.0';
|
running = '1.3.0';
|
||||||
required = '1.2.3';
|
required = '1.2.3';
|
||||||
expect(utils.checkVersion(running, required)).toBeTruthy();
|
expect(utils.checkVersion(running, required)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.2.2' and '1.2.3', when I check the version required, the result will be false", function() {
|
it("Given two version strings '1.2.2' and '1.2.3', when I check the version required, the result will be false", function () {
|
||||||
running = '1.2.2';
|
running = '1.2.2';
|
||||||
required = '1.2.3';
|
required = '1.2.3';
|
||||||
expect(utils.checkVersion(running, required)).toBeFalsy();
|
expect(utils.checkVersion(running, required)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.2.3' and '1.2.3', when I check the version required, the result will be true", function() {
|
it("Given two version strings '1.2.3' and '1.2.3', when I check the version required, the result will be true", function () {
|
||||||
running = '1.2.3';
|
running = '1.2.3';
|
||||||
required = '1.2.3';
|
required = '1.2.3';
|
||||||
expect(utils.checkVersion(running, required)).toBeTruthy();
|
expect(utils.checkVersion(running, required)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two random strings 'wISr91GRXzTsxkx' and 'uSIwvRDp8QJO', when I check the version required, the result will be true", function() {
|
it("Given two random strings 'wISr91GRXzTsxkx' and 'uSIwvRDp8QJO', when I check the version required, the result will be true", function () {
|
||||||
running = 'wISr91GRXzTsxkx';
|
running = 'wISr91GRXzTsxkx';
|
||||||
required = 'uSIwvRDp8QJO';
|
required = 'uSIwvRDp8QJO';
|
||||||
expect(utils.checkVersion(running, required)).toBeTruthy();
|
expect(utils.checkVersion(running, required)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a version string '1.0.1' and undefined, when I check the version required, the result will be true", function() {
|
it("Given a version string '1.0.1' and undefined, when I check the version required, the result will be true", function () {
|
||||||
running = '1.0.1';
|
running = '1.0.1';
|
||||||
required = undefined;
|
required = undefined;
|
||||||
expect(utils.checkVersion(running, required)).toBeTruthy();
|
expect(utils.checkVersion(running, required)).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("checkVersionNewer() -", function() {
|
describe("checkVersionNewer() -", function () {
|
||||||
var newer, older;
|
var newer, older;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
newer = '';
|
newer = '';
|
||||||
older = '';
|
older = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '2.0.1' and '1.2.3', when I check if the first version is newer, the result will be true", function() {
|
it("Given two version strings '2.0.1' and '1.2.3', when I check if the first version is newer, the result will be true", function () {
|
||||||
newer = '2.0.1';
|
newer = '2.0.1';
|
||||||
older = '1.2.3';
|
older = '1.2.3';
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version objects {major: 2, minor: 0, patch: 1} and {major: 1, minor: 2, patch: 3}, when I check if the first version is newer, the result will be true", function() {
|
it("Given two version objects {major: 2, minor: 0, patch: 1} and {major: 1, minor: 2, patch: 3}, when I check if the first version is newer, the result will be true", function () {
|
||||||
newer = {
|
newer = {
|
||||||
major: 2,
|
major: 2,
|
||||||
minor: 0,
|
minor: 0,
|
||||||
|
@ -115,45 +116,45 @@ describe("utils service", function() {
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.3.0' and '1.2.3', when I check if the first version is newer, the result will be true", function() {
|
it("Given two version strings '1.3.0' and '1.2.3', when I check if the first version is newer, the result will be true", function () {
|
||||||
newer = '1.3.0';
|
newer = '1.3.0';
|
||||||
older = '1.2.3';
|
older = '1.2.3';
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.2.2' and '1.2.3', when I check if the first version is newer, the result will be false", function() {
|
it("Given two version strings '1.2.2' and '1.2.3', when I check if the first version is newer, the result will be false", function () {
|
||||||
newer = '1.2.2';
|
newer = '1.2.2';
|
||||||
older = '1.2.3';
|
older = '1.2.3';
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeFalsy();
|
expect(utils.checkVersionNewer(newer, older)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.2.3' and '1.2.3', when I check if the first version is newer, the result will be false", function() {
|
it("Given two version strings '1.2.3' and '1.2.3', when I check if the first version is newer, the result will be false", function () {
|
||||||
newer = '1.2.3';
|
newer = '1.2.3';
|
||||||
older = '1.2.3';
|
older = '1.2.3';
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeFalsy();
|
expect(utils.checkVersionNewer(newer, older)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two version strings '1.0.1' and '1.0.0', when I check if the first version is newer, the result will be true", function() {
|
it("Given two version strings '1.0.1' and '1.0.0', when I check if the first version is newer, the result will be true", function () {
|
||||||
newer = '1.0.1';
|
newer = '1.0.1';
|
||||||
older = '1.0.0';
|
older = '1.0.0';
|
||||||
|
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given two random strings 'wISr91GRXzTsxkx' and 'uSIwvRDp8QJO', when I check if the first version is newer, the result will be false", function() {
|
it("Given two random strings 'wISr91GRXzTsxkx' and 'uSIwvRDp8QJO', when I check if the first version is newer, the result will be false", function () {
|
||||||
newer = 'wISr91GRXzTsxkx';
|
newer = 'wISr91GRXzTsxkx';
|
||||||
older = 'uSIwvRDp8QJO';
|
older = 'uSIwvRDp8QJO';
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeFalsy();
|
expect(utils.checkVersionNewer(newer, older)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a version string '1.0.1' and undefined, when I check if the first version is newer, the result will be true", function() {
|
it("Given a version string '1.0.1' and undefined, when I check if the first version is newer, the result will be true", function () {
|
||||||
newer = '1.0.1';
|
newer = '1.0.1';
|
||||||
older = undefined;
|
older = undefined;
|
||||||
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
expect(utils.checkVersionNewer(newer, older)).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("formatDate() - Given a Date and a text format, when I format a Date, jQuery's format date will be called and a formatted string will be returned", function() {
|
it("formatDate() - Given a Date and a text format, when I format a Date, jQuery's format date will be called and a formatted string will be returned", function () {
|
||||||
spyOn($.format, 'date');
|
spyOn($.format, 'date');
|
||||||
var date = new Date('2015-03-28T16:54:40+01:00');
|
var date = new Date('2015-03-28T16:54:40+01:00');
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
describe("jplayer directive", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("jplayer directive", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var element, scope, $player, playingSong, deferred,
|
var element, scope, $player, playingSong, deferred,
|
||||||
playerService, mockGlobals, subsonic, notifications, persistence, Page, $interval;
|
playerService, mockGlobals, subsonic, notifications, persistence, Page, $interval;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
// We redefine globals because in some tests we need to alter the settings
|
// We redefine globals because in some tests we need to alter the settings
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
settings: {
|
settings: {
|
||||||
|
@ -16,13 +17,13 @@ describe("jplayer directive", function() {
|
||||||
};
|
};
|
||||||
// Redefined to avoid firing 'play' with a previous test song
|
// Redefined to avoid firing 'play' with a previous test song
|
||||||
playingSong = undefined;
|
playingSong = undefined;
|
||||||
module('jamstash.player.directive', function($provide) {
|
module('jamstash.player.directive', function ($provide) {
|
||||||
// Mock the player service
|
// Mock the player service
|
||||||
$provide.decorator('player', function($delegate) {
|
$provide.decorator('player', function ($delegate) {
|
||||||
$delegate.pauseSong = false;
|
$delegate.pauseSong = false;
|
||||||
$delegate.restartSong = false;
|
$delegate.restartSong = false;
|
||||||
$delegate.loadSong = false;
|
$delegate.loadSong = false;
|
||||||
$delegate.getPlayingSong = jasmine.createSpy('getPlayingSong').and.callFake(function() {
|
$delegate.getPlayingSong = jasmine.createSpy('getPlayingSong').and.callFake(function () {
|
||||||
return playingSong;
|
return playingSong;
|
||||||
});
|
});
|
||||||
$delegate.getVolume = jasmine.createSpy('getVolume').and.returnValue(1.0);
|
$delegate.getVolume = jasmine.createSpy('getVolume').and.returnValue(1.0);
|
||||||
|
@ -35,7 +36,7 @@ describe("jplayer directive", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn($.fn, "jPlayer").and.callThrough();
|
spyOn($.fn, "jPlayer").and.callThrough();
|
||||||
inject(function($rootScope, $compile, _$interval_, $q, _player_, _subsonic_, _notifications_, _persistence_, _Page_) {
|
inject(function ($rootScope, $compile, _$interval_, $q, _player_, _subsonic_, _notifications_, _persistence_, _Page_) {
|
||||||
playerService = _player_;
|
playerService = _player_;
|
||||||
subsonic = _subsonic_;
|
subsonic = _subsonic_;
|
||||||
notifications = _notifications_;
|
notifications = _notifications_;
|
||||||
|
@ -54,8 +55,8 @@ describe("jplayer directive", function() {
|
||||||
$player = element.children('div');
|
$player = element.children('div');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When the player service's current song changes,", function() {
|
describe("When the player service's current song changes,", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
// To avoid errors breaking the test, we stub jPlayer
|
// To avoid errors breaking the test, we stub jPlayer
|
||||||
$.fn.jPlayer.and.stub();
|
$.fn.jPlayer.and.stub();
|
||||||
playingSong = {
|
playingSong = {
|
||||||
|
@ -65,15 +66,15 @@ describe("jplayer directive", function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("it sets jPlayer's media, stores the song for future scrobbling and sets the page title with the song", function() {
|
it("it sets jPlayer's media, stores the song for future scrobbling and sets the page title with the song", function () {
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
|
||||||
expect($.fn.jPlayer).toHaveBeenCalledWith('setMedia', {'mp3': 'https://gantry.com/antemarital/vigorless?a=oropharyngeal&b=killcrop#eviscerate'});
|
expect($.fn.jPlayer).toHaveBeenCalledWith('setMedia', { mp3: 'https://gantry.com/antemarital/vigorless?a=oropharyngeal&b=killcrop#eviscerate' });
|
||||||
expect(scope.currentSong).toEqual(playingSong);
|
expect(scope.currentSong).toEqual(playingSong);
|
||||||
expect(Page.setTitleSong).toHaveBeenCalledWith(playingSong);
|
expect(Page.setTitleSong).toHaveBeenCalledWith(playingSong);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the global setting Jukebox is true, it mutes jPlayer and adds the song to subsonic's Jukebox", function() {
|
it("if the global setting Jukebox is true, it mutes jPlayer and adds the song to subsonic's Jukebox", function () {
|
||||||
mockGlobals.settings.Jukebox = true;
|
mockGlobals.settings.Jukebox = true;
|
||||||
scope.addToJukebox = jasmine.createSpy("addToJukebox");
|
scope.addToJukebox = jasmine.createSpy("addToJukebox");
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.addToJukebox).toHaveBeenCalledWith(playingSong.id);
|
expect(scope.addToJukebox).toHaveBeenCalledWith(playingSong.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the player service's loadSong flag is true, it does not play the song, it displays the player controls and sets the player to the song's supplied position", function() {
|
it("if the player service's loadSong flag is true, it does not play the song, it displays the player controls and sets the player to the song's supplied position", function () {
|
||||||
// Reset the calls because the watcher on player.pauseSong calls jPlayer('play')
|
// Reset the calls because the watcher on player.pauseSong calls jPlayer('play')
|
||||||
$player.jPlayer.calls.reset();
|
$player.jPlayer.calls.reset();
|
||||||
spyOn(scope, "revealControls");
|
spyOn(scope, "revealControls");
|
||||||
|
@ -97,8 +98,8 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.revealControls).toHaveBeenCalled();
|
expect(scope.revealControls).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("if the player service's loadSong flag is false,", function() {
|
describe("if the player service's loadSong flag is false,", function () {
|
||||||
it("it plays the song", function() {
|
it("it plays the song", function () {
|
||||||
playerService.loadSong = false;
|
playerService.loadSong = false;
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ describe("jplayer directive", function() {
|
||||||
expect(playerService.loadSong).toBeFalsy();
|
expect(playerService.loadSong).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the global setting NotificationSong is true, it displays a notification", function() {
|
it("if the global setting NotificationSong is true, it displays a notification", function () {
|
||||||
spyOn(notifications, "showNotification");
|
spyOn(notifications, "showNotification");
|
||||||
mockGlobals.settings.NotificationSong = true;
|
mockGlobals.settings.NotificationSong = true;
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ describe("jplayer directive", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if fancybox is open, it sets it up with the new song's cover art", function() {
|
it("if fancybox is open, it sets it up with the new song's cover art", function () {
|
||||||
$.fancybox.isOpen = true;
|
$.fancybox.isOpen = true;
|
||||||
scope.fancyboxOpenImage = jasmine.createSpy("fancyboxOpenImage");
|
scope.fancyboxOpenImage = jasmine.createSpy("fancyboxOpenImage");
|
||||||
|
|
||||||
|
@ -125,25 +126,25 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.fancyboxOpenImage).toHaveBeenCalledWith(playingSong.coverartfull);
|
expect(scope.fancyboxOpenImage).toHaveBeenCalledWith(playingSong.coverartfull);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the song's suffix is 'm4a', it sets jPlayer up with this format", function() {
|
it("if the song's suffix is 'm4a', it sets jPlayer up with this format", function () {
|
||||||
playingSong.suffix = 'm4a';
|
playingSong.suffix = 'm4a';
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
expect($.fn.jPlayer).toHaveBeenCalledWith('setMedia', {'m4a': 'https://gantry.com/antemarital/vigorless?a=oropharyngeal&b=killcrop#eviscerate'});
|
expect($.fn.jPlayer).toHaveBeenCalledWith('setMedia', { m4a: 'https://gantry.com/antemarital/vigorless?a=oropharyngeal&b=killcrop#eviscerate' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the song's suffix is 'oga', it sets jPlayer up with this format", function() {
|
it("if the song's suffix is 'oga', it sets jPlayer up with this format", function () {
|
||||||
playingSong.suffix = 'oga';
|
playingSong.suffix = 'oga';
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
expect($.fn.jPlayer).toHaveBeenCalledWith('setMedia', {'oga': 'https://gantry.com/antemarital/vigorless?a=oropharyngeal&b=killcrop#eviscerate'});
|
expect($.fn.jPlayer).toHaveBeenCalledWith('setMedia', { oga: 'https://gantry.com/antemarital/vigorless?a=oropharyngeal&b=killcrop#eviscerate' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("", function() {
|
describe("", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
$.fn.jPlayer.and.stub();
|
$.fn.jPlayer.and.stub();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When the player service's restartSong flag is true, it restarts the current song, resets the restart flag to false and resets the scrobbled flag to false", function() {
|
it("When the player service's restartSong flag is true, it restarts the current song, resets the restart flag to false and resets the scrobbled flag to false", function () {
|
||||||
playerService.restartSong = true;
|
playerService.restartSong = true;
|
||||||
scope.scrobbled = true;
|
scope.scrobbled = true;
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
@ -153,14 +154,14 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.scrobbled).toBeFalsy();
|
expect(scope.scrobbled).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When the player service's pauseSong is true, it pauses the current song", function() {
|
it("When the player service's pauseSong is true, it pauses the current song", function () {
|
||||||
playerService.pauseSong = true;
|
playerService.pauseSong = true;
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
|
||||||
expect($player.jPlayer).toHaveBeenCalledWith('pause');
|
expect($player.jPlayer).toHaveBeenCalledWith('pause');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the current song is paused, when the player service's pauseSong becomes false, it plays the song ", function() {
|
it("Given that the current song is paused, when the player service's pauseSong becomes false, it plays the song ", function () {
|
||||||
playerService.pauseSong = true;
|
playerService.pauseSong = true;
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
|
||||||
|
@ -169,24 +170,24 @@ describe("jplayer directive", function() {
|
||||||
expect($player.jPlayer).toHaveBeenCalledWith('play');
|
expect($player.jPlayer).toHaveBeenCalledWith('play');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When the player service's volume changes, it sets jPlayer's volume", function() {
|
it("When the player service's volume changes, it sets jPlayer's volume", function () {
|
||||||
playerService.getVolume.and.returnValue(0.2034);
|
playerService.getVolume.and.returnValue(0.2034);
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
expect($player.jPlayer).toHaveBeenCalledWith('volume', 0.2034);
|
expect($player.jPlayer).toHaveBeenCalledWith('volume', 0.2034);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When jplayer has finished the current song,", function() {
|
describe("When jplayer has finished the current song,", function () {
|
||||||
var ended;
|
var ended;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
ended = $.jPlayer.event.ended;
|
ended = $.jPlayer.event.ended;
|
||||||
});
|
});
|
||||||
it("it notifies the player service that the song has ended", function() {
|
it("it notifies the player service that the song has ended", function () {
|
||||||
$player.trigger(ended);
|
$player.trigger(ended);
|
||||||
expect(playerService.songEnded).toHaveBeenCalled();
|
expect(playerService.songEnded).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("given that the last song of the queue is playing and that the global setting AutoPlay is true, it asks subsonic for random tracks, notifies the player service that the song has ended and notifies the user", function() {
|
it("given that the last song of the queue is playing and that the global setting AutoPlay is true, it asks subsonic for random tracks, notifies the player service that the song has ended and notifies the user", function () {
|
||||||
mockGlobals.settings.AutoPlay = true;
|
mockGlobals.settings.AutoPlay = true;
|
||||||
spyOn(subsonic, "getRandomSongs").and.returnValue(deferred.promise);
|
spyOn(subsonic, "getRandomSongs").and.returnValue(deferred.promise);
|
||||||
spyOn(notifications, "updateMessage");
|
spyOn(notifications, "updateMessage");
|
||||||
|
@ -202,7 +203,7 @@ describe("jplayer directive", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When jPlayer gets new media, it resets the scrobbled flag to false", function() {
|
it("When jPlayer gets new media, it resets the scrobbled flag to false", function () {
|
||||||
scope.scrobbled = true;
|
scope.scrobbled = true;
|
||||||
|
|
||||||
var e = $.jPlayer.event.setmedia;
|
var e = $.jPlayer.event.setmedia;
|
||||||
|
@ -211,7 +212,7 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.scrobbled).toBeFalsy();
|
expect(scope.scrobbled).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When jPlayer throws an error, it tries to restart playback at the last position", function() {
|
it("When jPlayer throws an error, it tries to restart playback at the last position", function () {
|
||||||
// Fake jPlayer's internal _trigger event because I can't trigger a manual error
|
// Fake jPlayer's internal _trigger event because I can't trigger a manual error
|
||||||
var fakejPlayer = {
|
var fakejPlayer = {
|
||||||
element: $player,
|
element: $player,
|
||||||
|
@ -224,7 +225,7 @@ describe("jplayer directive", function() {
|
||||||
expect($player.jPlayer).toHaveBeenCalledWith('play', 10.4228);
|
expect($player.jPlayer).toHaveBeenCalledWith('play', 10.4228);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When jPlayer starts to play the current song, it displays the player controls", function() {
|
it("When jPlayer starts to play the current song, it displays the player controls", function () {
|
||||||
spyOn(scope, "revealControls");
|
spyOn(scope, "revealControls");
|
||||||
|
|
||||||
var e = $.jPlayer.event.play;
|
var e = $.jPlayer.event.play;
|
||||||
|
@ -233,7 +234,7 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.revealControls).toHaveBeenCalled();
|
expect(scope.revealControls).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("revealControls - it displays the song details and the player controls", function() {
|
it("revealControls - it displays the song details and the player controls", function () {
|
||||||
$.fn.jPlayer.and.stub();
|
$.fn.jPlayer.and.stub();
|
||||||
affix('#playermiddle').css('visibility', 'hidden');
|
affix('#playermiddle').css('visibility', 'hidden');
|
||||||
affix('#songdetails').css('visibility', 'hidden');
|
affix('#songdetails').css('visibility', 'hidden');
|
||||||
|
@ -244,9 +245,9 @@ describe("jplayer directive", function() {
|
||||||
expect($('#songdetails').css('visibility')).toEqual('visible');
|
expect($('#songdetails').css('visibility')).toEqual('visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Scrobbling -", function() {
|
describe("Scrobbling -", function () {
|
||||||
var fakejPlayer, timeUpdate;
|
var fakejPlayer, timeUpdate;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
spyOn(subsonic, "scrobble");
|
spyOn(subsonic, "scrobble");
|
||||||
scope.currentSong = {
|
scope.currentSong = {
|
||||||
id: 5375
|
id: 5375
|
||||||
|
@ -260,7 +261,7 @@ describe("jplayer directive", function() {
|
||||||
timeUpdate = $.jPlayer.event.timeupdate;
|
timeUpdate = $.jPlayer.event.timeupdate;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a song that hasn't been scrobbled yet, When jPlayer reaches 30 percent of it, it scrobbles to last.fm using the subsonic service and sets the flag to true", function() {
|
it("Given a song that hasn't been scrobbled yet, When jPlayer reaches 30 percent of it, it scrobbles to last.fm using the subsonic service and sets the flag to true", function () {
|
||||||
scope.scrobbled = false;
|
scope.scrobbled = false;
|
||||||
|
|
||||||
// Trigger our fake timeupdate
|
// Trigger our fake timeupdate
|
||||||
|
@ -270,7 +271,7 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.scrobbled).toBeTruthy();
|
expect(scope.scrobbled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a song that has already been scrobbled, when jPlayer reaches 30 percent of it, it does not scrobble again and leaves the flag to true", function() {
|
it("Given a song that has already been scrobbled, when jPlayer reaches 30 percent of it, it does not scrobble again and leaves the flag to true", function () {
|
||||||
scope.scrobbled = true;
|
scope.scrobbled = true;
|
||||||
|
|
||||||
// Trigger our fake timeupdate
|
// Trigger our fake timeupdate
|
||||||
|
@ -281,7 +282,7 @@ describe("jplayer directive", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When the global setting SaveTrackPosition becomes true, it starts saving the current song's position", function() {
|
it("When the global setting SaveTrackPosition becomes true, it starts saving the current song's position", function () {
|
||||||
spyOn(scope, "startSavePosition");
|
spyOn(scope, "startSavePosition");
|
||||||
mockGlobals.settings.SaveTrackPosition = true;
|
mockGlobals.settings.SaveTrackPosition = true;
|
||||||
|
|
||||||
|
@ -290,14 +291,14 @@ describe("jplayer directive", function() {
|
||||||
expect(scope.startSavePosition).toHaveBeenCalled();
|
expect(scope.startSavePosition).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Given that the global setting SaveTrackPosition is true,", function() {
|
describe("Given that the global setting SaveTrackPosition is true,", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
mockGlobals.settings.SaveTrackPosition = true;
|
mockGlobals.settings.SaveTrackPosition = true;
|
||||||
spyOn(persistence, "saveTrackPosition");
|
spyOn(persistence, "saveTrackPosition");
|
||||||
spyOn(persistence, "saveQueue");
|
spyOn(persistence, "saveQueue");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("every 30 seconds, it saves the current song's position and the playing queue", function() {
|
it("every 30 seconds, it saves the current song's position and the playing queue", function () {
|
||||||
scope.currentSong = { id: 419 };
|
scope.currentSong = { id: 419 };
|
||||||
$player.data('jPlayer').status.currentTime = 35.3877;
|
$player.data('jPlayer').status.currentTime = 35.3877;
|
||||||
$player.data('jPlayer').status.paused = false;
|
$player.data('jPlayer').status.paused = false;
|
||||||
|
@ -310,7 +311,7 @@ describe("jplayer directive", function() {
|
||||||
expect(persistence.saveQueue).toHaveBeenCalled();
|
expect(persistence.saveQueue).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the song is not playing, it does not save anything", function() {
|
it("if the song is not playing, it does not save anything", function () {
|
||||||
$player.data('jPlayer').status.currentTime = 0.0;
|
$player.data('jPlayer').status.currentTime = 0.0;
|
||||||
$player.data('jPlayer').status.paused = true;
|
$player.data('jPlayer').status.paused = true;
|
||||||
|
|
||||||
|
@ -321,7 +322,7 @@ describe("jplayer directive", function() {
|
||||||
expect(persistence.saveQueue).not.toHaveBeenCalled();
|
expect(persistence.saveQueue).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if there was already a watcher, it clears it before adding a new one", function() {
|
it("if there was already a watcher, it clears it before adding a new one", function () {
|
||||||
spyOn($interval, "cancel");
|
spyOn($interval, "cancel");
|
||||||
|
|
||||||
scope.startSavePosition();
|
scope.startSavePosition();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
describe("Player service -", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Player service -", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var player, firstSong, secondSong, thirdSong, newSong;
|
var player, firstSong, secondSong, thirdSong, newSong;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.player.service');
|
module('jamstash.player.service');
|
||||||
inject(function (_player_) {
|
inject(function (_player_) {
|
||||||
player = _player_;
|
player = _player_;
|
||||||
|
@ -10,9 +11,9 @@ describe("Player service -", function() {
|
||||||
player.settings.repeat = "none";
|
player.settings.repeat = "none";
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Given that I have 3 songs in my playing queue,", function() {
|
describe("Given that I have 3 songs in my playing queue,", function () {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
firstSong = {
|
firstSong = {
|
||||||
id: 6726,
|
id: 6726,
|
||||||
name: 'Guarauno',
|
name: 'Guarauno',
|
||||||
|
@ -40,19 +41,19 @@ describe("Player service -", function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when I call nextTrack", function() {
|
describe("when I call nextTrack", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
spyOn(player, "play");
|
spyOn(player, "play");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and no song is playing, it plays the first song", function() {
|
it("and no song is playing, it plays the first song", function () {
|
||||||
player.nextTrack();
|
player.nextTrack();
|
||||||
|
|
||||||
expect(player._playingIndex).toBe(0);
|
expect(player._playingIndex).toBe(0);
|
||||||
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and the first song is playing, it plays the second song", function() {
|
it("and the first song is playing, it plays the second song", function () {
|
||||||
player._playingIndex = 0;
|
player._playingIndex = 0;
|
||||||
player._playingSong = firstSong;
|
player._playingSong = firstSong;
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ describe("Player service -", function() {
|
||||||
expect(player.play).toHaveBeenCalledWith(player.queue[1]);
|
expect(player.play).toHaveBeenCalledWith(player.queue[1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and the last song is playing, it does nothing", function() {
|
it("and the last song is playing, it does nothing", function () {
|
||||||
player._playingIndex = 2;
|
player._playingIndex = 2;
|
||||||
player._playingSong = thirdSong;
|
player._playingSong = thirdSong;
|
||||||
|
|
||||||
|
@ -73,19 +74,19 @@ describe("Player service -", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when I call previousTrack", function() {
|
describe("when I call previousTrack", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
spyOn(player, "play");
|
spyOn(player, "play");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and no song is playing, it plays the first song", function() {
|
it("and no song is playing, it plays the first song", function () {
|
||||||
player.previousTrack();
|
player.previousTrack();
|
||||||
|
|
||||||
expect(player._playingIndex).toBe(0);
|
expect(player._playingIndex).toBe(0);
|
||||||
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and the first song is playing, it restarts the first song", function() {
|
it("and the first song is playing, it restarts the first song", function () {
|
||||||
player._playingIndex = 0;
|
player._playingIndex = 0;
|
||||||
player._playingSong = firstSong;
|
player._playingSong = firstSong;
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ describe("Player service -", function() {
|
||||||
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and the last song is playing, it plays the second song", function() {
|
it("and the last song is playing, it plays the second song", function () {
|
||||||
player._playingIndex = 2;
|
player._playingIndex = 2;
|
||||||
player._playingSong = thirdSong;
|
player._playingSong = thirdSong;
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ describe("Player service -", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I call playFirstSong, it plays the first song and updates the playing index", function() {
|
it("when I call playFirstSong, it plays the first song and updates the playing index", function () {
|
||||||
spyOn(player, "play");
|
spyOn(player, "play");
|
||||||
|
|
||||||
player.playFirstSong();
|
player.playFirstSong();
|
||||||
|
@ -115,22 +116,22 @@ describe("Player service -", function() {
|
||||||
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
expect(player.play).toHaveBeenCalledWith(player.queue[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I play the second song, it finds its index in the playing queue and updates the playing index", function() {
|
it("when I play the second song, it finds its index in the playing queue and updates the playing index", function () {
|
||||||
player.play(secondSong);
|
player.play(secondSong);
|
||||||
expect(player._playingIndex).toBe(1);
|
expect(player._playingIndex).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I play a song that isn't in the playing queue, the next song will be the first song of the playing queue", function() {
|
it("when I play a song that isn't in the playing queue, the next song will be the first song of the playing queue", function () {
|
||||||
player.play(newSong);
|
player.play(newSong);
|
||||||
expect(player._playingIndex).toBe(-1);
|
expect(player._playingIndex).toBe(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I call emptyQueue, it empties the playing queue", function() {
|
it("when I call emptyQueue, it empties the playing queue", function () {
|
||||||
player.emptyQueue();
|
player.emptyQueue();
|
||||||
expect(player.queue).toEqual([]);
|
expect(player.queue).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and given the third song was playing, when I shuffle the playing queue, then the third song will be at the first position and the rest of the queue will be shuffled", function() {
|
it("and given the third song was playing, when I shuffle the playing queue, then the third song will be at the first position and the rest of the queue will be shuffled", function () {
|
||||||
player._playingSong = thirdSong;
|
player._playingSong = thirdSong;
|
||||||
|
|
||||||
player.shuffleQueue();
|
player.shuffleQueue();
|
||||||
|
@ -140,7 +141,7 @@ describe("Player service -", function() {
|
||||||
expect(player.queue).toContain(secondSong);
|
expect(player.queue).toContain(secondSong);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and given no song was playing, when I shuffle the playing queue, then the whole queue will be shuffled", function() {
|
it("and given no song was playing, when I shuffle the playing queue, then the whole queue will be shuffled", function () {
|
||||||
player.shuffleQueue();
|
player.shuffleQueue();
|
||||||
|
|
||||||
expect(player.queue).toContain(firstSong);
|
expect(player.queue).toContain(firstSong);
|
||||||
|
@ -149,47 +150,54 @@ describe("Player service -", function() {
|
||||||
expect(player.queue).not.toContain(undefined);
|
expect(player.queue).not.toContain(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I get the index of the first song, it returns 0", function() {
|
it("when I get the index of the first song, it returns 0", function () {
|
||||||
expect(player.indexOfSong(firstSong)).toBe(0);
|
expect(player.indexOfSong(firstSong)).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I get the index of a song that isn't in the playing queue, it returns undefined", function() {
|
it("when I get the index of a song that isn't in the playing queue, it returns undefined", function () {
|
||||||
expect(player.indexOfSong(newSong)).toBeUndefined();
|
expect(player.indexOfSong(newSong)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I add a song to the queue, it is appended to the end of the playing queue", function() {
|
it("when I add a song to the queue, it is appended to the end of the playing queue", function () {
|
||||||
player.addSong(newSong);
|
player.addSong(newSong);
|
||||||
expect(player.queue).toEqual([firstSong, secondSong, thirdSong, newSong]);
|
expect(player.queue).toEqual([firstSong, secondSong, thirdSong, newSong]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I add 3 songs to the queue, they are appended to the end of the playing queue", function() {
|
it("when I add 3 songs to the queue, they are appended to the end of the playing queue", function () {
|
||||||
var secondNewSong = {id: 6338, name: 'Preconquest', artist: 'France Wisley', album: 'Unmix'};
|
var secondNewSong = { id: 6338, name: 'Preconquest', artist: 'France Wisley', album: 'Unmix' };
|
||||||
var thirdNewSong = {id: 3696, name: 'Cetene', artist: 'Hilario Masley', album: 'Gonapophysal'};
|
var thirdNewSong = { id: 3696, name: 'Cetene', artist: 'Hilario Masley', album: 'Gonapophysal' };
|
||||||
player.addSongs([newSong, secondNewSong, thirdNewSong]);
|
player.addSongs([newSong, secondNewSong, thirdNewSong]);
|
||||||
expect(player.queue).toEqual([firstSong, secondSong, thirdSong, newSong, secondNewSong, thirdNewSong]);
|
expect(player.queue).toEqual([
|
||||||
|
firstSong,
|
||||||
|
secondSong,
|
||||||
|
thirdSong,
|
||||||
|
newSong,
|
||||||
|
secondNewSong,
|
||||||
|
thirdNewSong
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I remove the second song, the playing queue is now only the first and third song", function() {
|
it("when I remove the second song, the playing queue is now only the first and third song", function () {
|
||||||
player.removeSong(secondSong);
|
player.removeSong(secondSong);
|
||||||
expect(player.queue).toEqual([firstSong, thirdSong]);
|
expect(player.queue).toEqual([firstSong, thirdSong]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I remove the first and third songs, the playing queue is now only the second song", function() {
|
it("when I remove the first and third songs, the playing queue is now only the second song", function () {
|
||||||
player.removeSongs([firstSong, thirdSong]);
|
player.removeSongs([firstSong, thirdSong]);
|
||||||
expect(player.queue).toEqual([secondSong]);
|
expect(player.queue).toEqual([secondSong]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when the first song is playing, isLastSongPlaying returns false", function() {
|
it("when the first song is playing, isLastSongPlaying returns false", function () {
|
||||||
player._playingIndex = 0;
|
player._playingIndex = 0;
|
||||||
expect(player.isLastSongPlaying()).toBeFalsy();
|
expect(player.isLastSongPlaying()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when the third song is playing, isLastSongPlaying returns true", function() {
|
it("when the third song is playing, isLastSongPlaying returns true", function () {
|
||||||
player._playingIndex = 2;
|
player._playingIndex = 2;
|
||||||
expect(player.isLastSongPlaying()).toBeTruthy();
|
expect(player.isLastSongPlaying()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and the current song is not the last, when the current song ends, it plays the next song in queue", function() {
|
it("and the current song is not the last, when the current song ends, it plays the next song in queue", function () {
|
||||||
spyOn(player, "nextTrack");
|
spyOn(player, "nextTrack");
|
||||||
player._playingIndex = 0;
|
player._playingIndex = 0;
|
||||||
|
|
||||||
|
@ -198,7 +206,7 @@ describe("Player service -", function() {
|
||||||
expect(player.nextTrack).toHaveBeenCalled();
|
expect(player.nextTrack).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("and that the 'Repeat' setting is set to 'song', when the current song ends, it restarts it", function() {
|
it("and that the 'Repeat' setting is set to 'song', when the current song ends, it restarts it", function () {
|
||||||
spyOn(player, "restart");
|
spyOn(player, "restart");
|
||||||
player.settings.repeat = "song";
|
player.settings.repeat = "song";
|
||||||
|
|
||||||
|
@ -207,12 +215,12 @@ describe("Player service -", function() {
|
||||||
expect(player.restart).toHaveBeenCalled();
|
expect(player.restart).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("and the current song is the last of the queue, when the current song ends,", function() {
|
describe("and the current song is the last of the queue, when the current song ends,", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
player._playingIndex = 2;
|
player._playingIndex = 2;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the 'Repeat' setting is set to 'queue', it plays the first song of the queue", function() {
|
it("if the 'Repeat' setting is set to 'queue', it plays the first song of the queue", function () {
|
||||||
spyOn(player, "playFirstSong");
|
spyOn(player, "playFirstSong");
|
||||||
player.settings.repeat = "queue";
|
player.settings.repeat = "queue";
|
||||||
|
|
||||||
|
@ -221,7 +229,7 @@ describe("Player service -", function() {
|
||||||
expect(player.playFirstSong).toHaveBeenCalled();
|
expect(player.playFirstSong).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("it does not play anything", function() {
|
it("it does not play anything", function () {
|
||||||
spyOn(player, "nextTrack").and.callThrough();
|
spyOn(player, "nextTrack").and.callThrough();
|
||||||
player.songEnded();
|
player.songEnded();
|
||||||
|
|
||||||
|
@ -231,10 +239,10 @@ describe("Player service -", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Given a song", function() {
|
describe("Given a song", function () {
|
||||||
|
|
||||||
var song;
|
var song;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
song = {
|
song = {
|
||||||
id: 6726,
|
id: 6726,
|
||||||
name: 'Guarauno',
|
name: 'Guarauno',
|
||||||
|
@ -244,7 +252,7 @@ describe("Player service -", function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when the song was playing and I play it again, it restarts the current song", function() {
|
it("when the song was playing and I play it again, it restarts the current song", function () {
|
||||||
spyOn(player, "restart");
|
spyOn(player, "restart");
|
||||||
|
|
||||||
player.play(song);
|
player.play(song);
|
||||||
|
@ -253,12 +261,12 @@ describe("Player service -", function() {
|
||||||
expect(player.restart).toHaveBeenCalled();
|
expect(player.restart).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I restart the current song, the flag for the directive is set", function() {
|
it("when I restart the current song, the flag for the directive is set", function () {
|
||||||
player.restart();
|
player.restart();
|
||||||
expect(player.restartSong).toBeTruthy();
|
expect(player.restartSong).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I load the song, the flag for the directive is set", function() {
|
it("when I load the song, the flag for the directive is set", function () {
|
||||||
spyOn(player, "play");
|
spyOn(player, "play");
|
||||||
|
|
||||||
player.load(song);
|
player.load(song);
|
||||||
|
@ -268,49 +276,49 @@ describe("Player service -", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Given that my playing queue is empty", function() {
|
describe("Given that my playing queue is empty", function () {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
player.queue = [];
|
player.queue = [];
|
||||||
player._playingIndex = -1;
|
player._playingIndex = -1;
|
||||||
spyOn(player, "play");
|
spyOn(player, "play");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I call nextTrack, it does nothing", function() {
|
it("when I call nextTrack, it does nothing", function () {
|
||||||
player.nextTrack();
|
player.nextTrack();
|
||||||
expect(player.play).not.toHaveBeenCalled();
|
expect(player.play).not.toHaveBeenCalled();
|
||||||
expect(player._playingIndex).toBe(-1);
|
expect(player._playingIndex).toBe(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I call previousTrack, it does nothing", function() {
|
it("when I call previousTrack, it does nothing", function () {
|
||||||
player.previousTrack();
|
player.previousTrack();
|
||||||
expect(player.play).not.toHaveBeenCalled();
|
expect(player.play).not.toHaveBeenCalled();
|
||||||
expect(player._playingIndex).toBe(-1);
|
expect(player._playingIndex).toBe(-1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When I turn the volume up,", function() {
|
describe("When I turn the volume up,", function () {
|
||||||
it("it sets the player's volume up by 10%", function() {
|
it("it sets the player's volume up by 10%", function () {
|
||||||
player.setVolume(0.5);
|
player.setVolume(0.5);
|
||||||
player.turnVolumeUp();
|
player.turnVolumeUp();
|
||||||
expect(player.getVolume()).toBe(0.6);
|
expect(player.getVolume()).toBe(0.6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the player's resulting volume won't be between 0 and 1, it sets it to 1", function() {
|
it("if the player's resulting volume won't be between 0 and 1, it sets it to 1", function () {
|
||||||
player.setVolume(5.91488);
|
player.setVolume(5.91488);
|
||||||
player.turnVolumeUp();
|
player.turnVolumeUp();
|
||||||
expect(player.getVolume()).toBe(1.0);
|
expect(player.getVolume()).toBe(1.0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("When I turn the volume down,", function() {
|
describe("When I turn the volume down,", function () {
|
||||||
it("it sets the player's volume down by 10%", function() {
|
it("it sets the player's volume down by 10%", function () {
|
||||||
player.setVolume(0.5);
|
player.setVolume(0.5);
|
||||||
player.turnVolumeDown();
|
player.turnVolumeDown();
|
||||||
expect(player.getVolume()).toBe(0.4);
|
expect(player.getVolume()).toBe(0.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the player's resulting volume won't be between 0 and 1, it sets it to 0", function() {
|
it("if the player's resulting volume won't be between 0 and 1, it sets it to 0", function () {
|
||||||
player.setVolume(0.05);
|
player.setVolume(0.05);
|
||||||
player.turnVolumeDown();
|
player.turnVolumeDown();
|
||||||
expect(player.getVolume()).toBe(0);
|
expect(player.getVolume()).toBe(0);
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
describe("Player controller", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Player controller", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var player, scope, mockGlobals;
|
var player, scope, mockGlobals;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
// We redefine globals because in some tests we need to alter the settings
|
// We redefine globals because in some tests we need to alter the settings
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
settings: {
|
settings: {
|
||||||
|
@ -11,7 +12,7 @@ describe("Player controller", function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module('jamstash.player.controller');
|
module("jamstash.player.controller");
|
||||||
|
|
||||||
inject(function ($controller, $rootScope) {
|
inject(function ($controller, $rootScope) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
@ -24,7 +25,7 @@ describe("Player controller", function() {
|
||||||
"togglePause"
|
"togglePause"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$controller('PlayerController', {
|
$controller("PlayerController", {
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
player: player,
|
player: player,
|
||||||
globals: mockGlobals
|
globals: mockGlobals
|
||||||
|
@ -32,31 +33,31 @@ describe("Player controller", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I play a song, the player service will be called", function() {
|
it("When I play a song, the player service will be called", function () {
|
||||||
scope.play();
|
scope.play();
|
||||||
|
|
||||||
expect(player.togglePause).toHaveBeenCalled();
|
expect(player.togglePause).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when I pause a song, the player service will be called", function() {
|
it("when I pause a song, the player service will be called", function () {
|
||||||
scope.pause();
|
scope.pause();
|
||||||
|
|
||||||
expect(player.togglePause).toHaveBeenCalled();
|
expect(player.togglePause).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I get the currently playing song, the player service will be called", function() {
|
it("When I get the currently playing song, the player service will be called", function () {
|
||||||
scope.getPlayingSong();
|
scope.getPlayingSong();
|
||||||
|
|
||||||
expect(player.getPlayingSong).toHaveBeenCalled();
|
expect(player.getPlayingSong).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I get the previous track, the player service will be called", function() {
|
it("When I get the previous track, the player service will be called", function () {
|
||||||
scope.previousTrack();
|
scope.previousTrack();
|
||||||
|
|
||||||
expect(player.previousTrack).toHaveBeenCalled();
|
expect(player.previousTrack).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I get the next track, the player service will be called", function() {
|
it("When I get the next track, the player service will be called", function () {
|
||||||
scope.nextTrack();
|
scope.nextTrack();
|
||||||
|
|
||||||
expect(player.nextTrack).toHaveBeenCalled();
|
expect(player.nextTrack).toHaveBeenCalled();
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
describe("repeat directive", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("repeat directive", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var element, scope, isolateScope, notifications, mockGlobals;
|
var element, scope, isolateScope, notifications, mockGlobals;
|
||||||
|
|
||||||
beforeEach(module ('templates'));
|
beforeEach(module('templates'));
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
// We redefine globals because in some tests we need to alter the settings
|
// We redefine globals because in some tests we need to alter the settings
|
||||||
mockGlobals = {
|
mockGlobals = {
|
||||||
settings: {
|
settings: {
|
||||||
|
@ -13,7 +14,7 @@ describe("repeat directive", function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module('jamstash.repeat.directive', function($provide) {
|
module('jamstash.repeat.directive', function ($provide) {
|
||||||
$provide.value('globals', mockGlobals);
|
$provide.value('globals', mockGlobals);
|
||||||
// Mock the notifications service
|
// Mock the notifications service
|
||||||
$provide.decorator('notifications', function () {
|
$provide.decorator('notifications', function () {
|
||||||
|
@ -33,14 +34,14 @@ describe("repeat directive", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the Repeat setting was set to 'none', when I cycle through the values, then the Repeat setting will be set to 'queue'", function() {
|
it("Given that the Repeat setting was set to 'none', when I cycle through the values, then the Repeat setting will be set to 'queue'", function () {
|
||||||
isolateScope.cycleRepeat();
|
isolateScope.cycleRepeat();
|
||||||
isolateScope.$apply();
|
isolateScope.$apply();
|
||||||
|
|
||||||
expect(mockGlobals.settings.Repeat).toBe('queue');
|
expect(mockGlobals.settings.Repeat).toBe('queue');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the Repeat setting was set to 'queue', when I cycle through the values, then the Repeat setting will be set to 'song'", function() {
|
it("Given that the Repeat setting was set to 'queue', when I cycle through the values, then the Repeat setting will be set to 'song'", function () {
|
||||||
mockGlobals.settings.Repeat = 'queue';
|
mockGlobals.settings.Repeat = 'queue';
|
||||||
isolateScope.$apply();
|
isolateScope.$apply();
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ describe("repeat directive", function() {
|
||||||
expect(mockGlobals.settings.Repeat).toBe('song');
|
expect(mockGlobals.settings.Repeat).toBe('song');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the Repeat setting was set to 'song', when I cycle through the values, then the Repeat setting will be set to 'none", function() {
|
it("Given that the Repeat setting was set to 'song', when I cycle through the values, then the Repeat setting will be set to 'none", function () {
|
||||||
mockGlobals.settings.Repeat = 'song';
|
mockGlobals.settings.Repeat = 'song';
|
||||||
isolateScope.$apply();
|
isolateScope.$apply();
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ describe("repeat directive", function() {
|
||||||
expect(mockGlobals.settings.Repeat).toBe('none');
|
expect(mockGlobals.settings.Repeat).toBe('none');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I cycle through the values, then the user will be notified with the new value", function() {
|
it("When I cycle through the values, then the user will be notified with the new value", function () {
|
||||||
isolateScope.cycleRepeat();
|
isolateScope.cycleRepeat();
|
||||||
isolateScope.$apply();
|
isolateScope.$apply();
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
describe("Queue controller", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Queue controller", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var player, scope;
|
var player, scope;
|
||||||
var song;
|
var song;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.queue.controller');
|
module('jamstash.queue.controller');
|
||||||
|
|
||||||
inject(function ($controller, $rootScope, globals, _player_) {
|
inject(function ($controller, $rootScope, globals, _player_) {
|
||||||
|
@ -21,13 +22,13 @@ describe("Queue controller", function() {
|
||||||
player.queue = [];
|
player.queue = [];
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I play a song, 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");
|
spyOn(player, "play");
|
||||||
scope.playSong(song);
|
scope.playSong(song);
|
||||||
expect(player.play).toHaveBeenCalledWith(song);
|
expect(player.play).toHaveBeenCalledWith(song);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I empty the queue, it calls emptyQueue in the player service and closes fancybox", function() {
|
it("When I empty the queue, it calls emptyQueue in the player service and closes fancybox", function () {
|
||||||
spyOn(player, "emptyQueue");
|
spyOn(player, "emptyQueue");
|
||||||
spyOn($.fancybox, "close");
|
spyOn($.fancybox, "close");
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ describe("Queue controller", function() {
|
||||||
expect($.fancybox.close).toHaveBeenCalled();
|
expect($.fancybox.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I shuffle the queue, then the player's shuffleQueue will be called and the queue will be scrolled back to the first element", function() {
|
it("When I shuffle the queue, then the player's shuffleQueue will be called and the queue will be scrolled back to the first element", function () {
|
||||||
spyOn(player, "shuffleQueue");
|
spyOn(player, "shuffleQueue");
|
||||||
spyOn($.fn, 'scrollTo');
|
spyOn($.fn, 'scrollTo');
|
||||||
|
|
||||||
|
@ -46,19 +47,19 @@ describe("Queue controller", function() {
|
||||||
expect($.fn.scrollTo).toHaveBeenCalledWith('.header', jasmine.any(Number));
|
expect($.fn.scrollTo).toHaveBeenCalledWith('.header', jasmine.any(Number));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I add one song to the queue, it calls addSong in the player service", function() {
|
it("When I add one song to the queue, it calls addSong in the player service", function () {
|
||||||
spyOn(player, "addSong");
|
spyOn(player, "addSong");
|
||||||
scope.addSongToQueue(song);
|
scope.addSongToQueue(song);
|
||||||
expect(player.addSong).toHaveBeenCalledWith(song);
|
expect(player.addSong).toHaveBeenCalledWith(song);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("When I remove a song from the queue, it calls removeSong in the player service", function() {
|
it("When I remove a song from the queue, it calls removeSong in the player service", function () {
|
||||||
spyOn(player, "removeSong");
|
spyOn(player, "removeSong");
|
||||||
scope.removeSongFromQueue(song);
|
scope.removeSongFromQueue(song);
|
||||||
expect(player.removeSong).toHaveBeenCalledWith(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() {
|
it("When I remove all the selected songs from the queue, it calls removeSongs in the player service", function () {
|
||||||
spyOn(player, "removeSongs");
|
spyOn(player, "removeSongs");
|
||||||
var secondSong = { id: 6791 };
|
var secondSong = { id: 6791 };
|
||||||
scope.selectedSongs = [song, secondSong];
|
scope.selectedSongs = [song, secondSong];
|
||||||
|
@ -66,14 +67,14 @@ describe("Queue controller", function() {
|
||||||
expect(player.removeSongs).toHaveBeenCalledWith([song, secondSong]);
|
expect(player.removeSongs).toHaveBeenCalledWith([song, secondSong]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("asks the player service if a given song is the currently playing song", function() {
|
it("asks the player service if a given song is the currently playing song", function () {
|
||||||
spyOn(player, "getPlayingSong").and.returnValue(song);
|
spyOn(player, "getPlayingSong").and.returnValue(song);
|
||||||
expect(scope.isPlayingSong(song)).toBeTruthy();
|
expect(scope.isPlayingSong(song)).toBeTruthy();
|
||||||
expect(player.getPlayingSong).toHaveBeenCalled();
|
expect(player.getPlayingSong).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when the player service's current song changes, it scrolls the queue to display it", function() {
|
it("when the player service's current song changes, it scrolls the queue to display it", function () {
|
||||||
spyOn(player, "getPlayingSong").and.callFake(function() {
|
spyOn(player, "getPlayingSong").and.callFake(function () {
|
||||||
return song;
|
return song;
|
||||||
});
|
});
|
||||||
spyOn($.fn, "scrollTo");
|
spyOn($.fn, "scrollTo");
|
||||||
|
@ -83,20 +84,20 @@ describe("Queue controller", function() {
|
||||||
expect($.fn.scrollTo).toHaveBeenCalled();
|
expect($.fn.scrollTo).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("reorders the queue by drag and drop - ", function() {
|
describe("reorders the queue by drag and drop - ", function () {
|
||||||
var mockUI;
|
var mockUI;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
player.queue = [
|
player.queue = [
|
||||||
{id: 2246},
|
{ id: 2246 },
|
||||||
{id: 8869},
|
{ id: 8869 },
|
||||||
{id: 285}
|
{ id: 285 }
|
||||||
];
|
];
|
||||||
mockUI = {
|
mockUI = {
|
||||||
item: {}
|
item: {}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("given a song in the queue, when I start dragging it, it records what its starting position in the queue was", function() {
|
it("given a song in the queue, when I start dragging it, it records what its starting position in the queue was", function () {
|
||||||
mockUI.item.index = jasmine.createSpy("index").and.returnValue('1');
|
mockUI.item.index = jasmine.createSpy("index").and.returnValue('1');
|
||||||
mockUI.item.data = jasmine.createSpy("data");
|
mockUI.item.data = jasmine.createSpy("data");
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ describe("Queue controller", function() {
|
||||||
expect(mockUI.item.data).toHaveBeenCalledWith('start', '1');
|
expect(mockUI.item.data).toHaveBeenCalledWith('start', '1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("given a song in the queue that I started dragging, when I drop it, its position in the queue has changed", function() {
|
it("given a song in the queue that I started dragging, when I drop it, its position in the queue has changed", function () {
|
||||||
mockUI.item.index = jasmine.createSpy("index").and.returnValue('0');
|
mockUI.item.index = jasmine.createSpy("index").and.returnValue('0');
|
||||||
mockUI.item.data = jasmine.createSpy("data").and.returnValue('1');
|
mockUI.item.data = jasmine.createSpy("data").and.returnValue('1');
|
||||||
|
|
||||||
|
@ -116,15 +117,15 @@ describe("Queue controller", function() {
|
||||||
expect(mockUI.item.data).toHaveBeenCalledWith('start');
|
expect(mockUI.item.data).toHaveBeenCalledWith('start');
|
||||||
// The second song should now be first
|
// The second song should now be first
|
||||||
expect(player.queue).toEqual([
|
expect(player.queue).toEqual([
|
||||||
{id: 8869},
|
{ id: 8869 },
|
||||||
{id: 2246},
|
{ id: 2246 },
|
||||||
{id: 285}
|
{ id: 285 }
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Hyz: Maybe it should be an end-to-end test
|
// TODO: Hyz: Maybe it should be an end-to-end test
|
||||||
it("given that the player is playing the second song (B), when I swap the first (A) and the second song (B), the player's next song should be A", function() {
|
it("given that the player is playing the second song (B), when I swap the first (A) and the second song (B), the player's next song should be A", function () {
|
||||||
player.play({id: 8869});
|
player.play({ id: 8869 });
|
||||||
mockUI.item.index = jasmine.createSpy("index").and.returnValue('0');
|
mockUI.item.index = jasmine.createSpy("index").and.returnValue('0');
|
||||||
mockUI.item.data = jasmine.createSpy("data").and.returnValue('1');
|
mockUI.item.data = jasmine.createSpy("data").and.returnValue('1');
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ describe("Queue controller", function() {
|
||||||
|
|
||||||
player.nextTrack();
|
player.nextTrack();
|
||||||
expect(player._playingIndex).toBe(1);
|
expect(player._playingIndex).toBe(1);
|
||||||
expect(player._playingSong).toEqual({id: 2246});
|
expect(player._playingSong).toEqual({ id: 2246 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
describe("Settings service", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Settings service", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var globals;
|
var globals;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.settings.service');
|
module('jamstash.settings.service');
|
||||||
inject(function (_globals_) {
|
inject(function (_globals_) {
|
||||||
globals = _globals_;
|
globals = _globals_;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given 'http://subsonic.org/demo', when calling BaseURL() then I get 'http://subsonic.org/demo/rest'", function() {
|
it("Given 'http://subsonic.org/demo', when calling BaseURL() then I get 'http://subsonic.org/demo/rest'", function () {
|
||||||
globals.settings.Server = "http://subsonic.org/demo";
|
globals.settings.Server = "http://subsonic.org/demo";
|
||||||
expect(globals.BaseURL()).toBe("http://subsonic.org/demo/rest");
|
expect(globals.BaseURL()).toBe("http://subsonic.org/demo/rest");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
describe("Settings controller", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Settings controller", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var scope, $rootScope, $controller, $location, $q,
|
var scope, $rootScope, $controller, $location, $q,
|
||||||
controllerParams, utils, persistence, mockGlobals, json, notifications, subsonic, deferred;
|
controllerParams, utils, persistence, mockGlobals, json, notifications, subsonic, deferred;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
jasmine.addCustomEqualityTester(angular.equals);
|
jasmine.addCustomEqualityTester(angular.equals);
|
||||||
|
|
||||||
module('jamstash.settings.controller');
|
module('jamstash.settings.controller');
|
||||||
|
@ -17,7 +18,13 @@ describe("Settings controller", function() {
|
||||||
};
|
};
|
||||||
// Mock all the services
|
// Mock all the services
|
||||||
utils = jasmine.createSpyObj("utils", ["HexEncode"]);
|
utils = jasmine.createSpyObj("utils", ["HexEncode"]);
|
||||||
persistence = jasmine.createSpyObj("persistence", ["saveQueue", "deleteQueue", "deleteTrackPosition", "saveSettings", "deleteSettings"]);
|
persistence = jasmine.createSpyObj("persistence", [
|
||||||
|
"saveQueue",
|
||||||
|
"deleteQueue",
|
||||||
|
"deleteTrackPosition",
|
||||||
|
"saveSettings",
|
||||||
|
"deleteSettings"
|
||||||
|
]);
|
||||||
json = jasmine.createSpyObj("json", ["getChangeLog"]);
|
json = jasmine.createSpyObj("json", ["getChangeLog"]);
|
||||||
notifications = jasmine.createSpyObj("notifications", ["requestPermissionIfRequired", "isSupported", "updateMessage"]);
|
notifications = jasmine.createSpyObj("notifications", ["requestPermissionIfRequired", "isSupported", "updateMessage"]);
|
||||||
|
|
||||||
|
@ -50,20 +57,20 @@ describe("Settings controller", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("", function() {
|
describe("", function () {
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
$controller('SettingsController', controllerParams);
|
$controller('SettingsController', controllerParams);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("save() -", function() {
|
describe("save() -", function () {
|
||||||
it("Given the settings have been set, when I save them, then the settings will be saved using the persistence service and the user will be notified", function() {
|
it("Given the settings have been set, when I save them, then the settings will be saved using the persistence service and the user will be notified", function () {
|
||||||
scope.save();
|
scope.save();
|
||||||
|
|
||||||
expect(persistence.saveSettings).toHaveBeenCalledWith(scope.settings);
|
expect(persistence.saveSettings).toHaveBeenCalledWith(scope.settings);
|
||||||
expect(notifications.updateMessage).toHaveBeenCalledWith('Settings Updated!', true);
|
expect(notifications.updateMessage).toHaveBeenCalledWith('Settings Updated!', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the SaveTrackPosition setting was true, when I save the settings, then the current queue will be saved using the persistence service", function() {
|
it("Given that the SaveTrackPosition setting was true, when I save the settings, then the current queue will be saved using the persistence service", function () {
|
||||||
scope.settings.SaveTrackPosition = true;
|
scope.settings.SaveTrackPosition = true;
|
||||||
|
|
||||||
scope.save();
|
scope.save();
|
||||||
|
@ -71,7 +78,7 @@ describe("Settings controller", function() {
|
||||||
expect(persistence.saveQueue).toHaveBeenCalled();
|
expect(persistence.saveQueue).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the SaveTrackPosition setting was false, when I save the settings, then the saved queue and track will be deleted from the persistence service", function() {
|
it("Given that the SaveTrackPosition setting was false, when I save the settings, then the saved queue and track will be deleted from the persistence service", function () {
|
||||||
scope.settings.SaveTrackPosition = false;
|
scope.settings.SaveTrackPosition = false;
|
||||||
|
|
||||||
scope.save();
|
scope.save();
|
||||||
|
@ -80,7 +87,7 @@ describe("Settings controller", function() {
|
||||||
expect(persistence.deleteQueue).toHaveBeenCalled();
|
expect(persistence.deleteQueue).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given that the Server, Username and Password settings weren't empty, when I save the settings, then subsonic service will be pinged", function() {
|
it("Given that the Server, Username and Password settings weren't empty, when I save the settings, then subsonic service will be pinged", function () {
|
||||||
scope.settings.Server = 'http://hexagram.com/malacobdella/liposis?a=platybasic&b=enantiopathia#stratoplane';
|
scope.settings.Server = 'http://hexagram.com/malacobdella/liposis?a=platybasic&b=enantiopathia#stratoplane';
|
||||||
scope.settings.Username = 'Mollura';
|
scope.settings.Username = 'Mollura';
|
||||||
scope.settings.Password = 'FPTVjZtBwEyq';
|
scope.settings.Password = 'FPTVjZtBwEyq';
|
||||||
|
@ -91,7 +98,7 @@ describe("Settings controller", function() {
|
||||||
expect(subsonic.ping).toHaveBeenCalled();
|
expect(subsonic.ping).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given the server and Jamstash had different api versions, when I save the settings and the server responds an error, then the ApiVersion setting will be updated with the one sent from the server", function() {
|
it("Given the server and Jamstash had different api versions, when I save the settings and the server responds an error, then the ApiVersion setting will be updated with the one sent from the server", function () {
|
||||||
scope.settings.Server = 'http://gallotannate.com/tetranychus/puzzlement?a=stoically&b=mantuamaker#marianolatrist';
|
scope.settings.Server = 'http://gallotannate.com/tetranychus/puzzlement?a=stoically&b=mantuamaker#marianolatrist';
|
||||||
scope.settings.Username = 'Vandervelden';
|
scope.settings.Username = 'Vandervelden';
|
||||||
scope.settings.Password = 'PA3DhdfAu0dy';
|
scope.settings.Password = 'PA3DhdfAu0dy';
|
||||||
|
@ -101,7 +108,7 @@ describe("Settings controller", function() {
|
||||||
scope.save();
|
scope.save();
|
||||||
deferred.reject({
|
deferred.reject({
|
||||||
reason: 'Error when contacting the Subsonic server.',
|
reason: 'Error when contacting the Subsonic server.',
|
||||||
subsonicError: {code: 30, message: 'Incompatible Subsonic REST protocol version. Server must upgrade.'},
|
subsonicError: { code: 30, message: 'Incompatible Subsonic REST protocol version. Server must upgrade.' },
|
||||||
version: '1.8.0'
|
version: '1.8.0'
|
||||||
});
|
});
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
@ -110,7 +117,7 @@ describe("Settings controller", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reset() - When I reset the settings, they will be deleted from the persistence service and will be reloaded with default values", function() {
|
it("reset() - When I reset the settings, they will be deleted from the persistence service and will be reloaded with default values", function () {
|
||||||
scope.reset();
|
scope.reset();
|
||||||
|
|
||||||
expect(persistence.deleteSettings).toHaveBeenCalled();
|
expect(persistence.deleteSettings).toHaveBeenCalled();
|
||||||
|
@ -118,7 +125,7 @@ describe("Settings controller", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("On startup", function() {
|
describe("On startup", function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
describe("breadcrumbs directive", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("breadcrumbs directive", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var $q, deferred, element, scope, controller, subsonic, notifications, breadcrumbs;
|
var $q, deferred, element, scope, controller, subsonic, notifications, breadcrumbs;
|
||||||
|
|
||||||
beforeEach(module ('templates'));
|
beforeEach(module('templates'));
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.breadcrumbs.directive', function($provide) {
|
module('jamstash.breadcrumbs.directive', function ($provide) {
|
||||||
subsonic = jasmine.createSpyObj("subsonic", ["getSongs"]);
|
subsonic = jasmine.createSpyObj("subsonic", ["getSongs"]);
|
||||||
$provide.value('subsonic', subsonic);
|
$provide.value('subsonic', subsonic);
|
||||||
notifications = jasmine.createSpyObj("notifications", ["updateMessage"]);
|
notifications = jasmine.createSpyObj("notifications", ["updateMessage"]);
|
||||||
|
@ -32,7 +33,7 @@ describe("breadcrumbs directive", function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a music directory that contained 2 songs and 1 subdirectory and given its id and name, when I display its songs, then subsonic service will be called, the breadcrumbs will be popped until they only display the directory and the songs and directory will be published to the scope", function() {
|
it("Given a music directory that contained 2 songs and 1 subdirectory and given its id and name, when I display its songs, then subsonic service will be called, the breadcrumbs will be popped until they only display the directory and the songs and directory will be published to the scope", function () {
|
||||||
controller.displaySongs({
|
controller.displaySongs({
|
||||||
id: 680,
|
id: 680,
|
||||||
name: "henchman unstormy"
|
name: "henchman unstormy"
|
||||||
|
@ -60,19 +61,19 @@ describe("breadcrumbs directive", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a music directory, when I display it, then handleErrors will handle HTTP and Subsonic errors", function() {
|
it("Given a music directory, when I display it, then handleErrors will handle HTTP and Subsonic errors", function () {
|
||||||
controller.displaySongs({
|
controller.displaySongs({
|
||||||
id: 628
|
id: 628
|
||||||
});
|
});
|
||||||
expect(scope.handleErrors).toHaveBeenCalledWith(deferred.promise);
|
expect(scope.handleErrors).toHaveBeenCalledWith(deferred.promise);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given a music directory that didn't contain anything, when I display it, then an error notification will be displayed", function() {
|
it("Given a music directory that didn't contain anything, when I display it, then an error notification will be displayed", function () {
|
||||||
controller.displaySongs({
|
controller.displaySongs({
|
||||||
id: 242,
|
id: 242,
|
||||||
name: "discinoid"
|
name: "discinoid"
|
||||||
});
|
});
|
||||||
deferred.reject({reason: 'This directory is empty.'});
|
deferred.reject({ reason: 'This directory is empty.' });
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
|
|
||||||
expect(notifications.updateMessage).toHaveBeenCalledWith('This directory is empty.', true);
|
expect(notifications.updateMessage).toHaveBeenCalledWith('This directory is empty.', true);
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
describe("Breadcrumbs service -", function() {
|
// jscs:disable validateQuoteMarks
|
||||||
|
describe("Breadcrumbs service -", function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var breadcrumbs;
|
var breadcrumbs;
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
module('jamstash.breadcrumbs.service');
|
module('jamstash.breadcrumbs.service');
|
||||||
|
|
||||||
inject(function(_breadcrumbs_) {
|
inject(function (_breadcrumbs_) {
|
||||||
breadcrumbs = _breadcrumbs_;
|
breadcrumbs = _breadcrumbs_;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("push() -", function() {
|
describe("push() -", function () {
|
||||||
it("Given an item with an id and a name and given the breadcrumbs were empty, when I push it to the breadcrumbs and I get them, then an array of 1 item containing an id and name will be returned", function() {
|
it("Given an item with an id and a name and given the breadcrumbs were empty, when I push it to the breadcrumbs and I get them, then an array of 1 item containing an id and name will be returned", function () {
|
||||||
breadcrumbs.push({
|
breadcrumbs.push({
|
||||||
id: 240,
|
id: 240,
|
||||||
name: "Renee Stuekerjuerge"
|
name: "Renee Stuekerjuerge"
|
||||||
|
@ -25,7 +26,7 @@ describe("Breadcrumbs service -", function() {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given an item with an id and a name and given the breadcrumbs already contained another item, when I push the item to the breadcrumbs and I get them, then an array of 2 items will be returned and the item I pushed will be the second one", function() {
|
it("Given an item with an id and a name and given the breadcrumbs already contained another item, when I push the item to the breadcrumbs and I get them, then an array of 2 items will be returned and the item I pushed will be the second one", function () {
|
||||||
breadcrumbs.push({
|
breadcrumbs.push({
|
||||||
id: 150,
|
id: 150,
|
||||||
name: "Collen Kampmann"
|
name: "Collen Kampmann"
|
||||||
|
@ -46,8 +47,8 @@ describe("Breadcrumbs service -", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("popUntil() -", function() {
|
describe("popUntil() -", function () {
|
||||||
it("Given an item with an id and a name, and given the breadcrumbs already contained this item as first element and 2 others, when I pop breadcrumbs until finding the provided item, then an array containing only the provided item will be returned", function() {
|
it("Given an item with an id and a name, and given the breadcrumbs already contained this item as first element and 2 others, when I pop breadcrumbs until finding the provided item, then an array containing only the provided item will be returned", function () {
|
||||||
breadcrumbs.push({
|
breadcrumbs.push({
|
||||||
id: 979,
|
id: 979,
|
||||||
name: "telescopic Sivatheriinae"
|
name: "telescopic Sivatheriinae"
|
||||||
|
@ -72,7 +73,7 @@ describe("Breadcrumbs service -", function() {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given an item with an id and a name, and given the breadcrumbs already contained this item as last element and 2 others, when I pop breadcrumbs until finding the provided item, then an array containing all 3 items will be returned", function() {
|
it("Given an item with an id and a name, and given the breadcrumbs already contained this item as last element and 2 others, when I pop breadcrumbs until finding the provided item, then an array containing all 3 items will be returned", function () {
|
||||||
breadcrumbs.push({
|
breadcrumbs.push({
|
||||||
id: 474,
|
id: 474,
|
||||||
name: "Kolinsky"
|
name: "Kolinsky"
|
||||||
|
@ -103,7 +104,7 @@ describe("Breadcrumbs service -", function() {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given an item with an id and a name that didn't exist in the breadcrumbs, and given the breadcrumbs contained 3 items, when I pop breadcrumbs until finding the provided item, then an array containing all 3 breadcrumbs will be returned", function() {
|
it("Given an item with an id and a name that didn't exist in the breadcrumbs, and given the breadcrumbs contained 3 items, when I pop breadcrumbs until finding the provided item, then an array containing all 3 breadcrumbs will be returned", function () {
|
||||||
breadcrumbs.push({
|
breadcrumbs.push({
|
||||||
id: 46,
|
id: 46,
|
||||||
name: "Cordell"
|
name: "Cordell"
|
||||||
|
@ -134,7 +135,7 @@ describe("Breadcrumbs service -", function() {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given an item with an id and a name, and given the breadcrumbs were empty, when I pop breadcrumbs until finding the provided item, then an empty array will be returned", function() {
|
it("Given an item with an id and a name, and given the breadcrumbs were empty, when I pop breadcrumbs until finding the provided item, then an empty array will be returned", function () {
|
||||||
var list = breadcrumbs.popUntil({
|
var list = breadcrumbs.popUntil({
|
||||||
id: 605,
|
id: 605,
|
||||||
name: "spacecraft"
|
name: "spacecraft"
|
||||||
|
@ -145,7 +146,7 @@ describe("Breadcrumbs service -", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("reset() -", function () {
|
describe("reset() -", function () {
|
||||||
it("Given a breadcrumb had been previously set, when I reset the breadcrumbs, then they will be empty", function() {
|
it("Given a breadcrumb had been previously set, when I reset the breadcrumbs, then they will be empty", function () {
|
||||||
breadcrumbs.push({
|
breadcrumbs.push({
|
||||||
id: 350,
|
id: 350,
|
||||||
name: "exterritoriality dubious"
|
name: "exterritoriality dubious"
|
||||||
|
@ -156,7 +157,7 @@ describe("Breadcrumbs service -", function() {
|
||||||
expect(list).toEqual([]);
|
expect(list).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Given the breadcrumbs were empty, when I reset them, then they will be empty", function() {
|
it("Given the breadcrumbs were empty, when I reset them, then they will be empty", function () {
|
||||||
var list = breadcrumbs.reset().get();
|
var list = breadcrumbs.reset().get();
|
||||||
|
|
||||||
expect(list).toEqual([]);
|
expect(list).toEqual([]);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue