Skip to content

Commit

Permalink
fix(in-memory-reporter): Fix bug in new InMemoryReport, now using nul…
Browse files Browse the repository at this point in the history
…l-checks
  • Loading branch information
nicojs committed Mar 7, 2016
1 parent fbca762 commit 051cffd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/in-memory-report.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
var Report = require('istanbul').Report
var util = require('util')

function InMemoryReport (opt) {
this.browser = opt.browser
this.emitter = opt.emitter
this.opt = opt
}

util.inherits(InMemoryReport, Report)

InMemoryReport.prototype.writeReport = function (collector, sync) {
this.emitter.emit('coverage_complete', this.browser, collector.getFinalCoverage())
if (!this.opt.emitter || !this.opt.emitter.emit) {
console.error('Could not raise "coverage_complete" event, missing emitter because it was not supplied during initialization of the reporter')
} else {
this.opt.emitter.emit('coverage_complete', this.opt.browser, collector.getFinalCoverage())
}
}

InMemoryReport.TYPE = 'in-memory'
Expand Down
7 changes: 7 additions & 0 deletions test/in-memory-report.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
InMemoryReport = require '../lib/in-memory-report'
istanbul = require 'istanbul';

describe 'InMemoryReport', ->

Expand All @@ -17,3 +18,9 @@ describe 'InMemoryReport', ->

it 'should be of type "in-memory"', ->
expect(InMemoryReport.TYPE).to.be.equal('in-memory')

it 'should not fail when created without arguments', ->
expect(new InMemoryReport()).to.be.ok

it 'should inherit from Report', ->
expect(new InMemoryReport()).to.be.an.instanceof(istanbul.Report)

0 comments on commit 051cffd

Please sign in to comment.