Skip to content

Commit

Permalink
code coverage with unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Anisul Mahmud committed Dec 3, 2023
1 parent 8930c9c commit 14513d9
Show file tree
Hide file tree
Showing 23 changed files with 312 additions and 278 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ jobs:
run: npm ci

- name: Run tests
run: npm test
run: npm test

- name: Generate Code Coverage
run: npm run coverage # Assuming you have a script for running tests with coverage

- name: Upload Code Coverage Results
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage # Adjust the path based on your coverage report directory
File renamed without changes.
File renamed without changes.
106 changes: 106 additions & 0 deletions coverage/convertToReadableTime.ts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

<!doctype html>
<html lang="en">

<head>
<title>Code coverage report for convertToReadableTime.ts</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>

<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> convertToReadableTime.ts</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>7/7</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>1/1</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>1/1</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>7/7</span>
</div>


</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
<template id="filterTemplate">
<div class="quiet">
Filter:
<input oninput="onInput()" type="search" id="fileSearch">
</div>
</template>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">export const convertToReadableTime = (time: string | Date) =&gt; {
const startTime = new Date(time)
const startTimeHours = String(startTime.getUTCHours()).padStart(2, '0')
const startTimeMinutes = String(startTime.getUTCMinutes()).padStart(2, '0')
const startTimeFormatted = `${startTimeHours}:${startTimeMinutes}`
return startTimeFormatted
}
&nbsp;</pre></td></tr></table></pre>

<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-12-03T21:54:13.612Z
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

2 changes: 2 additions & 0 deletions coverage/coverage-final.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"F:\\Tampere\\code_coverage\\TurnUp\\src\\utils\\convertToReadableTime.ts": {"path":"F:\\Tampere\\code_coverage\\TurnUp\\src\\utils\\convertToReadableTime.ts","all":false,"statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":63}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":34}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":73}},"3":{"start":{"line":4,"column":0},"end":{"line":4,"column":77}},"4":{"start":{"line":5,"column":0},"end":{"line":5,"column":68}},"5":{"start":{"line":6,"column":0},"end":{"line":6,"column":27}},"6":{"start":{"line":7,"column":0},"end":{"line":7,"column":1}}},"s":{"0":1,"1":6,"2":6,"3":6,"4":6,"5":6,"6":6},"branchMap":{"0":{"type":"branch","line":1,"loc":{"start":{"line":1,"column":37},"end":{"line":7,"column":1}},"locations":[{"start":{"line":1,"column":37},"end":{"line":7,"column":1}}]}},"b":{"0":[6]},"fnMap":{"0":{"name":"convertToReadableTime","decl":{"start":{"line":1,"column":37},"end":{"line":7,"column":1}},"loc":{"start":{"line":1,"column":37},"end":{"line":7,"column":1}},"line":1}},"f":{"0":6}}
}
File renamed without changes
37 changes: 26 additions & 11 deletions coverage/lcov-report/index.html → coverage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@ <h1>All files</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">Unknown% </span>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>0/0</span>
<span class='fraction'>7/7</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">Unknown% </span>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
<span class='fraction'>1/1</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">Unknown% </span>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>0/0</span>
<span class='fraction'>1/1</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">Unknown% </span>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>0/0</span>
<span class='fraction'>7/7</span>
</div>


Expand All @@ -61,7 +61,7 @@ <h1>All files</h1>
</div>
</template>
</div>
<div class='status-line medium'></div>
<div class='status-line high'></div>
<div class="pad1">
<table class="coverage-summary">
<thead>
Expand All @@ -78,15 +78,30 @@ <h1>All files</h1>
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
</tr>
</thead>
<tbody></tbody>
<tbody><tr>
<td class="file high" data-value="convertToReadableTime.ts"><a href="convertToReadableTime.ts.html">convertToReadableTime.ts</a></td>
<td data-value="100" class="pic high">
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="7" class="abs high">7/7</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="1" class="abs high">1/1</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="1" class="abs high">1/1</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="7" class="abs high">7/7</td>
</tr>

</tbody>
</table>
</div>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-11-25T03:16:18.410Z
at 2023-12-03T21:54:13.612Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
Loading

0 comments on commit 14513d9

Please sign in to comment.