Browse Source

:construction_worker: Tests, how do they work

Felix Rieseberg 7 years ago
parent
commit
582ef30b4a
2 changed files with 5 additions and 5 deletions
  1. 2 2
      lib/common/api/crash-reporter.js
  2. 3 3
      spec/api-crash-reporter-spec.js

+ 2 - 2
lib/common/api/crash-reporter.js

@@ -66,8 +66,8 @@ class CrashReporter {
   getLastCrashReport () {
     const reports = this.getUploadedReports()
       .sort((a, b) => {
-        const ats = (a && a.timestamp) ? new Date(a.timestamp).getTime() : 0
-        const bts = (b && b.timestamp) ? new Date(b.timestamp).getTime() : 0
+        const ats = (a && a.date) ? new Date(a.date).getTime() : 0
+        const bts = (b && b.date) ? new Date(b.date).getTime() : 0
         return bts - ats
       })
 

+ 3 - 3
spec/api-crash-reporter-spec.js

@@ -263,15 +263,15 @@ describe('crashReporter module', () => {
 
       // Let's find the newest report
       const newestReport = reports.reduce((acc, cur) => {
-        const timestamp = new Date(cur.timestamp).getTime();
+        const timestamp = new Date(cur.date).getTime();
         return (timestamp > acc.timestamp)
           ? { report: cur, timestamp: timestamp }
           : acc
       }, { timestamp: 0 })
 
-      // In our case, the first report is actually the newest
+
       assert(lastReport != null)
-      assert(lastReport === newestReport.report)
+      assert(lastReport.date.toString() === newestReport.report.date.toString())
     })
   })