From 43f176e0c7661386b314d0866cb0a98264c80c7b Mon Sep 17 00:00:00 2001 From: Derrick Date: Tue, 26 May 2020 12:48:30 -0400 Subject: [PATCH] Fix line hit values of `undefined`. --- lib/transforms.js | 2 +- test/transforms-spec.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/transforms.js b/lib/transforms.js index 48ca2e3..f09622f 100644 --- a/lib/transforms.js +++ b/lib/transforms.js @@ -66,7 +66,7 @@ const transformJsonCoverage = coverage => { stats: [ { name: 'Hits', - value: lines[lineNumber] + value: method.Lines[lineNumber] } ] } diff --git a/test/transforms-spec.js b/test/transforms-spec.js index d7c94be..b7a04aa 100644 --- a/test/transforms-spec.js +++ b/test/transforms-spec.js @@ -49,7 +49,16 @@ describe('transforms', () => { const methods = Object.keys(classObj) const method = classObj[methods[1]] const lines = Object.keys(method.Lines) + const transformed = transforms.getLines(method) + assert.equal(transformed.length, lines.length) + + transformed.forEach((transformedLine, i) => { + const lineNumber = transformedLine.line; + const transformedHitCount = transformedLine.stats.find(s => s.name === 'Hits').value; + const originalHitCount = method.Lines[lineNumber]; + assert.equal(transformedHitCount, originalHitCount) + }); }) })