UNPKG

botbuilder-unit

Version:
240 lines (239 loc) 7.22 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for botbuilder-unit/src/messages/UserMessage.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">botbuilder-unit/src/messages</a> UserMessage.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">91.67% </span> <span class="quiet">Statements</span> <span class='fraction'>22/24</span> </div> <div class='fl pad1y space-right2'> <span class="strong">83.33% </span> <span class="quiet">Branches</span> <span class='fraction'>5/6</span> </div> <div class='fl pad1y space-right2'> <span class="strong">87.5% </span> <span class="quiet">Functions</span> <span class='fraction'>7/8</span> </div> <div class='fl pad1y space-right2'> <span class="strong">91.67% </span> <span class="quiet">Lines</span> <span class='fraction'>22/24</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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59</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-yes">1x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">69x</span> <span class="cline-any cline-yes">2x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">67x</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">69x</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-yes">1x</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">1x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">68x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">69x</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">69x</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-yes">1x</span></td><td class="text"><pre class="prettyprint lang-js">/* jslint es6 */ 'use strict'; &nbsp; const BaseScriptStep = require('./BaseScriptStep'); &nbsp; function UserMessage(step, config, bot, logReporter, prevStepPromise ) { BaseScriptStep.call(this,step,config,bot,logReporter,prevStepPromise); &nbsp; &nbsp; this.connector = this.bot.connector('console'); &nbsp; this.stepFinishedPromise = Promise.all([prevStepPromise] ).then(() =&gt; { return this.send(); }); } UserMessage.prototype = Object.create(BaseScriptStep.prototype); UserMessage.prototype.constructor = UserMessage; &nbsp; UserMessage.prototype.send = function () { return new Promise((resolve, reject) =&gt; { this.logReporter.messageSent(this.step, this.config); &nbsp; Promise.resolve() .then(() =&gt; { if ("function" === typeof this.config.user) { return this.config.user(); } else { return Promise.resolve(this.config.user); } }) .then((message) =&gt; { if ("object" == typeof message) { <span class="missing-if-branch" title="else path not taken" >E</span>if (!message.data.address) { message.address({ channelId: 'console', user: {id: 'user', name: 'User1'}, bot: {id: 'bot', name: 'Bot'}, conversation: {id: 'Convo1'} }); } this.connector.onEventHandler([message.toMessage()]); } else { this.connector.processMessage(message); } return true; }) &nbsp; .then(() =&gt; { resolve(); }) .catch(<span class="fstat-no" title="function not covered" >(e</span>rr)=&gt; { <span class="cstat-no" title="statement not covered" > this.logReporter.error(`Error at step ${this.step}`, err);</span> <span class="cstat-no" title="statement not covered" > reject(err);</span> }); }) }; &nbsp; &nbsp; module.exports = UserMessage;</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">istanbul</a> at Tue Feb 27 2018 06:41:45 GMT+0300 (+03) </div> </div> <script src="../../../prettify.js"></script> <script> window.onload = function () { if (typeof prettyPrint === 'function') { prettyPrint(); } }; </script> <script src="../../../sorter.js"></script> </body> </html>