Skip to content

Commit

Permalink
refactor: migrate BrowserResult class to ES2015
Browse files Browse the repository at this point in the history
  • Loading branch information
devoto13 committed Mar 15, 2018
1 parent 5809653 commit 33b1078
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
22 changes: 13 additions & 9 deletions lib/browser_result.js
@@ -1,15 +1,19 @@
var Result = function () {
var startTime = Date.now()
'use strict'

this.total = this.skipped = this.failed = this.success = 0
this.netTime = this.totalTime = 0
this.disconnected = this.error = false
class BrowserResult {
constructor () {
this.startTime = Date.now()

this.totalTimeEnd = function () {
this.totalTime = Date.now() - startTime
this.total = this.skipped = this.failed = this.success = 0
this.netTime = this.totalTime = 0
this.disconnected = this.error = false
}

this.add = function (result) {
totalTimeEnd () {
this.totalTime = Date.now() - this.startTime
}

add (result) {
if (result.skipped) {
this.skipped++
} else if (result.success) {
Expand All @@ -22,4 +26,4 @@ var Result = function () {
}
}

module.exports = Result
module.exports = BrowserResult
12 changes: 7 additions & 5 deletions test/unit/browser_result.spec.js
@@ -1,20 +1,22 @@
'use strict'

describe('BrowserResult', () => {
var Result = require('../../lib/browser_result')
var result = null
const Result = require('../../lib/browser_result')
let result = null

var successResultFromBrowser = {
const successResultFromBrowser = {
success: true,
skipped: false,
time: 100
}

var failedResultFromBrowser = {
const failedResultFromBrowser = {
success: false,
skipped: false,
time: 200
}

var skippedResultFromBrowser = {
const skippedResultFromBrowser = {
success: false,
skipped: true,
time: 0
Expand Down

0 comments on commit 33b1078

Please sign in to comment.