Skip to content

Commit

Permalink
Added tests for watermarks
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalaguti committed Apr 16, 2015
1 parent 4f12c7b commit ccf0c06
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ describe 'reporter', ->
mockCoverageMap =
add: sinon.spy()
get: sinon.spy()
mockDefaultWatermarks =
statements: [50, 80]
branches: [50, 80]
functions: [50, 80]
lines: [50, 80]

mocks =
fs: mockFs
istanbul:
Store: mockStore
Collector: mockCollector
Report: create: mockReportCreate
config: defaultConfig: sinon.stub().returns(reporting: watermarks: mockDefaultWatermarks)
dateformat: require 'dateformat'
'./coverageMap': mockCoverageMap

Expand Down Expand Up @@ -293,3 +299,58 @@ describe 'reporter', ->
browsers.forEach (b) -> reporter.onBrowserStart b

expect(mockCoverageMap.get).not.to.have.been.called

it 'should pass watermarks to istanbul', ->
watermarks =
statements: [10, 20]
branches: [30, 40]
functions: [50, 60]
lines: [70, 80]

customConfig = _.merge {}, rootConfig,
coverageReporter:
reporters: [
{
dir: 'reporter1'
}
]
watermarks: watermarks

mockReportCreate.reset()

reporter = new m.CoverageReporter customConfig, mockHelper, mockLogger
reporter.onRunStart()
browsers.forEach (b) -> reporter.onBrowserStart b
reporter.onRunComplete browsers

expect(mockReportCreate).to.have.been.called
options = mockReportCreate.getCall(0)
expect(options.args[1].watermarks).to.deep.equal(watermarks)

it 'should merge with istanbul default watermarks', ->
watermarks =
statements: [10, 20]
lines: [70, 80]

customConfig = _.merge {}, rootConfig,
coverageReporter:
reporters: [
{
dir: 'reporter1'
}
]
watermarks: watermarks

mockReportCreate.reset()

reporter = new m.CoverageReporter customConfig, mockHelper, mockLogger
reporter.onRunStart()
browsers.forEach (b) -> reporter.onBrowserStart b
reporter.onRunComplete browsers

expect(mockReportCreate).to.have.been.called
options = mockReportCreate.getCall(0)
expect(options.args[1].watermarks.statements).to.deep.equal(watermarks.statements)
expect(options.args[1].watermarks.branches).to.deep.equal(mockDefaultWatermarks.branches)
expect(options.args[1].watermarks.functions).to.deep.equal(mockDefaultWatermarks.functions)
expect(options.args[1].watermarks.lines).to.deep.equal(watermarks.lines)

0 comments on commit ccf0c06

Please sign in to comment.