From cbffd598f9277fbd5aed762228997031f00e0789 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 16 Nov 2016 16:28:57 -0800 Subject: [PATCH] Add failing spec for unknown user defaults --- spec/api-system-preferences-spec.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/spec/api-system-preferences-spec.js b/spec/api-system-preferences-spec.js index e61ae726dfcc..e893a7c55e24 100644 --- a/spec/api-system-preferences-spec.js +++ b/spec/api-system-preferences-spec.js @@ -37,14 +37,26 @@ describe('systemPreferences module', function () { } it('returns values for known user defaults', function () { - let locale = systemPreferences.getUserDefault('AppleLocale', 'string') - assert.notEqual(locale, null) + const locale = systemPreferences.getUserDefault('AppleLocale', 'string') + assert.equal(typeof locale, 'string') assert(locale.length > 0) - let languages = systemPreferences.getUserDefault('AppleLanguages', 'array') - assert.notEqual(languages, null) + const languages = systemPreferences.getUserDefault('AppleLanguages', 'array') + assert(Array.isArray(languages)) assert(languages.length > 0) }) + + it('returns values for unknown user defaults', function () { + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false) + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0) + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0) + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'double'), 0) + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'string'), '') + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'url'), '') + assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'badtype'), undefined) + assert.deepEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'array'), []) + assert.deepEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'dictionary'), {}) + }) }) describe('systemPreferences.isInvertedColorScheme()', function () {