зеркало из https://github.com/electron/electron.git
spec: better texts for the Crash Reporter tests (#13227)
* Better failure messages for a Crash Reporter test * Add a TODO
This commit is contained in:
Родитель
dee9aef975
Коммит
6a59b37bea
|
@ -1,5 +1,6 @@
|
|||
const assert = require('assert')
|
||||
const childProcess = require('child_process')
|
||||
const {expect} = require('chai')
|
||||
const fs = require('fs')
|
||||
const http = require('http')
|
||||
const multiparty = require('multiparty')
|
||||
|
@ -256,23 +257,31 @@ describe('crashReporter module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
// TODO(alexeykuzmin): This suite should explicitly
|
||||
// generate several crash reports instead of hoping
|
||||
// that there will be enough of them already.
|
||||
describe('getLastCrashReport', () => {
|
||||
it('correctly returns the most recent report', () => {
|
||||
const reports = crashReporter.getUploadedReports()
|
||||
const lastReport = crashReporter.getLastCrashReport()
|
||||
expect(reports).to.be.an('array')
|
||||
expect(reports).to.have.lengthOf.at.least(2,
|
||||
'There are not enough reports for this test')
|
||||
|
||||
// Let's find the newest report
|
||||
const newestReport = reports.reduce((acc, cur) => {
|
||||
const lastReport = crashReporter.getLastCrashReport()
|
||||
expect(lastReport).to.be.an('object').that.includes.a.key('date')
|
||||
|
||||
// Let's find the newest report.
|
||||
const {report: newestReport} = reports.reduce((acc, cur) => {
|
||||
const timestamp = new Date(cur.date).getTime()
|
||||
return (timestamp > acc.timestamp)
|
||||
? { report: cur, timestamp: timestamp }
|
||||
: acc
|
||||
}, { timestamp: 0 })
|
||||
}, { timestamp: -Infinity })
|
||||
assert(newestReport, 'Hey!')
|
||||
|
||||
assert(reports.length > 1, 'has more than 1 report')
|
||||
assert(lastReport != null, 'found a last report')
|
||||
assert(lastReport.date.toString() === newestReport.report.date.toString(),
|
||||
'last report is correct')
|
||||
expect(lastReport.date.getTime()).to.be.equal(
|
||||
newestReport.date.getTime(),
|
||||
'Last report is not the newest.')
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче