-
Notifications
You must be signed in to change notification settings - Fork 280
/
cli-reporter-test.coffee
81 lines (55 loc) · 1.79 KB
/
cli-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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{assert} = require 'chai'
sinon = require 'sinon'
proxyquire = require('proxyquire').noCallThru()
loggerStub = require '../../src/logger'
CliReporter = proxyquire '../../src/cli-reporter', {
'winston' : loggerStub
}
describe 'CliReporter', () ->
test = {}
describe 'when adding passing test', () ->
before () ->
test =
status: 'pass'
title: 'Passing Test'
beforeEach () ->
sinon.spy loggerStub, 'pass'
afterEach () ->
loggerStub.pass.restore()
it 'should write pass to the console', (done) ->
cliReporter = new CliReporter()
cliReporter.addTest test, () ->
assert.ok loggerStub.pass.calledOnce
done()
describe 'when adding failing test', () ->
before () ->
test =
status: 'fail'
title: 'Failing Test'
beforeEach () ->
sinon.spy loggerStub, 'fail'
afterEach () ->
loggerStub.fail.restore()
it 'should write fail to the console', (done) ->
cliReporter = new CliReporter()
cliReporter.addTest test, ()->
assert.ok loggerStub.fail.called
done()
describe 'when creating report', () ->
beforeEach () ->
sinon.spy loggerStub, 'complete'
afterEach () ->
loggerStub.complete.restore()
describe 'when there is at least one test', () ->
it 'should write to the console', (done) ->
cliReporter = new CliReporter()
cliReporter.addTest test, () ->
cliReporter.createReport () ->
assert.ok loggerStub.complete.calledOnce
done()
describe 'when there are no tests', () ->
it 'should write to the console', (done) ->
cliReporter = new CliReporter()
cliReporter.createReport () ->
assert.notOk loggerStub.complete.calledOnce
done()