ft-webplatform/coverage/lib/test-utils.js.html
Martin Donnelly 76920442b1 init
2017-09-28 13:04:16 +01:00

312 lines
10 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for lib/test-utils.js</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>
<a href="..\index.html">All files</a> / <a href="index.html">lib</a> test-utils.js
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">19.05% </span>
<span class="quiet">Statements</span>
<span class='fraction'>4/21</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">66.67% </span>
<span class="quiet">Branches</span>
<span class='fraction'>4/6</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">13.33% </span>
<span class="quiet">Functions</span>
<span class='fraction'>2/15</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">22.22% </span>
<span class="quiet">Lines</span>
<span class='fraction'>4/18</span>
</div>
</div>
</div>
<div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">24x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">23x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">22x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import {DOM} from 'aurelia-pal';
import {ajax} from 'jquery';
&nbsp;
/**
* @param {HTMLElement} element
* @param {string} value
* @returns {Promise}
*/
export function <span class="fstat-no" title="function not covered" >simulateInputChange(</span>element, value) {
<span class="cstat-no" title="statement not covered" > element.value = value;</span>
<span class="cstat-no" title="statement not covered" > element.dispatchEvent(DOM.createCustomEvent('change', { bubbles: true }));</span>
<span class="cstat-no" title="statement not covered" > return new Promise(setTimeout);</span>
}
&nbsp;
/**
* @param {number} delay
* @returns {function(): Promise}
*/
export function <span class="fstat-no" title="function not covered" >wait(</span>delay = <span class="branch-0 cbranch-no" title="branch not covered" >0)</span> {
<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >()</span> =&gt; <span class="cstat-no" title="statement not covered" >new Promise(<span class="fstat-no" title="function not covered" >re</span>solve =&gt; {</span></span>
<span class="cstat-no" title="statement not covered" > setTimeout(resolve, delay);</span>
});
}
&nbsp;
/**
* synchronously load JSON fixture file
* @parameter {string} filename eg /components/products/pricing-distribution/ft-pricing-distribution/lib/gw/mock-new-state-out.fixture.json
* @returns {Object}
*/
export function <span class="fstat-no" title="function not covered" >getJSONFixture(</span>filename) {
let result = <span class="cstat-no" title="statement not covered" >ajax({</span>
url: '/base/src' + filename,
async: false
});
<span class="cstat-no" title="statement not covered" > return result.responseJSON;</span>
}
&nbsp;
/**
* return a object which when evaluated eg a.b.c.d will always be able to go deeper
* @returns {Object}
*/
export function getEndlessObject() {
return new Proxy({}, {
get: (target, name) =&gt; {
if (name === 'push' || name === 'slice') {
return <span class="fstat-no" title="function not covered" >()</span> =&gt; {<span class="cstat-no" title="statement not covered" >return [];}</span>;
}
return getEndlessObject();
}
});
}
&nbsp;
/**
* get a mock representation of the store, with spies
* @param {Object} mockState
* @returns {Object}
*/
export function <span class="fstat-no" title="function not covered" >getMockStore(</span>mockState = <span class="branch-0 cbranch-no" title="branch not covered" >{})</span> {
let mockStore = <span class="cstat-no" title="statement not covered" >{</span>
dispatch: <span class="fstat-no" title="function not covered" >fu</span>nction(action) {
<span class="cstat-no" title="statement not covered" > expect(action.type).toBeDefined();</span>
// console.log('actions should have a type: ' + action.type);
},
subscribe: <span class="fstat-no" title="function not covered" >fu</span>nction(callback) {
// console.log('subscription request to the store');
<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >()</span> =&gt; {};</span>
},
getState: <span class="fstat-no" title="function not covered" >fu</span>nction() {
<span class="cstat-no" title="statement not covered" > return mockState;</span>
}
};
<span class="cstat-no" title="statement not covered" > spyOn(mockStore, 'dispatch');</span>
<span class="cstat-no" title="statement not covered" > return mockStore;</span>
}
&nbsp;
/**
* return a array of strings representing each item in array of elements
* @returns {string[]}
*/
export function <span class="fstat-no" title="function not covered" >getTextArray(</span>$jqueryElements) {
<span class="cstat-no" title="statement not covered" > return Array.from($jqueryElements.map(<span class="fstat-no" title="function not covered" >(i</span>ndex, th) =&gt; <span class="cstat-no" title="statement not covered" >$(th).text().trim().replace(/[ ]+/, ' '))</span>);</span>
}
&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="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Sep 28 2017 09:48:32 GMT+0100 (GMT Daylight Time)
</div>
</div>
<script src="..\prettify.js"></script>
<script>
window.onload = function () {
if (typeof prettyPrint === 'function') {
prettyPrint();
}
};
</script>
<script src="..\sorter.js"></script>
</body>
</html>