botbuilder-unit
Version:
Unit tests for chatbot dialogs
285 lines (284 loc) • 10.4 kB
HTML
<html lang="en">
<head>
<title>Code coverage report for botbuilder-unit/spec/promptsSpec.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/spec</a> promptsSpec.js
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">65.85% </span>
<span class="quiet">Statements</span>
<span class='fraction'>27/41</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>2/2</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">42.11% </span>
<span class="quiet">Functions</span>
<span class='fraction'>8/19</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">65.85% </span>
<span class="quiet">Lines</span>
<span class='fraction'>27/41</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</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-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</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-yes">6x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </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">const botFactory = require('./lib/botFactory');
const unit = require('../');
const builder = require('botbuilder');
const util = require('util');
describe('Prompts Test Suite: make sure that default Prompts supported', function () {
let bot = null;
let test = function (title,type, done, callback, responseCallback) {
bot = botFactory();
let script = require(`./scripts/prompts/${type}`);
let waterfall = [callback];
if (responseCallback) {
waterfall.push(responseCallback);
} else {
waterfall.push(<span class="fstat-no" title="function not covered" >fu</span>nction (session, response) {
<span class="cstat-no" title="statement not covered" > session.endDialog('Your response is:' + response.response);</span>
});
}
bot.dialog('/test', waterfall)
unit(bot, script,{
title : title
}).then( <span class="fstat-no" title="function not covered" >fu</span>nction () {
<span class="cstat-no" title="statement not covered" > done();</span>
});
}
it('Should support Prompt.text', function (done) {
test('Should support Prompt.text', 'text', done, <span class="fstat-no" title="function not covered" >fu</span>nction (session) {
<span class="cstat-no" title="statement not covered" > builder.Prompts.text(session, 'Please type any text')</span>
});
});
it('Should support Prompt.confirm', function (done) {
test('Should support Prompt.confirm','confirm', done, <span class="fstat-no" title="function not covered" >fu</span>nction (session) {
<span class="cstat-no" title="statement not covered" > builder.Prompts.text(session, 'Please select yes or no')</span>
});
});
it('Should support Prompt.number', function (done) {
test('Should support Prompt.number','number', done, <span class="fstat-no" title="function not covered" >fu</span>nction (session) {
<span class="cstat-no" title="statement not covered" > builder.Prompts.number(session, 'Please type any number')</span>
});
});
it('Should support Prompt.time', function (done) {
test('Should support Prompt.time','time', done, <span class="fstat-no" title="function not covered" >fu</span>nction (session) {
<span class="cstat-no" title="statement not covered" > builder.Prompts.time(session, 'Please type any date')</span>
}, <span class="fstat-no" title="function not covered" >fu</span>nction (session, results) {
let date = <span class="cstat-no" title="statement not covered" >new Date(results.response.resolution.start);</span>
<span class="cstat-no" title="statement not covered" > session.endDialog(`Your response is:${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`);</span>
});
});
it('Should support Prompt.choices', function (done) {
test('Should support Prompt.choices','choices', done, <span class="fstat-no" title="function not covered" >fu</span>nction (session) {
<span class="cstat-no" title="statement not covered" > builder.Prompts.choice(session, 'Please select any choice', 'red|green|blue',{listStyle:builder.ListStyle.buttons})</span>
}, <span class="fstat-no" title="function not covered" >(s</span>ession, results) => {
<span class="cstat-no" title="statement not covered" > session.endDialog(`Your response is:${results.response.entity}`);</span>
});
});
it('Should support Prompts.attachment', function (done) {
test('Should support Prompts.attachment','attachment', done, <span class="fstat-no" title="function not covered" >(s</span>ession,next) => {
// looks like there is a bug in MBF, and because of that
// i'm writing another shitty line of code
let message = <span class="cstat-no" title="statement not covered" >new builder.Message(session);</span>
<span class="cstat-no" title="statement not covered" > message.text('Please upload an attachment');</span>
<span class="cstat-no" title="statement not covered" > builder.Prompts.attachment(session, message, {</span>
"textFormat": "markdown",
disableRecognizer: true
});
}, <span class="fstat-no" title="function not covered" >(s</span>ession, results) => {
<span class="cstat-no" title="statement not covered" > session.endDialog(`Your response is:${results.response[0].name}:${results.response[0].contentType}`);</span>
});
});
})</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 07:17:32 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>