UNPKG

3.64 kBJavaScriptView Raw
1(function (fs, parser, helper, path) {
2 'use strict';
3
4 var expect = helper.chai.expect;
5 var jacocoData = fs.readFileSync(__dirname + '/mock/jacoco.xml').toString();
6 var noStatsJacocoData = fs.readFileSync(__dirname + '/mock/no-lines.xml').toString();
7 describe('Jacoco Parser', function () {
8
9 it('should be to parse jacoco data', function () {
10 return expect(parser.getParser('jacoco').parse('',jacocoData))
11 .to.eventually.satisfy(function (data) {
12 expect(data).to.deep.equal({
13 total: 23,
14 fileReports: [
15 {
16 filename: path.normalize('com/wmbest/myapplicationtest/MainActivity.java'),
17 coverage: {
18 8: 0,
19 11: 2,
20 12: 1,
21 13: 7,
22 18: 0,
23 19: 0,
24 20: 0,
25 25: 0,
26 26: 0,
27 34: 0,
28 37: 0,
29 38: 0,
30 41: 0
31 },
32 total: 23 }]
33 });
34 return true;
35 });
36 });
37
38 it('should be able to parse jacoco data with path prefix', function () {
39 return expect(parser.getParser('jacoco').parse(path.normalize('my-project' + path.sep), jacocoData))
40 .to.eventually.satisfy(function (data) {
41 expect(data).to.deep.equal({
42 total: 23,
43 fileReports: [
44 {
45 filename: path.normalize('my-project/com/wmbest/myapplicationtest/MainActivity.java'),
46 coverage: {
47 8: 0,
48 11: 2,
49 12: 1,
50 13: 7,
51 18: 0,
52 19: 0,
53 20: 0,
54 25: 0,
55 26: 0,
56 34: 0,
57 37: 0,
58 38: 0,
59 41: 0
60 },
61 total: 23 }]
62 });
63 return true;
64 });
65 });
66
67 it('should be able to parse jacoco data without lines', function() {
68 return expect(parser.getParser('jacoco').parse('', noStatsJacocoData))
69 .to.eventually.satisfy(function (data) {
70 expect(JSON.stringify(data)).to.equal(JSON.stringify({
71 total: 0,
72 fileReports: [
73 {
74 filename: path.normalize('com/wmbest/myapplicationtest/MainActivity.java'),
75 coverage: {},
76 total: 0
77 }]
78 }));
79 return true;
80 });
81 });
82 });
83}(require('fs'), require('../lib/coverageParser'),require('./helper'), require('path')));