HansHammel/watchmen

View on GitHub
coverage/lcov-report/lib/notifications/services/postmark/postmark.js.html

Summary

Maintainability
Test Coverage
<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for lib/notifications/services/postmark/postmark.js</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="../../../../prettify.css">
    <link rel="stylesheet" href="../../../../base.css">
    <style type='text/css'>
        div.coverage-summary .sorter {
            background-image: url(../../../../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class="header high">
    <h1>Code coverage report for <span class="entity">lib/notifications/services/postmark/postmark.js</span></h1>
    <h2>
        Statements: <span class="metric">83.33% <small>(20 / 24)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
        Branches: <span class="metric">86.67% <small>(13 / 15)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
        Functions: <span class="metric">75% <small>(3 / 4)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
        Lines: <span class="metric">83.33% <small>(20 / 24)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
        Ignored: <span class="metric"><span class="ignore-none">none</span></span> &nbsp;&nbsp;&nbsp;&nbsp;
    </h2>
    <div class="path"><a href="../../../../index.html">All files</a> &#187; <a href="index.html">lib/notifications/services/postmark/</a> &#187; postmark.js</div>
</div>
<div class="body">
<pre><table class="coverage">
<tr><td class="line-count">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</td><td class="line-coverage"><span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">6</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1</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-yes">1</span>
<span class="cline-any cline-yes">6</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">6</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">5</span>
<span class="cline-any cline-yes">1</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-yes">1</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">6</span>
<span class="cline-any cline-yes">6</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">4</span>
<span class="cline-any cline-yes">3</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</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-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></td><td class="text"><pre class="prettyprint lang-js">var defaultConfig = require('../../../../config/notifications/services/postmark');
var postmark = require("postmark");
&nbsp;
exports = module.exports = Postmark;
&nbsp;
function Postmark(config) {
  this.config = config || <span class="branch-1 cbranch-no" title="branch not covered" >defaultConfig;</span>
}
&nbsp;
Postmark.prototype.getName = <span class="fstat-no" title="function not covered" >function() {</span>
<span class="cstat-no" title="statement not covered" >  return 'postmark';</span>
};
&nbsp;
Postmark.prototype.checkConfiguration = function() {
  var err = 'invalid configuration for service Postmark. Please fix it in config/notification-services/postmark. missing field: ';
&nbsp;
  if (!this.config.from)
    return err  + '"from"';
&nbsp;
  if (!this.config.API_KEY)
    return err  + '"API_KEY"';
};
&nbsp;
/**
 * Postmark send
 * @param options.to {Array} email addresses
 * @param options.title {string} subject
 * @param options.body {string} email body
 * @param cb
 * @returns {*}
 */
Postmark.prototype.send = function (options, cb) {
&nbsp;
  var errors = this.checkConfiguration();
  if (errors){
    return cb(errors);
  }
&nbsp;
  if (!options.to || !options.title || !options.body) {
    return cb('invalid options calling Postmark');
  }
&nbsp;
  <span class="missing-if-branch" title="else path not taken" >E</span>if (!Array.isArray(options.to)){
    return cb('"to" field must be an array')
  }
&nbsp;
<span class="cstat-no" title="statement not covered" >  var client = new postmark.Client(this.config.API_KEY);</span>
&nbsp;
<span class="cstat-no" title="statement not covered" >  var payload = {</span>
    'From' : this.config.from,
    'To': options.to.join(','),
    'Subject': options.title,
    'TextBody': options.body
  };
&nbsp;
<span class="cstat-no" title="statement not covered" >  client.sendEmail(payload, cb);</span>
};</pre></td></tr>
</table></pre>

</div>
<div class="footer">
    <div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jun 21 2015 20:01:25 GMT+1000 (AEST)</div>
</div>
<script src="../../../../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../../../../sorter.js"></script>
</body>
</html>