upgrade system pref spec
This commit is contained in:
parent
d8f2183b3d
commit
1130ccf69b
1 changed files with 16 additions and 25 deletions
|
@ -2,41 +2,37 @@ const assert = require('assert')
|
||||||
const {remote} = require('electron')
|
const {remote} = require('electron')
|
||||||
const {systemPreferences} = remote
|
const {systemPreferences} = remote
|
||||||
|
|
||||||
describe('systemPreferences module', function () {
|
describe('systemPreferences module', () => {
|
||||||
describe('systemPreferences.getAccentColor', function () {
|
describe('systemPreferences.getAccentColor', () => {
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
it('should return a non-empty string', function () {
|
it('should return a non-empty string', () => {
|
||||||
let accentColor = systemPreferences.getAccentColor()
|
let accentColor = systemPreferences.getAccentColor()
|
||||||
assert.notEqual(accentColor, null)
|
assert.notEqual(accentColor, null)
|
||||||
assert(accentColor.length > 0)
|
assert(accentColor.length > 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('systemPreferences.getColor(id)', function () {
|
describe('systemPreferences.getColor(id)', () => {
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
it('throws an error when the id is invalid', function () {
|
it('throws an error when the id is invalid', () => {
|
||||||
assert.throws(function () {
|
assert.throws(() => {
|
||||||
systemPreferences.getColor('not-a-color')
|
systemPreferences.getColor('not-a-color')
|
||||||
}, /Unknown color: not-a-color/)
|
}, /Unknown color: not-a-color/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns a hex RGB color string', function () {
|
it('returns a hex RGB color string', () => {
|
||||||
assert.equal(/^#[0-9A-F]{6}$/i.test(systemPreferences.getColor('window')), true)
|
assert.equal(/^#[0-9A-F]{6}$/i.test(systemPreferences.getColor('window')), true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('systemPreferences.getUserDefault(key, type)', function () {
|
describe('systemPreferences.getUserDefault(key, type)', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
it('returns values for known user defaults', function () {
|
it('returns values for known user defaults', () => {
|
||||||
const locale = systemPreferences.getUserDefault('AppleLocale', 'string')
|
const locale = systemPreferences.getUserDefault('AppleLocale', 'string')
|
||||||
assert.equal(typeof locale, 'string')
|
assert.equal(typeof locale, 'string')
|
||||||
assert(locale.length > 0)
|
assert(locale.length > 0)
|
||||||
|
@ -46,7 +42,7 @@ describe('systemPreferences module', function () {
|
||||||
assert(languages.length > 0)
|
assert(languages.length > 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns values for unknown user defaults', function () {
|
it('returns values for unknown user defaults', () => {
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false)
|
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false)
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0)
|
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0)
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
|
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
|
||||||
|
@ -60,12 +56,9 @@ describe('systemPreferences module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('systemPreferences.setUserDefault(key, type, value)', () => {
|
describe('systemPreferences.setUserDefault(key, type, value)', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const KEY = 'SystemPreferencesTest'
|
const KEY = 'SystemPreferencesTest'
|
||||||
|
|
||||||
const TEST_CASES = [
|
const TEST_CASES = [
|
||||||
['string', 'abc'],
|
['string', 'abc'],
|
||||||
['boolean', true],
|
['boolean', true],
|
||||||
|
@ -101,9 +94,7 @@ describe('systemPreferences module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('systemPreferences.setUserDefault(key, type, value)', () => {
|
describe('systemPreferences.setUserDefault(key, type, value)', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
it('removes keys', () => {
|
it('removes keys', () => {
|
||||||
const KEY = 'SystemPreferencesTest'
|
const KEY = 'SystemPreferencesTest'
|
||||||
|
@ -117,8 +108,8 @@ describe('systemPreferences module', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('systemPreferences.isInvertedColorScheme()', function () {
|
describe('systemPreferences.isInvertedColorScheme()', () => {
|
||||||
it('returns a boolean', function () {
|
it('returns a boolean', () => {
|
||||||
assert.equal(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
|
assert.equal(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue