UNPKG

3.03 kBJavaScriptView Raw
1(function (exec, Joi, parser, helper) {
2 'use strict';
3
4 var expect = helper.chai.expect;
5
6 describe('Command Line', function () {
7 it('should be able to parse lcov data', function (done) {
8 var bodyObject = {
9 total: 92,
10 fileReports: [
11 {
12 filename: '/Users/david.pate/Git/codacy-coverage/lib/reporter.js',
13 coverage: {
14 1: 1,
15 25: 1,
16 39: 1,
17 40: 3,
18 44: 3,
19 45: 0,
20 48: 3,
21 50: 3,
22 52: 3,
23 54: 3,
24 55: 3,
25 61: 3,
26 63: 3,
27 64: 0,
28 67: 3,
29 73: 2,
30 74: 1,
31 75: 1,
32 76: 1,
33 77: 1,
34 79: 2,
35 81: 1,
36 82: 1,
37 83: 1,
38 84: 1,
39 87: 3
40 },
41 total: 92
42 }
43 ]
44 };
45
46 helper.setupMockEndpoint('1234', '4321', Joi.compile(bodyObject)).then(function () {
47 exec('cat ./test/mock/lcov.info | node ./bin/codacy-coverage.js --token 1234 --commit 4321', function (err, res) {
48 if (err) {
49 return done(err);
50 }
51
52 expect(res).to.match(/Status Code \[404\] - Error \[{"error":"not found"}\]/);
53 //nock.done(); //TODO: Need to figure out how to use nock here. Since it's a separate process, it's not tied together.
54 done();
55 });
56 });
57 });
58 it('should be able to set options', function (done) {
59 exec('cat ./test/mock/no-lines.info | node ./bin/codacy-coverage.js --debug --verbose --token 1234 --commit 4321 --prefix asdf/ --endpoint something --format lcov', function (err, res) {
60 if (err) {
61 return done(err);
62 }
63
64 expect(res).to.match(/Started with: token \["1234"], commitId \["4321"], language \[undefined], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
65 expect(res).to.match(/Handling input for: token \["1234"], commitId \["4321"], language \[undefined], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
66 done();
67 });
68 });
69 });
70}(require('child_process').exec, require('joi'), require('../'), require('./helper')));