UNPKG

botbuilder-unit

Version:
795 lines (794 loc) 26.7 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for botbuilder-unit/src/messages/BotMessage.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> BotMessage.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">78.38% </span> <span class="quiet">Statements</span> <span class='fraction'>116/148</span> </div> <div class='fl pad1y space-right2'> <span class="strong">78.48% </span> <span class="quiet">Branches</span> <span class='fraction'>62/79</span> </div> <div class='fl pad1y space-right2'> <span class="strong">91.67% </span> <span class="quiet">Functions</span> <span class='fraction'>22/24</span> </div> <div class='fl pad1y space-right2'> <span class="strong">78.38% </span> <span class="quiet">Lines</span> <span class='fraction'>116/148</span> </div> </div> </div> <div class='status-line medium'></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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244</td><td class="line-coverage quiet"><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-yes">116x</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-yes">114x</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-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">114x</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">1x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">114x</span> <span class="cline-any cline-yes">114x</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-yes">114x</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-yes">114x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">111x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">111x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">111x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">108x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">108x</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">6x</span> <span class="cline-any cline-yes">6x</span> <span class="cline-any cline-yes">6x</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-yes">111x</span> <span class="cline-any cline-yes">13x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">98x</span> <span class="cline-any cline-yes">5x</span> <span class="cline-any cline-yes">5x</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">4x</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">93x</span> <span class="cline-any cline-yes">93x</span> <span class="cline-any cline-yes">93x</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">92x</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-yes">108x</span> <span class="cline-any cline-yes">106x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">2x</span> <span class="cline-any cline-yes">2x</span> <span class="cline-any cline-yes">2x</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-yes">1x</span> <span class="cline-any cline-yes">108x</span> <span class="cline-any cline-yes">97x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">11x</span> <span class="cline-any cline-yes">11x</span> <span class="cline-any cline-yes">11x</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-yes">1x</span> <span class="cline-any cline-yes">111x</span> <span class="cline-any cline-yes">108x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">3x</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-yes">1x</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-yes">1x</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-yes">2x</span> <span class="cline-any cline-yes">2x</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-yes">1x</span> <span class="cline-any cline-yes">111x</span> <span class="cline-any cline-yes">108x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">3x</span> <span class="cline-any cline-yes">22x</span> <span class="cline-any cline-yes">4x</span> <span class="cline-any cline-yes">4x</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">4x</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-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">18x</span> <span class="cline-any cline-yes">4x</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-yes">4x</span> <span class="cline-any cline-yes">5x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">14x</span> <span class="cline-any cline-yes">7x</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-yes">7x</span> <span class="cline-any cline-yes">14x</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">14x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">7x</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-yes">3x</span> <span class="cline-any cline-yes">3x</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-yes">3x</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">114x</span> <span class="cline-any cline-yes">110x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">4x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">4x</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">3x</span> <span class="cline-any cline-yes">3x</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-yes">2x</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-yes">8x</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">1x</span> <span class="cline-any cline-no">&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-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-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">1x</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-yes">116x</span> <span class="cline-any cline-yes">116x</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">const BaseScriptStep = require('./BaseScriptStep'); const inspect = require('util').inspect; function BotMessage(step, config, bot, logReporter, prevStepPromise) { &nbsp; BaseScriptStep.call(this, step, config, bot, logReporter, prevStepPromise); this.receivedMessage = null; this.replyResolver = null; this.replyPromise = new Promise((resolve, reject) =&gt; { this.replyResolver = resolve; }) &nbsp; this.stepFinishedPromise = Promise.all([prevStepPromise, this.replyPromise]).then(() =&gt; { return this.validate(); }); } &nbsp; BotMessage.prototype = Object.create(BaseScriptStep.prototype); BotMessage.prototype.constructor = BotMessage; &nbsp; BotMessage.prototype.isStepHasValidator = function () { return ("undefined" != typeof this.config.bot) || ("undefined" != typeof this.config.suggestedActions) || ("undefined" != typeof this.config.attachments) || ("undefined" != typeof this.config.endConversation) || ("undefined" != typeof this.config.typing) } &nbsp; &nbsp; BotMessage.prototype.validate = function () { &nbsp; return new Promise((resolve, reject) =&gt; { <span class="missing-if-branch" title="if path not taken" >I</span>if (null == this.receivedMessage) { let msg = <span class="cstat-no" title="statement not covered" >'Can\'t continue validation. There are no received message';</span> <span class="cstat-no" title="statement not covered" > reject(msg);</span> <span class="cstat-no" title="statement not covered" > return;</span> } <span class="missing-if-branch" title="if path not taken" >I</span>if (!this.isStepHasValidator()) { let msg = <span class="cstat-no" title="statement not covered" >`Unable to find matching validator. Step config:\n${inspect(this.config)}`;</span> <span class="cstat-no" title="statement not covered" > reject();</span> <span class="cstat-no" title="statement not covered" > return;</span> } &nbsp; this.validateSuggestedActions() .then(() =&gt; { return this.validateAttachments(); }) .then(() =&gt; { return this.validateAttachmentLayout(); }) .then(() =&gt; { return this.validateBotMessage(); }) .then(() =&gt; { return this.validateEndConversation(); }) .then(() =&gt; { return this.validateTyping(); }) .then(resolve) .catch((error) =&gt; { this.logReporter.info(`Expected message at step ${this.step}`, this.config); this.logReporter.expectationError(this.step, this.receivedMessage, error); reject(error); }) }) } &nbsp; BotMessage.prototype.validateBotMessage = function () { if (!this.config.bot) { return Promise.resolve(); } if ("function" == typeof this.config.bot) { let promise = this.config.bot.call(null, this.receivedMessage); if (!(promise instanceof Promise )) { let error = `Message validation by callback failed. Callback MUST return a promise `; return Promise.reject(error); } return promise.catch((error) =&gt; { return Promise.reject(error); }) } else { let isRegExp = this.config.bot.test ? true : false; let result = isRegExp ? this.config.bot.test(this.receivedMessage.text) : this.receivedMessage.text === this.config.bot; if (!result) { let error = `Received text &lt;${this.receivedMessage.text}&gt; does not match &lt;${this.config.bot}&gt;`; return Promise.reject(error); } return Promise.resolve(); &nbsp; } } BotMessage.prototype.validateTyping = function () { if (!this.config.typing) { return Promise.resolve(); } <span class="missing-if-branch" title="else path not taken" >E</span>if ("typing" == this.receivedMessage.type) { this.logReporter.typing(this.step); return Promise.resolve(); } else { let msg = <span class="cstat-no" title="statement not covered" >'Typing indicator expected';</span> <span class="cstat-no" title="statement not covered" > return Promise.reject(msg);</span> } } BotMessage.prototype.validateEndConversation = function () { if (!this.config.endConversation) { return Promise.resolve(); } <span class="missing-if-branch" title="else path not taken" >E</span>if ("endOfConversation" == this.receivedMessage.type) { this.logReporter.endConversation(this.step); return Promise.resolve(); } else { let msg = <span class="cstat-no" title="statement not covered" >'endConversation indicator expected'</span> <span class="cstat-no" title="statement not covered" > return Promise.reject(msg);</span> } } BotMessage.prototype.validateAttachmentLayout = function () { if (!this.config.attachmentLayout) { return Promise.resolve(); } if ("function" == typeof this.config.attachmentLayout) { let promise = this.config.attachmentLayout.call(null, this.receivedMessage.attachmentLayout); <span class="missing-if-branch" title="if path not taken" >I</span>if (!(promise instanceof Promise )) { let msg = <span class="cstat-no" title="statement not covered" >`Attachment layout validation by callback failed. Callback MUST return a promise`;</span> <span class="cstat-no" title="statement not covered" > return Promise.reject((msg));</span> } return promise.catch(<span class="fstat-no" title="function not covered" >()</span> =&gt; { let msg = <span class="cstat-no" title="statement not covered" >`Attachment layout validation by callback failed.`;</span> <span class="cstat-no" title="statement not covered" > return Promise.reject((msg));</span> }) } else <span class="missing-if-branch" title="else path not taken" >E</span>if (this.config.attachmentLayout == this.receivedMessage.attachmentLayout) { return Promise.resolve(); } else { let msg = <span class="cstat-no" title="statement not covered" >`Attachment layout validation failed:&lt;${this.receivedMessage.attachmentLayout}&gt; does not match &lt;${this.config.attachmentLayout}&gt;`;</span> <span class="cstat-no" title="statement not covered" > return Promise.reject(msg);</span> } } &nbsp; BotMessage.prototype.validateAttachments = function () { if (!this.config.attachments) { return Promise.resolve(); } &nbsp; let iterateAndValidate = function (validatorConfig, receivedValue, path) { if ("function" == typeof validatorConfig) { let promise = validatorConfig.call(null, receivedValue, path); <span class="missing-if-branch" title="if path not taken" >I</span>if (!(promise instanceof Promise )) { <span class="cstat-no" title="statement not covered" > throw ('Attachment validation by callback failed. Callback MUST return a Promise');</span> } &nbsp; return promise.catch(<span class="fstat-no" title="function not covered" >(e</span>rror) =&gt; { let msg = <span class="cstat-no" title="statement not covered" >`Attachment validation by callback failed. Path: ${path}`;</span> <span class="cstat-no" title="statement not covered" > if (error) {</span> <span class="cstat-no" title="statement not covered" > msg += ' Error:' + inspect(error)</span> } <span class="cstat-no" title="statement not covered" > throw (msg);</span> }) } else if (Array.isArray(validatorConfig)) { <span class="missing-if-branch" title="if path not taken" >I</span>if (!Array.isArray(receivedValue)) { let msg = <span class="cstat-no" title="statement not covered" >`Attachment validation failed, array must exist at path: ${path}`;</span> <span class="cstat-no" title="statement not covered" > throw msg;</span> } validatorConfig.forEach((item, i) =&gt; { iterateAndValidate(item, receivedValue[i], path + `[${i}]`) }); } else if ("object" == typeof validatorConfig) { <span class="missing-if-branch" title="if path not taken" >I</span>if ("object" != typeof receivedValue) { let msg = <span class="cstat-no" title="statement not covered" >`Attachment validation failed, object must exist at path: ${path}`;</span> <span class="cstat-no" title="statement not covered" > throw msg;</span> } for (let key in validatorConfig) { <span class="missing-if-branch" title="if path not taken" >I</span>if (!validatorConfig.hasOwnProperty(key)) { <span class="cstat-no" title="statement not covered" > continue;</span> } iterateAndValidate(validatorConfig[key], receivedValue[key], path + `[${key}]`); } } else <span class="missing-if-branch" title="if path not taken" >I</span>if (validatorConfig != receivedValue) { let msg = <span class="cstat-no" title="statement not covered" >`Attachment validation failed at path: ${path}`;</span> <span class="cstat-no" title="statement not covered" > throw msg;</span> } &nbsp; } try { iterateAndValidate(this.config.attachments, this.receivedMessage.attachments, 'attachments'); } catch (e) { <span class="cstat-no" title="statement not covered" > return Promise.reject(e);</span> } return Promise.resolve(); } BotMessage.prototype.validateSuggestedActions = function () { &nbsp; if (!this.config.suggestedActions) { return Promise.resolve(); } let isSuggestedActionsPresent = this.receivedMessage.suggestedActions &amp;&amp; this.receivedMessage.suggestedActions.actions &amp;&amp; this.receivedMessage.suggestedActions.actions.length; if (!isSuggestedActionsPresent) { let msg = `Step #${this.step}, Message misses Suggested Actions`; return Promise.reject(msg); } let isRangeError = this.config.suggestedActions.length != this.receivedMessage.suggestedActions.actions.length; if (isRangeError) { let msg = (`Step #${this.step}, amount of received suggested actions (${this.receivedMessage.suggestedActions.actions.length}) differs from expected (${this.config.suggestedActions.length})`); return Promise.reject(msg); } &nbsp; for (let i = 0; i &lt; this.config.suggestedActions.length; i++) { let expectedAction = this.config.suggestedActions[i]; let messageAction = this.receivedMessage.suggestedActions.actions[i]; // let isSameType = messageAction['type'] == expectedAction.data['type']; let isSameValue = messageAction['value'] == expectedAction.data['value']; let isSameTitle = messageAction['title'] == expectedAction.data['title']; &nbsp; let isOk = isSameTitle &amp;&amp; isSameType &amp;&amp; isSameValue; if (!isOk) { let msg = `Step #${this.step}, Failed to compare actions with index ${i}. Reasons:`; <span class="missing-if-branch" title="if path not taken" >I</span>if ( !isSameTitle ) { <span class="cstat-no" title="statement not covered" > msg += `\n- Expected title: ${expectedAction.data.title}\n- Received title: ${messageAction["title"]}`;</span> } <span class="missing-if-branch" title="if path not taken" >I</span>if ( !isSameType ) { <span class="cstat-no" title="statement not covered" > msg += "\n- Wrong type of the card";</span> } <span class="missing-if-branch" title="else path not taken" >E</span>if ( !isSameValue ) { msg += `\n- Messages are different:\n- Expected value: ${expectedAction.data.value}\n- Received value: ${messageAction['value']}`; } &nbsp; return Promise.reject(msg); &nbsp; } } return Promise.resolve(); } BotMessage.prototype.receiveBotReply = function (receivedMessage) { <span class="missing-if-branch" title="if path not taken" >I</span>if (this.receivedMessage) { <span class="cstat-no" title="statement not covered" > throw new Error('This step already has received message');</span> } this.receivedMessage = receivedMessage; this.logReporter.messageReceived(this.step, receivedMessage); this.replyResolver(); &nbsp; } &nbsp; module.exports = BotMessage;</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>