-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8b898d1
Showing
16 changed files
with
639 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- "8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
> **Pair programming exercise** | ||
> | ||
> * Fork and clone repo | ||
> * Write a solution to each exercise and a corresponding test which ensures correctness of solution | ||
> * Try to write the test before writing the solution. This will force you to think closely about the task | ||
> * One person should be writing the test and another the solution. Alternate roles after each exercise | ||
> * For some tests you may have to write several test cases to make sure all edge cases are covered | ||
> * Run `npm test` regularly to ensure your tests pass | ||
> * Commit and push after each solution created | ||
> * Create a pull request after first push | ||
> | ||
> | ||
> * `longestString` - Write a function which receives an array of strings. It should return the longest string from the array | ||
> | ||
> * `l337` Write a function which receives a string. It should replace all instances of letters below with corresponding number and return the resulting string | ||
> 1. `i` or `l` with number 1 | ||
> 2. `z` with the number 2 | ||
> 3. `e` with number 3 | ||
> 4. `a` with number 4 | ||
> 5. `s` with number 5 | ||
> 6. `g` with number 6 | ||
> 7. `t` or `y` with number 7 | ||
> 8. `b` with number 8 | ||
> 9. `q` with number 9 | ||
> 10. `o` with number 0 | ||
> * `uniqueStrings` - Write a function which receives an array of strings. It should return an array of unique strings from the input array | ||
> * `developer` - Write a function a constructor called `Developer` which receives 2 parameters an input string containing name and an array of programming languages the developer knows | ||
> * `inherit` - using prototypal inheritance add a function called learn language, which accepts a new language in string format and adds it to array of programming languages the developer knows. The values in array should be unique | ||
> * `garden` - create a constructor called Garden. It should receive an object as input which contains names of plants as keys and numbers as corresponding quantities as values | ||
> * `extend` - using prototypal inheritance add a method called `plant` which receives an object of plants and corresponding quantities as keys and adds them to current stock | ||
> * `harvest` - using prototypal inheritance add a method called harvest to garden. It should receive and object which contains plant names as keys and quantities to harvest as values. Reduce the quantity of existing plants in garden by the number of plants to be harvested. If number of certain plant falls to 0 or below. Remove key from corresponding object | ||
> * `stringsConcat` - Write a function which receives an array of strings and numbers. The function should concatenate all strings and return the resulting string. | ||
> * `negativeOnly` - Write a function which receives one array of positive and negative numbers. It should return an array containing only the negative numbers | ||
> * `camelise` - Write a function which receive a string of lower case, space separated words. It should convert the string to camel case. That is capitalise the first letter of every word except the first and remove all spaces | ||
> * `merging` - Write a function which receives an array of objects. It should merge them into a single object. The objects with fewest values should take precedence over objects with fewer values. The input objects should remain unaffected, by the merge. For example input `[{a: 5}, {a: 3, b: 21, c:32}]` to `{a:5, b:21, c:32}` | ||
> * `possibleValues` - Write a function which receives an array of objects. Your function should output an object which contains all the keys from input objects. The corresponding value of each key should be an array which contains a list of all values the corresponding key had in all input objects. Values should be unique. For example `[{a: 5}, {a: 3, b: 21, c:32}, {a: 3, c:32}]` to `{a:[5,3], b:[21], c:[32]}` | ||
> * `isPrime` - Write a function which receives an integer an returns `true` if the input is a prime number, `false` otherwise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage generated="1517786417727" clover="3.2.0"> | ||
<project timestamp="1517786417727" name="All files"> | ||
<metrics statements="2" coveredstatements="2" conditionals="0" coveredconditionals="0" methods="1" coveredmethods="1" elements="3" coveredelements="3" complexity="0" loc="2" ncloc="2" packages="1" files="1" classes="1"> | ||
<file name="index.js" path="/Users/dgrabov/workspace/unit-testing/src/index.js"> | ||
<metrics statements="2" coveredstatements="2" conditionals="0" coveredconditionals="0" methods="1" coveredmethods="1"/> | ||
<line num="2" count="1" type="stmt"/> | ||
<line num="5" count="1" type="stmt"/> | ||
</file> | ||
</metrics> | ||
</project> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"/Users/dgrabov/workspace/unit-testing/src/index.js": {"path":"/Users/dgrabov/workspace/unit-testing/src/index.js","statementMap":{"0":{"start":{"line":2,"column":2},"end":{"line":2,"column":15}},"1":{"start":{"line":5,"column":0},"end":{"line":5,"column":18}}},"fnMap":{"0":{"name":"add","decl":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},"loc":{"start":{"line":1,"column":18},"end":{"line":3,"column":1}},"line":1}},"branchMap":{},"s":{"0":1,"1":1},"f":{"0":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"7b4fba1d156e21bbfc9ec59b3463a67efff21e63"} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
body, html { | ||
margin:0; padding: 0; | ||
height: 100%; | ||
} | ||
body { | ||
font-family: Helvetica Neue, Helvetica, Arial; | ||
font-size: 14px; | ||
color:#333; | ||
} | ||
.small { font-size: 12px; } | ||
*, *:after, *:before { | ||
-webkit-box-sizing:border-box; | ||
-moz-box-sizing:border-box; | ||
box-sizing:border-box; | ||
} | ||
h1 { font-size: 20px; margin: 0;} | ||
h2 { font-size: 14px; } | ||
pre { | ||
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; | ||
margin: 0; | ||
padding: 0; | ||
-moz-tab-size: 2; | ||
-o-tab-size: 2; | ||
tab-size: 2; | ||
} | ||
a { color:#0074D9; text-decoration:none; } | ||
a:hover { text-decoration:underline; } | ||
.strong { font-weight: bold; } | ||
.space-top1 { padding: 10px 0 0 0; } | ||
.pad2y { padding: 20px 0; } | ||
.pad1y { padding: 10px 0; } | ||
.pad2x { padding: 0 20px; } | ||
.pad2 { padding: 20px; } | ||
.pad1 { padding: 10px; } | ||
.space-left2 { padding-left:55px; } | ||
.space-right2 { padding-right:20px; } | ||
.center { text-align:center; } | ||
.clearfix { display:block; } | ||
.clearfix:after { | ||
content:''; | ||
display:block; | ||
height:0; | ||
clear:both; | ||
visibility:hidden; | ||
} | ||
.fl { float: left; } | ||
@media only screen and (max-width:640px) { | ||
.col3 { width:100%; max-width:100%; } | ||
.hide-mobile { display:none!important; } | ||
} | ||
|
||
.quiet { | ||
color: #7f7f7f; | ||
color: rgba(0,0,0,0.5); | ||
} | ||
.quiet a { opacity: 0.7; } | ||
|
||
.fraction { | ||
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; | ||
font-size: 10px; | ||
color: #555; | ||
background: #E8E8E8; | ||
padding: 4px 5px; | ||
border-radius: 3px; | ||
vertical-align: middle; | ||
} | ||
|
||
div.path a:link, div.path a:visited { color: #333; } | ||
table.coverage { | ||
border-collapse: collapse; | ||
margin: 10px 0 0 0; | ||
padding: 0; | ||
} | ||
|
||
table.coverage td { | ||
margin: 0; | ||
padding: 0; | ||
vertical-align: top; | ||
} | ||
table.coverage td.line-count { | ||
text-align: right; | ||
padding: 0 5px 0 20px; | ||
} | ||
table.coverage td.line-coverage { | ||
text-align: right; | ||
padding-right: 10px; | ||
min-width:20px; | ||
} | ||
|
||
table.coverage td span.cline-any { | ||
display: inline-block; | ||
padding: 0 5px; | ||
width: 100%; | ||
} | ||
.missing-if-branch { | ||
display: inline-block; | ||
margin-right: 5px; | ||
border-radius: 3px; | ||
position: relative; | ||
padding: 0 4px; | ||
background: #333; | ||
color: yellow; | ||
} | ||
|
||
.skip-if-branch { | ||
display: none; | ||
margin-right: 10px; | ||
position: relative; | ||
padding: 0 4px; | ||
background: #ccc; | ||
color: white; | ||
} | ||
.missing-if-branch .typ, .skip-if-branch .typ { | ||
color: inherit !important; | ||
} | ||
.coverage-summary { | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
.coverage-summary tr { border-bottom: 1px solid #bbb; } | ||
.keyline-all { border: 1px solid #ddd; } | ||
.coverage-summary td, .coverage-summary th { padding: 10px; } | ||
.coverage-summary tbody { border: 1px solid #bbb; } | ||
.coverage-summary td { border-right: 1px solid #bbb; } | ||
.coverage-summary td:last-child { border-right: none; } | ||
.coverage-summary th { | ||
text-align: left; | ||
font-weight: normal; | ||
white-space: nowrap; | ||
} | ||
.coverage-summary th.file { border-right: none !important; } | ||
.coverage-summary th.pct { } | ||
.coverage-summary th.pic, | ||
.coverage-summary th.abs, | ||
.coverage-summary td.pct, | ||
.coverage-summary td.abs { text-align: right; } | ||
.coverage-summary td.file { white-space: nowrap; } | ||
.coverage-summary td.pic { min-width: 120px !important; } | ||
.coverage-summary tfoot td { } | ||
|
||
.coverage-summary .sorter { | ||
height: 10px; | ||
width: 7px; | ||
display: inline-block; | ||
margin-left: 0.5em; | ||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; | ||
} | ||
.coverage-summary .sorted .sorter { | ||
background-position: 0 -20px; | ||
} | ||
.coverage-summary .sorted-desc .sorter { | ||
background-position: 0 -10px; | ||
} | ||
.status-line { height: 10px; } | ||
/* dark red */ | ||
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } | ||
.low .chart { border:1px solid #C21F39 } | ||
/* medium red */ | ||
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } | ||
/* light red */ | ||
.low, .cline-no { background:#FCE1E5 } | ||
/* light green */ | ||
.high, .cline-yes { background:rgb(230,245,208) } | ||
/* medium green */ | ||
.cstat-yes { background:rgb(161,215,106) } | ||
/* dark green */ | ||
.status-line.high, .high .cover-fill { background:rgb(77,146,33) } | ||
.high .chart { border:1px solid rgb(77,146,33) } | ||
|
||
|
||
.medium .chart { border:1px solid #666; } | ||
.medium .cover-fill { background: #666; } | ||
|
||
.cbranch-no { background: yellow !important; color: #111; } | ||
|
||
.cstat-skip { background: #ddd; color: #111; } | ||
.fstat-skip { background: #ddd; color: #111 !important; } | ||
.cbranch-skip { background: #ddd !important; color: #111; } | ||
|
||
span.cline-neutral { background: #eaeaea; } | ||
.medium { background: #eaeaea; } | ||
|
||
.cover-fill, .cover-empty { | ||
display:inline-block; | ||
height: 12px; | ||
} | ||
.chart { | ||
line-height: 0; | ||
} | ||
.cover-empty { | ||
background: white; | ||
} | ||
.cover-full { | ||
border-right: none !important; | ||
} | ||
pre.prettyprint { | ||
border: none !important; | ||
padding: 0 !important; | ||
margin: 0 !important; | ||
} | ||
.com { color: #999 !important; } | ||
.ignore-none { color: #999; font-weight: normal; } | ||
|
||
.wrapper { | ||
min-height: 100%; | ||
height: auto !important; | ||
height: 100%; | ||
margin: 0 auto -48px; | ||
} | ||
.footer, .push { | ||
height: 48px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Code coverage report for All files</title> | ||
<meta charset="utf-8" /> | ||
<link rel="stylesheet" href="prettify.css" /> | ||
<link rel="stylesheet" href="base.css" /> | ||
<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> | ||
All files | ||
</h1> | ||
<div class='clearfix'> | ||
<div class='fl pad1y space-right2'> | ||
<span class="strong">100% </span> | ||
<span class="quiet">Statements</span> | ||
<span class='fraction'>2/2</span> | ||
</div> | ||
<div class='fl pad1y space-right2'> | ||
<span class="strong">100% </span> | ||
<span class="quiet">Branches</span> | ||
<span class='fraction'>0/0</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'>2/2</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class='status-line high'></div> | ||
<div class="pad1"> | ||
<table class="coverage-summary"> | ||
<thead> | ||
<tr> | ||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th> | ||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> | ||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> | ||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> | ||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> | ||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> | ||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> | ||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> | ||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> | ||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</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="2" class="abs high">2/2</td> | ||
<td data-value="100" class="pct high">100%</td> | ||
<td data-value="0" class="abs high">0/0</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="2" class="abs high">2/2</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">istanbul</a> at Sun Feb 04 2018 23:20:17 GMT+0000 (GMT) | ||
</div> | ||
</div> | ||
<script src="prettify.js"></script> | ||
<script> | ||
window.onload = function () { | ||
if (typeof prettyPrint === 'function') { | ||
prettyPrint(); | ||
} | ||
}; | ||
</script> | ||
<script src="sorter.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.