diff --git a/lib/gui/app/models/settings.ts b/lib/gui/app/models/settings.ts index 5b3725b4..dd4e05da 100644 --- a/lib/gui/app/models/settings.ts +++ b/lib/gui/app/models/settings.ts @@ -49,30 +49,6 @@ export async function reset(): Promise { return await localSettings.writeAll(settings); } -/** - * @summary Extend the current settings - */ -export async function assign(value: _.Dictionary): Promise { - debug('assign', value); - if (_.isNil(value)) { - throw errors.createError({ - title: 'Missing settings', - }); - } - - if (!_.isPlainObject(value)) { - throw errors.createError({ - title: 'Settings must be an object', - }); - } - - const newSettings = _.assign({}, settings, value); - - const updatedSettings = await localSettings.writeAll(newSettings); - // NOTE: Only update in memory settings when successfully written - settings = updatedSettings; -} - /** * @summary Extend the application state with the local settings */ diff --git a/tests/gui/models/settings.spec.ts b/tests/gui/models/settings.spec.ts index 5f78b4d7..aacd8eb4 100644 --- a/tests/gui/models/settings.spec.ts +++ b/tests/gui/models/settings.spec.ts @@ -95,34 +95,17 @@ describe('Browser: settings', function() { }); }); - describe('.assign()', function() { - it('should not override all settings', function() { - return settings - .assign({ - foo: 'bar', - bar: 'baz', - }) - .then(() => { - expect(settings.getAll()).to.deep.equal( - _.assign({}, DEFAULT_SETTINGS, { - foo: 'bar', - bar: 'baz', - }), - ); - }); - }); - + describe('.set()', function() { it('should store the settings to the local machine', function() { return localSettings .readAll() .then(data => { expect(data.foo).to.be.undefined; expect(data.bar).to.be.undefined; - - return settings.assign({ - foo: 'bar', - bar: 'baz', - }); + return settings.set('foo', 'bar'); + }) + .then(() => { + return settings.set('bar', 'baz'); }) .then(localSettings.readAll) .then(data => { @@ -140,7 +123,7 @@ describe('Browser: settings', function() { Promise.reject(new Error('localSettings error')), ); - await checkError(settings.assign({ foo: 'baz' }), error => { + await checkError(settings.set('foo', 'baz'), error => { expect(error).to.be.an.instanceof(Error); expect(error.message).to.equal('localSettings error'); localSettingsWriteAllStub.restore(); @@ -189,13 +172,6 @@ describe('Browser: settings', function() { }); }); - it('should throw if setting an array', async function() { - await checkError(settings.assign([1, 2, 3]), error => { - expect(error).to.be.an.instanceof(Error); - expect(error.message).to.equal('Settings must be an object'); - }); - }); - it('should set the key to undefined if no value', function() { return settings .set('foo', 'bar')