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
|
var should = require('should');
var sinon = require('sinon-restore');
var index = require('../index');
var fs = require('fs');
logger = require('log-driver')({level : false});
describe("handleInput", function(){
afterEach(function() {
sinon.restoreAll();
});
it ("throws an error when there's an error sending", function(done){
sinon.stub(index, 'getOptions', function(cb){
return cb(null, {});
});
sinon.stub(index, 'sendToCoveralls', function(postData, cb){
try {
cb("some error");
should.fail("expected exception was not raised");
} catch (ex) {
done();
}
});
var path = __dirname + "/../fixtures/onefile.lcov";
var input = fs.readFileSync(path, "utf8");
index.handleInput(input);
});
it ("throws an error when there's a bad status code", function(done){
sinon.stub(index, 'getOptions', function(cb){
return cb(null, {});
});
sinon.stub(index, 'sendToCoveralls', function(postData, cb){
try {
cb(null, {statusCode : 500}, "body");
should.fail("expected exception was not raised");
} catch (ex) {
done();
}
});
var path = __dirname + "/../fixtures/onefile.lcov";
var input = fs.readFileSync(path, "utf8");
index.handleInput(input);
});
it ("completes successfully when there are now errors", function(done){
sinon.stub(index, 'getOptions', function(cb){
return cb(null, {});
});
sinon.stub(index, 'sendToCoveralls', function(postData, cb){
cb(null, {statusCode : 200}, "body");
done();
});
var path = __dirname + "/../fixtures/onefile.lcov";
var input = fs.readFileSync(path, "utf8");
index.handleInput(input);
});
});
|