-
Notifications
You must be signed in to change notification settings - Fork 280
/
x-unit-reporter-test.coffee
42 lines (32 loc) · 1.19 KB
/
x-unit-reporter-test.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{assert} = require 'chai'
sinon = require 'sinon'
proxyquire = require('proxyquire').noCallThru()
cliStub = require 'cli'
fsStub = require 'fs'
XUnitReporter = proxyquire '../../src/x-unit-reporter', {
'cli' : cliStub,
'fs' : fsStub
}
describe 'XUnitReporter', () ->
test = {}
describe 'when creating report', () ->
beforeEach () ->
sinon.spy fsStub, 'appendFileSync'
afterEach () ->
fsStub.appendFileSync.restore()
describe 'when there is one test', () ->
it 'should write tests to file', (done) ->
xUnitReporter = new XUnitReporter()
xUnitReporter.addTest { status: 'fail', title: 'Failing Test' }, () ->
xUnitReporter.addTest { status: 'pass', title: 'Passing Test' }, () ->
xUnitReporter.createReport () ->
assert.ok fsStub.appendFileSync.called
fsStub.unlinkSync(xUnitReporter.path)
done()
describe 'when there are no tests', () ->
it 'should write empty suite', (done) ->
xUnitReporter = new XUnitReporter()
xUnitReporter.createReport () ->
assert.ok fsStub.appendFileSync.calledTwice
fsStub.unlinkSync(xUnitReporter.path)
done()