Skip to content

Commit

Permalink
test: fix the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Nov 29, 2013
1 parent c9ef5c9 commit 9b78280
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe 'reporter', ->
isDefined: (v) -> helper.isDefined v
merge: (v...) -> helper.merge v...
mkdirIfNotExists: mockMkdir
normalizeWinPath: (path) -> helper.normalizeWinPath path

mocks =
fs: mockFs
Expand Down Expand Up @@ -108,9 +109,10 @@ describe 'reporter', ->

beforeEach ->
rootConfig =
basePath: '/base'
coverageReporter: dir: 'path/to/coverage/'
emitter = new events.EventEmitter
reporter = new m.CoverageReporter rootConfig, emitter, mockHelper, mockLogger
reporter = new m.CoverageReporter rootConfig, mockHelper, mockLogger
browsers = new Collection emitter
# fake user agent only for testing
# cf. helper.browserFullNameToShort
Expand All @@ -124,7 +126,7 @@ describe 'reporter', ->

it 'has no pending file writings', ->
done = sinon.spy()
emitter.emit 'exit', done
reporter.onExit done
expect(done).to.have.been.called

it 'has no coverage', ->
Expand All @@ -146,7 +148,7 @@ describe 'reporter', ->
expect(mockAdd).to.have.been.calledWith result.coverage
expect(mockMkdir).to.have.been.called
args = mockMkdir.lastCall.args
expect(args[0]).to.deep.equal path.resolve(rootConfig.coverageReporter.dir)
expect(args[0]).to.deep.equal path.resolve('/base', rootConfig.coverageReporter.dir)
args[1]()
expect(mockFs.writeFile).to.have.been.calledWith
args2 = mockFs.writeFile.lastCall.args
Expand All @@ -156,8 +158,8 @@ describe 'reporter', ->
reporter.onRunComplete browsers
expect(mockMkdir).to.have.been.calledTwice
dir = rootConfig.coverageReporter.dir
expect(mockMkdir.getCall(0).args[0]).to.deep.equal path.resolve(dir, fakeChrome.name)
expect(mockMkdir.getCall(1).args[0]).to.deep.equal path.resolve(dir, fakeOpera.name)
expect(mockMkdir.getCall(0).args[0]).to.deep.equal path.resolve('/base', dir, fakeChrome.name)
expect(mockMkdir.getCall(1).args[0]).to.deep.equal path.resolve('/base', dir, fakeOpera.name)
mockMkdir.getCall(0).args[1]()
expect(mockReportCreate).to.have.been.called
expect(mockWriteReport).to.have.been.called

0 comments on commit 9b78280

Please sign in to comment.