New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Properly cleanup in `removeAsDefaultProtocolClient` #11329

Merged
merged 10 commits into from Dec 6, 2017

👷 Test registry interaction

  • Loading branch information...
felixrieseberg committed Dec 5, 2017
commit e77751aab57b47235e8006773dd4aff5a77a1195
Copy path View file
@@ -504,9 +504,19 @@ describe('app module', () => {
'--process-start-args', `"--hidden"`
]
let Winreg
let classesKey
before(function () {
if (process.platform !== 'win32') {
this.skip()
} else {
Winreg = require('winreg')
classesKey = new Winreg({
hive: Winreg.HKCU,
key: '\\Software\\Classes\\'
})
}
})
@@ -534,6 +544,49 @@ describe('app module', () => {
assert.equal(app.isDefaultProtocolClient(protocol, updateExe, processStartArgs), true)
assert.equal(app.isDefaultProtocolClient(protocol), false)
})
it('creates a registry entry for the protocol class', (done) => {
app.setAsDefaultProtocolClient(protocol)
classesKey.keys((error, keys) => {
const exists = !!keys.find((key) => key.key.includes(protocol))
assert.equal(exists, true)
done()
})
})
it('completely removes a registry entry for the protocol class', (done) => {
app.setAsDefaultProtocolClient(protocol)
app.removeAsDefaultProtocolClient(protocol)
classesKey.keys((error, keys) => {
const exists = !!keys.find((key) => key.key.includes(protocol))
assert.equal(exists, false)
done()
})
})
it('only unsets a class registry key if it contains other data', (done) => {
app.setAsDefaultProtocolClient(protocol)
const protocolKey = new Winreg({
hive: Winreg.HKCU,
key: `\\Software\\Classes\\${protocol}`
})
protocolKey.set('test-value', 'REG_BINARY', '123', () => {
app.removeAsDefaultProtocolClient(protocol)
classesKey.keys((error, keys) => {
const exists = !!keys.find((key) => key.key.includes(protocol))
assert.equal(exists, true)
done()
})
})
})
})
describe('getFileIcon() API', () => {
ProTip! Use n and p to navigate between commits in a pull request.