2016-06-02 01:56:25 +00:00
|
|
|
const assert = require('assert')
|
|
|
|
const {remote} = require('electron')
|
|
|
|
const {systemPreferences} = remote
|
|
|
|
|
|
|
|
describe('systemPreferences module', function () {
|
2016-09-16 16:13:09 +00:00
|
|
|
describe('systemPreferences.getAccentColor', function () {
|
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
it('should return a non-empty string', function () {
|
2016-09-16 16:27:46 +00:00
|
|
|
let accentColor = systemPreferences.getAccentColor()
|
|
|
|
assert.notEqual(accentColor, null)
|
|
|
|
assert(accentColor.length > 0)
|
2016-09-16 16:13:09 +00:00
|
|
|
})
|
|
|
|
})
|
2016-06-02 01:56:25 +00:00
|
|
|
|
2016-10-10 22:06:25 +00:00
|
|
|
describe('systemPreferences.getColor(id)', function () {
|
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
it('throws an error when the id is invalid', function () {
|
|
|
|
assert.throws(function () {
|
|
|
|
systemPreferences.getColor('not-a-color')
|
|
|
|
}, /Unknown color: not-a-color/)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('returns a hex RGB color string', function () {
|
|
|
|
assert.equal(/^#[0-9A-F]{6}$/i.test(systemPreferences.getColor('window')), true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2016-06-02 02:29:24 +00:00
|
|
|
describe('systemPreferences.getUserDefault(key, type)', function () {
|
2016-09-16 16:13:09 +00:00
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:29:24 +00:00
|
|
|
it('returns values for known user defaults', function () {
|
|
|
|
let locale = systemPreferences.getUserDefault('AppleLocale', 'string')
|
|
|
|
assert.notEqual(locale, null)
|
|
|
|
assert(locale.length > 0)
|
2016-06-02 01:56:25 +00:00
|
|
|
|
2016-06-02 02:29:24 +00:00
|
|
|
let languages = systemPreferences.getUserDefault('AppleLanguages', 'array')
|
|
|
|
assert.notEqual(languages, null)
|
|
|
|
assert(languages.length > 0)
|
|
|
|
})
|
2016-06-02 01:56:25 +00:00
|
|
|
})
|
2016-10-06 22:27:24 +00:00
|
|
|
|
|
|
|
describe('systemPreferences.isInvertedColorScheme()', function () {
|
|
|
|
it('returns a boolean', function () {
|
|
|
|
assert.equal(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
|
|
|
|
})
|
|
|
|
})
|
2016-06-02 01:56:25 +00:00
|
|
|
})
|