@arisan/data-api
Version:
The Universal Database API Gateway for CLIO's Modules
192 lines (191 loc) • 6.41 kB
HTML
<html lang="en">
<head>
<title>Code coverage report for lib/middleware/checkPublicIP.spec.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/middleware/</a> checkPublicIP.spec.js
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>27/27</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>4/4</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'>26/26</span>
</div>
</div>
</div>
<div class='status-line high'></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</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
var _chai = require('chai');
var _nodeMocksHttp = require('node-mocks-http');
var _nodeMocksHttp2 = _interopRequireDefault(_nodeMocksHttp);
var _checkPublicIP = require('./checkPublicIP');
var _checkPublicIP2 = _interopRequireDefault(_checkPublicIP);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('checkPublicIP', () => {
it('should call next() on valid IP', done => {
const req = _nodeMocksHttp2.default.createRequest({ body: { publicIp: '123.123.123.123' } });
const res = _nodeMocksHttp2.default.createResponse();
(0, _checkPublicIP2.default)(req, res, done);
});
it('should return 400 without IP', () => {
const req = _nodeMocksHttp2.default.createRequest({ body: {} });
const res = _nodeMocksHttp2.default.createResponse();
(0, _checkPublicIP2.default)(req, res);
_chai.assert.equal(400, res._getStatusCode()); // eslint-disable-line no-underscore-dangle
});
it('should return 400 with Private IP', () => {
const req = _nodeMocksHttp2.default.createRequest({ body: { publicIp: '192.168.0.1' } });
const res = _nodeMocksHttp2.default.createResponse();
(0, _checkPublicIP2.default)(req, res);
_chai.assert.equal(400, res._getStatusCode()); // eslint-disable-line no-underscore-dangle
});
it('should return 400 with Malformed IP', () => {
const req = _nodeMocksHttp2.default.createRequest({ body: { publicIp: '192.168' } });
const res = _nodeMocksHttp2.default.createResponse();
(0, _checkPublicIP2.default)(req, res);
_chai.assert.equal(400, res._getStatusCode()); // eslint-disable-line no-underscore-dangle
});
});
//# sourceMappingURL=checkPublicIP.spec.js.map</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 Wed Jan 04 2017 04:00:17 GMT+0800 (CST)
</div>
</div>
<script src="../../prettify.js"></script>
<script>
window.onload = function () {
if (typeof prettyPrint === 'function') {
prettyPrint();
}
};
</script>
<script src="../../sorter.js"></script>
</body>
</html>