Expose the method to JS and write a simple test.
authorCharlie Hess <charlie@slack-corp.com>
Thu, 2 Jun 2016 01:56:25 +0000 (18:56 -0700)
committerCharlie Hess <charlie@slack-corp.com>
Thu, 2 Jun 2016 01:56:25 +0000 (18:56 -0700)
atom/browser/api/atom_api_system_preferences.cc
spec/api-system-preferences-spec.js [new file with mode: 0644]

index 2b11aad..8a02859 100644 (file)
@@ -54,6 +54,7 @@ void SystemPreferences::BuildPrototype(
       .SetMethod("unsubscribeNotification",
                  &SystemPreferences::UnsubscribeNotification)
       .SetMethod("getUserDefault", &SystemPreferences::GetUserDefault)
+      .SetMethod("getGlobalDefault", &SystemPreferences::GetGlobalDefault)
 #endif
       .SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
 }
diff --git a/spec/api-system-preferences-spec.js b/spec/api-system-preferences-spec.js
new file mode 100644 (file)
index 0000000..3cb0cd4
--- /dev/null
@@ -0,0 +1,25 @@
+const assert = require('assert')
+const {remote} = require('electron')
+const {systemPreferences} = remote
+
+describe('systemPreferences module', function () {
+  if (process.platform !== 'darwin') {
+    return
+  }
+
+  it('returns user defaults', function () {
+    assert.notEqual(systemPreferences.getUserDefault('AppleInterfaceStyle', 'string'), null)
+    assert.notEqual(systemPreferences.getUserDefault('AppleAquaColorVariant', 'integer'), null)
+  })
+
+  it('returns defaults under the global domain', function () {
+    let locale = systemPreferences.getGlobalDefault('AppleLocale')
+    assert.notEqual(locale, null)
+    assert(locale.length > 0)
+
+    let languages = systemPreferences.getGlobalDefault('AppleLanguages')
+    assert.notEqual(languages, null)
+    assert(languages.length > 0)
+  })
+
+})