1 | (function (util, parser, helper) {
|
2 | 'use strict';
|
3 |
|
4 | var expect = helper.chai.expect;
|
5 | var validFormats = ['lcov','jacoco'];
|
6 | var errorMsg = new Map([
|
7 | {lcov: 'Failed to parse string'},
|
8 | {jacoco: 'Failed to parse jacoco report: Error: Non-whitespace before first tag'}
|
9 | ])
|
10 | describe('Coverage Parser', function () {
|
11 | it('should receive an error when trying to use an unsupported format', function () {
|
12 | expect(function () {
|
13 | parser.getParser('invalid-format');
|
14 | }).to.throw(Error, util.format('Expected one of the following supported formats: %j, but got [%s]', validFormats, 'invalid-format'));
|
15 | });
|
16 |
|
17 | validFormats.forEach(function (format) {
|
18 | it('should be able to instantiate the parser for ' + format, function () {
|
19 | expect(function () {
|
20 | parser.getParser(format);
|
21 | }).to.not.throw();
|
22 | });
|
23 | it('shouldn\'t be able to parse a blank coverage file for ' + format, function () {
|
24 | return expect(parser.getParser(format).parse('')).to.eventually.be.rejectedWith(Error, '"value" is required');
|
25 | });
|
26 | it('shouldn\'t be able to parse invalid coverage for ' + format, function () {
|
27 | return expect(parser.getParser(format).parse('', 'There is no Dana, only Zuul')).to.eventually.be.rejectedWith(Error, errorMsg.get(format));
|
28 | });
|
29 | it('shouldn\'t be able to parse a non-existent coverage file for ' + format, function () {
|
30 | return expect(parser.getParser(format).parse('', '/no-exist/lcov')).to.eventually.be.rejectedWith(Error, errorMsg.get(format));
|
31 | });
|
32 | });
|
33 | });
|
34 | }(require('util'), require('../lib/coverageParser'), require('./helper')));
|