UNPKG

4.6 kBJavaScriptView Raw
1(function (fs, parser, helper, path) {
2 'use strict';
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 48: 3,
24 50: 3,
25 52: 3,
26 54: 3,
27 55: 3,
28 61: 3,
29 63: 3,
30 67: 3,
31 73: 2,
32 74: 1,
33 75: 1,
34 76: 1,
35 77: 1,
36 79: 2,
37 81: 1,
38 82: 1,
39 83: 1,
40 84: 1,
41 87: 3
42 },
43 total: 92
44 }
45 ]
46 });
47 return true;
48 });
49 });
50 it('should be able to parse lcov data with path prefix', function () {
51 return expect(parser.getParser('lcov').parse(path.normalize('my-project' + path.sep), lcovData))
52 .to.eventually.satisfy(function (data) {
53 expect(data).to.deep.equal({
54 total: 92,
55 fileReports: [
56 {
57 filename: path.normalize('my-project/lib/reporter.js'),
58 coverage: {
59 1: 1,
60 25: 1,
61 39: 1,
62 40: 3,
63 44: 3,
64 48: 3,
65 50: 3,
66 52: 3,
67 54: 3,
68 55: 3,
69 61: 3,
70 63: 3,
71 67: 3,
72 73: 2,
73 74: 1,
74 75: 1,
75 76: 1,
76 77: 1,
77 79: 2,
78 81: 1,
79 82: 1,
80 83: 1,
81 84: 1,
82 87: 3
83 },
84 total: 92
85 }
86 ]
87 });
88 return true;
89 });
90 });
91 it('should be able to parse lcov data without lines', function () {
92 return expect(parser.getParser('lcov').parse('', noStatsLcovData))
93 .to.eventually.satisfy(function (data) {
94 expect(JSON.stringify(data)).to.equal(JSON.stringify({
95 total: 0,
96 fileReports: [
97 {
98 filename: path.normalize('lib/reporter.js'),
99 coverage: {},
100 total: 0
101 }
102 ]
103 }));
104 return true;
105 });
106 });
107 });
108}(require('fs'), require('../lib/coverageParser'), require('./helper'), require('path')));