-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ElectronExternalApi fallback to super when electron app is undef…
…ined, fixes #399 (#400) * fix: ElectronExternalApi fallback to super when electron app is undefined; accept electron arg * test: ElectronExternalApi fallbacks to super when electron app is undefined * chore: Comsetic changes
- Loading branch information
1 parent
ba23a9a
commit a86e48f
Showing
3 changed files
with
101 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const humilePkg = require('humile/package.json'); | ||
const ElectronExternalApi = require('../ElectronExternalApi'); | ||
|
||
describe('ElectronExternalApi', () => { | ||
describe('getAppName', () => { | ||
it('gets the electron app name property', () => { | ||
const electron = { | ||
app: { | ||
name: 'test-prop', | ||
getName: () => 'test-func', | ||
}, | ||
}; | ||
|
||
expect(api({ electron }).getAppName()).toBe('test-prop'); | ||
}); | ||
|
||
it('calls the electron app name function when no name property', () => { | ||
const electron = { | ||
app: { | ||
name: undefined, | ||
getName: () => 'test-func', | ||
}, | ||
}; | ||
|
||
expect(api({ electron }).getAppName()).toBe('test-func'); | ||
}); | ||
|
||
it('fallsback to super function when no electron names', () => { | ||
const electron = { | ||
app: { | ||
name: undefined, | ||
getName: undefined, | ||
}, | ||
}; | ||
|
||
expect(api({ electron }).getAppName()).toBe(humilePkg.name); | ||
}); | ||
|
||
it('fallsback to super function when no electron', () => { | ||
const electron = undefined; | ||
|
||
expect(api({ electron }).getAppName()).toBe(humilePkg.name); | ||
}); | ||
}); | ||
|
||
/** | ||
* @param {object} options | ||
* @param {NodeJS.Platform} options.platform | ||
* @param {typeof Electron} options.electron | ||
* @returns {ElectronExternalApi} | ||
*/ | ||
function api({ electron, platform = process.platform } = {}) { | ||
const externalApi = new ElectronExternalApi({ electron }); | ||
externalApi.setPlatform(platform); | ||
return externalApi; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters