1 | (function (fs, parser, helper, path) {
|
2 | ;
|
3 |
|
4 | var expect = helper.chai.expect;
|
5 | var lcovData = fs.readFileSync(__dirname + '/mock/lcov.info').toString();
|
6 | var noStatsLcovData = fs.readFileSync(__dirname + '/mock/no-lines.info').toString();
|
7 |
|
8 | describe('Lcov Parser', function () {
|
9 | it('should be able to parse lcov data', function () {
|
10 | return expect(parser.getParser('lcov').parse('', lcovData))
|
11 | .to.eventually.satisfy(function (data) {
|
12 | expect(data).to.deep.equal({
|
13 | total: 92,
|
14 | fileReports: [
|
15 | {
|
16 | filename: path.normalize('lib/reporter.js'),
|
17 | coverage: {
|
18 | 1: 1,
|
19 | 25: 1,
|
20 | 39: 1,
|
21 | 40: 3,
|
22 | 44: 3,
|
23 | 45: 0,
|
24 | 48: 3,
|
25 | 50: 3,
|
26 | 52: 3,
|
27 | 54: 3,
|
28 | 55: 3,
|
29 | 61: 3,
|
30 | 63: 3,
|
31 | 64: 0,
|
32 | 67: 3,
|
33 | 73: 2,
|
34 | 74: 1,
|
35 | 75: 1,
|
36 | 76: 1,
|
37 | 77: 1,
|
38 | 79: 2,
|
39 | 81: 1,
|
40 | 82: 1,
|
41 | 83: 1,
|
42 | 84: 1,
|
43 | 87: 3
|
44 | },
|
45 | total: 92
|
46 | }
|
47 | ]
|
48 | });
|
49 | return true;
|
50 | });
|
51 | });
|
52 | it('should be able to parse lcov data with path prefix', function () {
|
53 | return expect(parser.getParser('lcov').parse(path.normalize('my-project' + path.sep), lcovData))
|
54 | .to.eventually.satisfy(function (data) {
|
55 | expect(data).to.deep.equal({
|
56 | total: 92,
|
57 | fileReports: [
|
58 | {
|
59 | filename: path.normalize('my-project/lib/reporter.js'),
|
60 | coverage: {
|
61 | 1: 1,
|
62 | 25: 1,
|
63 | 39: 1,
|
64 | 40: 3,
|
65 | 44: 3,
|
66 | 45: 0,
|
67 | 48: 3,
|
68 | 50: 3,
|
69 | 52: 3,
|
70 | 54: 3,
|
71 | 55: 3,
|
72 | 61: 3,
|
73 | 63: 3,
|
74 | 64: 0,
|
75 | 67: 3,
|
76 | 73: 2,
|
77 | 74: 1,
|
78 | 75: 1,
|
79 | 76: 1,
|
80 | 77: 1,
|
81 | 79: 2,
|
82 | 81: 1,
|
83 | 82: 1,
|
84 | 83: 1,
|
85 | 84: 1,
|
86 | 87: 3
|
87 | },
|
88 | total: 92
|
89 | }
|
90 | ]
|
91 | });
|
92 | return true;
|
93 | });
|
94 | });
|
95 | it('should be able to parse lcov data without lines', function () {
|
96 | return expect(parser.getParser('lcov').parse('', noStatsLcovData))
|
97 | .to.eventually.satisfy(function (data) {
|
98 | expect(JSON.stringify(data)).to.equal(JSON.stringify({
|
99 | total: 0,
|
100 | fileReports: [
|
101 | {
|
102 | filename: path.normalize('lib/reporter.js'),
|
103 | coverage: {},
|
104 | total: 0
|
105 | }
|
106 | ]
|
107 | }));
|
108 | return true;
|
109 | });
|
110 | });
|
111 | });
|
112 | }(require('fs'), require('../lib/coverageParser'), require('./helper'), require('path')));
|