Skip to content

Commit

Permalink
fix: nested summarizer error with no files (#230)
Browse files Browse the repository at this point in the history
* Fix issue where error was thrown when there were no files and using nested summarizer

* Add unit test to catch issue

* Fix linting error

* Rename unit test
  • Loading branch information
chinchiheather authored and JaKXz committed Dec 28, 2018
1 parent b2c1e8c commit 07724bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/istanbul-lib-report/lib/summarizer.js
Expand Up @@ -232,7 +232,7 @@ function createNestedSummary(coverageMap) {
root;

if (topNodes.length === 0) {
return treeFor(new ReportNode([]));
return treeFor(new ReportNode(new Path([])));
}

if (topNodes.length === 1) {
Expand Down
8 changes: 8 additions & 0 deletions packages/istanbul-lib-report/test/summarizer.test.js
Expand Up @@ -321,6 +321,14 @@ describe('summarizer', function() {
assert.deepEqual(nodes, ['g:']);
});

it('handles getting root node name without crashing when empty coverage map', function() {
var map = coverage.createCoverageMap({}),
tree = fn(map),
root = tree.getRoot(),
rootNodeName = root.getRelativeName();
assert.equal(rootNodeName, '');
});

it('supports a list of files at top-level', function() {
var map = singleDirMap(),
tree = fn(map),
Expand Down

0 comments on commit 07724bf

Please sign in to comment.