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 {systemPreferences} = remote
|
||||
|
||||
describe('systemPreferences module', function () {
|
||||
describe('systemPreferences.getAccentColor', function () {
|
||||
if (process.platform !== 'win32') {
|
||||
return
|
||||
}
|
||||
describe('systemPreferences module', () => {
|
||||
describe('systemPreferences.getAccentColor', () => {
|
||||
if (process.platform !== 'win32') return
|
||||
|
||||
it('should return a non-empty string', function () {
|
||||
it('should return a non-empty string', () => {
|
||||
let accentColor = systemPreferences.getAccentColor()
|
||||
assert.notEqual(accentColor, null)
|
||||
assert(accentColor.length > 0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('systemPreferences.getColor(id)', function () {
|
||||
if (process.platform !== 'win32') {
|
||||
return
|
||||
}
|
||||
describe('systemPreferences.getColor(id)', () => {
|
||||
if (process.platform !== 'win32') return
|
||||
|
||||
it('throws an error when the id is invalid', function () {
|
||||
assert.throws(function () {
|
||||
it('throws an error when the id is invalid', () => {
|
||||
assert.throws(() => {
|
||||
systemPreferences.getColor('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)
|
||||
})
|
||||
})
|
||||
|
||||
describe('systemPreferences.getUserDefault(key, type)', function () {
|
||||
describe('systemPreferences.getUserDefault(key, type)', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
return
|
||||
}
|
||||
|
||||
it('returns values for known user defaults', function () {
|
||||
it('returns values for known user defaults', () => {
|
||||
const locale = systemPreferences.getUserDefault('AppleLocale', 'string')
|
||||
assert.equal(typeof locale, 'string')
|
||||
assert(locale.length > 0)
|
||||
|
@ -46,7 +42,7 @@ describe('systemPreferences module', function () {
|
|||
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', 'integer'), 0)
|
||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
|
||||
|
@ -60,12 +56,9 @@ describe('systemPreferences module', function () {
|
|||
})
|
||||
|
||||
describe('systemPreferences.setUserDefault(key, type, value)', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
return
|
||||
}
|
||||
if (process.platform !== 'darwin') return
|
||||
|
||||
const KEY = 'SystemPreferencesTest'
|
||||
|
||||
const TEST_CASES = [
|
||||
['string', 'abc'],
|
||||
['boolean', true],
|
||||
|
@ -101,9 +94,7 @@ describe('systemPreferences module', function () {
|
|||
})
|
||||
|
||||
describe('systemPreferences.setUserDefault(key, type, value)', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
return
|
||||
}
|
||||
if (process.platform !== 'darwin') return
|
||||
|
||||
it('removes keys', () => {
|
||||
const KEY = 'SystemPreferencesTest'
|
||||
|
@ -117,8 +108,8 @@ describe('systemPreferences module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('systemPreferences.isInvertedColorScheme()', function () {
|
||||
it('returns a boolean', function () {
|
||||
describe('systemPreferences.isInvertedColorScheme()', () => {
|
||||
it('returns a boolean', () => {
|
||||
assert.equal(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue