Expose the method to JS and write a simple test.
This commit is contained in:
parent
0230567891
commit
587dd2fe51
2 changed files with 26 additions and 0 deletions
|
@ -54,6 +54,7 @@ void SystemPreferences::BuildPrototype(
|
||||||
.SetMethod("unsubscribeNotification",
|
.SetMethod("unsubscribeNotification",
|
||||||
&SystemPreferences::UnsubscribeNotification)
|
&SystemPreferences::UnsubscribeNotification)
|
||||||
.SetMethod("getUserDefault", &SystemPreferences::GetUserDefault)
|
.SetMethod("getUserDefault", &SystemPreferences::GetUserDefault)
|
||||||
|
.SetMethod("getGlobalDefault", &SystemPreferences::GetGlobalDefault)
|
||||||
#endif
|
#endif
|
||||||
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
|
.SetMethod("isDarkMode", &SystemPreferences::IsDarkMode);
|
||||||
}
|
}
|
||||||
|
|
25
spec/api-system-preferences-spec.js
Normal file
25
spec/api-system-preferences-spec.js
Normal file
|
@ -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)
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
Loading…
Reference in a new issue