👷 Test registry interaction
This commit is contained in:
		
					parent
					
						
							
								60634cac42
							
						
					
				
			
			
				commit
				
					
						e77751aab5
					
				
			
		
					 1 changed files with 53 additions and 0 deletions
				
			
		|  | @ -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', () => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Felix Rieseberg
				Felix Rieseberg