Adds back setting the volume up / down using the keyboard
- Adds a volume field to the player service. It is set directly, no need for get/set... - Adds a watcher in player-directive to set jPlayer's volume accordingly - Adds turnVolumeUp and turnVolumeDown methods to the main scope. For the moment they are fine there, we'll maybe move them to the player service if they are called by anything else. - Adds get/save/delete for the volume in the persistence service.
This commit is contained in:
parent
8529e331a2
commit
a85865371c
8 changed files with 196 additions and 57 deletions
|
@ -85,19 +85,37 @@ describe("Persistence service", function() {
|
|||
expect(notifications.updateMessage).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("getVolume -", function() {
|
||||
it("Given that we previously saved the volume in local Storage, it retrieves it", function() {
|
||||
fakeStorage = { 'Volume': 0.46582 };
|
||||
|
||||
var volume = persistence.getVolume();
|
||||
|
||||
expect(locker.get).toHaveBeenCalledWith('Volume');
|
||||
expect(volume).toBe(0.46582);
|
||||
});
|
||||
|
||||
it("Given that we didn't save the volume in local Storage, it returns undefined", function() {
|
||||
var volume = persistence.getVolume();
|
||||
|
||||
expect(locker.get).toHaveBeenCalledWith('Volume');
|
||||
expect(volume).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("save from localStorage -", function() {
|
||||
describe("save to localStorage -", function() {
|
||||
beforeEach(function() {
|
||||
spyOn(locker, "put");
|
||||
});
|
||||
|
||||
it("it saves the current track's position in local Storage", function() {
|
||||
it("saves the current track's position in local Storage", function() {
|
||||
persistence.saveTrackPosition(song);
|
||||
expect(locker.put).toHaveBeenCalledWith('CurrentSong', song);
|
||||
});
|
||||
|
||||
it("it saves the playing queue in local Storage", function() {
|
||||
it("saves the playing queue in local Storage", function() {
|
||||
player.queue = [
|
||||
{ id: 1245 },
|
||||
{ id: 7465 },
|
||||
|
@ -106,6 +124,11 @@ describe("Persistence service", function() {
|
|||
persistence.saveQueue();
|
||||
expect(locker.put).toHaveBeenCalledWith('CurrentQueue', player.queue);
|
||||
});
|
||||
|
||||
it("saves the volume in local Storage", function() {
|
||||
persistence.saveVolume(0.05167);
|
||||
expect(locker.put).toHaveBeenCalledWith('Volume', 0.05167);
|
||||
});
|
||||
});
|
||||
|
||||
describe("remove from localStorage -", function() {
|
||||
|
@ -113,14 +136,19 @@ describe("Persistence service", function() {
|
|||
spyOn(locker, "forget");
|
||||
});
|
||||
|
||||
it("it deletes the current track from local Storage", function() {
|
||||
it("deletes the current track from local Storage", function() {
|
||||
persistence.deleteTrackPosition();
|
||||
expect(locker.forget).toHaveBeenCalledWith('CurrentSong');
|
||||
});
|
||||
|
||||
it("it deletes the saved playing queue from local Storage", function() {
|
||||
it("deletes the saved playing queue from local Storage", function() {
|
||||
persistence.deleteQueue();
|
||||
expect(locker.forget).toHaveBeenCalledWith('CurrentQueue');
|
||||
});
|
||||
|
||||
it("deletes the saved volume from local Storage", function() {
|
||||
persistence.deleteVolume();
|
||||
expect(locker.forget).toHaveBeenCalledWith('Volume');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue