Uses angular-locker to store settings in localStorage
- settings.js now has its own module : 'jamstash.settings.controller'. This makes it easier to test it and identify what dependencies it has. - Renames 'jamstash.settings' module into 'jamstash.settings.service' - Adds an angular constant to hold the current Jamstash version in app.js. - Adds a way to upgrade incrementally what was in localStorage : in 4.4.5, DefaultSearchType will no longer be an object but an int, so we must init it with an int value, otherwise a blank option will be displayed. We detect what version we are using and what version was stored using persistence-service.js and run the upgrade accordingly. - Refactors almost completely persistence-service_test.js - Unit-tests some of settings.js's methods.
This commit is contained in:
parent
f98740d613
commit
a97e5159bc
17 changed files with 383 additions and 150 deletions
|
@ -21,7 +21,14 @@ describe("Main controller", function() {
|
|||
player.queue = [];
|
||||
|
||||
// Mock the persistence service
|
||||
persistence = jasmine.createSpyObj("persistence", ["loadQueue", "loadTrackPosition", "getVolume", "saveVolume"]);
|
||||
persistence = jasmine.createSpyObj("persistence", [
|
||||
"loadQueue",
|
||||
"loadTrackPosition",
|
||||
"getVolume",
|
||||
"saveVolume",
|
||||
"getSettings",
|
||||
"saveSettings"
|
||||
]);
|
||||
|
||||
inject(function (_$controller_, $rootScope, _$document_, _$window_, _$location_, _$cookieStore_, _utils_, globals, _model_, _notifications_, _Page_) {
|
||||
scope = $rootScope.$new();
|
||||
|
@ -166,6 +173,24 @@ describe("Main controller", function() {
|
|||
expect(player.previousTrack).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
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() {
|
||||
persistence.getSettings.and.returnValue({
|
||||
"Url": "http://gmelinite.com/contrastive/hypercyanotic?a=overdrive&b=chirpling#postjugular",
|
||||
"Username": "Hollingshead",
|
||||
"AutoPlaylistSize": 25,
|
||||
"AutoPlay": true
|
||||
});
|
||||
|
||||
scope.loadSettings();
|
||||
expect(mockGlobals.settings.Username).toEqual("Hollingshead");
|
||||
expect(mockGlobals.settings.AutoPlaylistSize).toBe(25);
|
||||
expect(mockGlobals.settings.AutoPlay).toBe(true);
|
||||
expect(mockGlobals.settings.Url).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe("When starting up,", function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue