add crashReporter parameter tests
This commit is contained in:
		
					parent
					
						
							
								cb78e4875b
							
						
					
				
			
			
				commit
				
					
						cd19d7c705
					
				
			
		
					 1 changed files with 28 additions and 10 deletions
				
			
		| 
						 | 
					@ -11,7 +11,7 @@ const {closeWindow} = require('./window-helpers')
 | 
				
			||||||
const {remote} = require('electron')
 | 
					const {remote} = require('electron')
 | 
				
			||||||
const {app, BrowserWindow, crashReporter} = remote.require('electron')
 | 
					const {app, BrowserWindow, crashReporter} = remote.require('electron')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe.only('crashReporter module', () => {
 | 
					describe('crashReporter module', () => {
 | 
				
			||||||
  if (process.mas || process.env.DISABLE_CRASH_REPORTER_TESTS) return
 | 
					  if (process.mas || process.env.DISABLE_CRASH_REPORTER_TESTS) return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let originalTempDirectory = null
 | 
					  let originalTempDirectory = null
 | 
				
			||||||
| 
						 | 
					@ -197,11 +197,10 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // complete
 | 
					 | 
				
			||||||
  describe('getProductName', () => {
 | 
					  describe('getProductName', () => {
 | 
				
			||||||
    it('returns the product name if one is specified', () => {
 | 
					    it('returns the product name if one is specified', () => {
 | 
				
			||||||
      const name = crashReporter.getProductName()
 | 
					      const name = crashReporter.getProductName()
 | 
				
			||||||
      if(process.platform === 'win32') {
 | 
					      if (process.platform === 'win32') {
 | 
				
			||||||
        assert.equal(name, 'Zombies')
 | 
					        assert.equal(name, 'Zombies')
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        assert.equal(name, 'Electron Test')
 | 
					        assert.equal(name, 'Electron Test')
 | 
				
			||||||
| 
						 | 
					@ -240,7 +239,6 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // complete
 | 
					 | 
				
			||||||
  describe('getCrashesDirectory', () => {
 | 
					  describe('getCrashesDirectory', () => {
 | 
				
			||||||
    it('correctly returns the directory', () => {
 | 
					    it('correctly returns the directory', () => {
 | 
				
			||||||
      const crashesDir = crashReporter.getCrashesDirectory()
 | 
					      const crashesDir = crashReporter.getCrashesDirectory()
 | 
				
			||||||
| 
						 | 
					@ -254,7 +252,6 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // complete
 | 
					 | 
				
			||||||
  describe('getUploadedReports', () => {
 | 
					  describe('getUploadedReports', () => {
 | 
				
			||||||
    it('returns an array of reports', () => {
 | 
					    it('returns an array of reports', () => {
 | 
				
			||||||
      const reports = crashReporter.getUploadedReports()
 | 
					      const reports = crashReporter.getUploadedReports()
 | 
				
			||||||
| 
						 | 
					@ -262,7 +259,6 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // complete
 | 
					 | 
				
			||||||
  describe('getLastCrashReport', () => {
 | 
					  describe('getLastCrashReport', () => {
 | 
				
			||||||
    it('correctly returns the most recent report', () => {
 | 
					    it('correctly returns the most recent report', () => {
 | 
				
			||||||
      const reports = crashReporter.getUploadedReports()
 | 
					      const reports = crashReporter.getUploadedReports()
 | 
				
			||||||
| 
						 | 
					@ -271,7 +267,6 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // complete
 | 
					 | 
				
			||||||
  describe('getUploadToServer()', () => {
 | 
					  describe('getUploadToServer()', () => {
 | 
				
			||||||
    it('throws an error when called from the renderer process', () => {
 | 
					    it('throws an error when called from the renderer process', () => {
 | 
				
			||||||
      assert.throws(() => require('electron').crashReporter.getUploadToServer())
 | 
					      assert.throws(() => require('electron').crashReporter.getUploadToServer())
 | 
				
			||||||
| 
						 | 
					@ -298,7 +293,6 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // complete
 | 
					 | 
				
			||||||
  describe('setUploadToServer(uploadToServer)', () => {
 | 
					  describe('setUploadToServer(uploadToServer)', () => {
 | 
				
			||||||
    it('throws an error when called from the renderer process', () => {
 | 
					    it('throws an error when called from the renderer process', () => {
 | 
				
			||||||
      assert.throws(() => require('electron').crashReporter.setUploadToServer('arg'))
 | 
					      assert.throws(() => require('electron').crashReporter.setUploadToServer('arg'))
 | 
				
			||||||
| 
						 | 
					@ -327,8 +321,32 @@ describe.only('crashReporter module', () => {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe('setExtraParameter', () => {
 | 
					  describe('Parameters', () => {
 | 
				
			||||||
    //
 | 
					    it('returns all of the current parameters', () => {
 | 
				
			||||||
 | 
					      const parameters = crashReporter.getParameters()
 | 
				
			||||||
 | 
					      assert(typeof parameters === Object)
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					    it('adds a parameter', () => {
 | 
				
			||||||
 | 
					      // only run on MacOS
 | 
				
			||||||
 | 
					      if (process.platform !== 'darwin') return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      crashReporter.addParameter('hello', 'world')
 | 
				
			||||||
 | 
					      const updatedParams = crashReporter.getParameters()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      assert(updatedParams.includes('hello'))
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					    it('removes a parameter', () => {
 | 
				
			||||||
 | 
					      // only run on MacOS
 | 
				
			||||||
 | 
					      if (process.platform !== 'darwin') return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      crashReporter.addParameter('hello', 'world')
 | 
				
			||||||
 | 
					      const originalParams = crashReporter.getParameters()
 | 
				
			||||||
 | 
					      assert(originalParams.includes('hello'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      crashReporter.removeExtraParameter('hello')
 | 
				
			||||||
 | 
					      const updatedParams = crashReporter.getParameters()
 | 
				
			||||||
 | 
					      assert(!updatedParams.includes('hello'))
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue