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 | 1x
1x
1x
1x
1x
3x
3x
3x
3x
3x
1x
6x
1x
1x
1x
2x
2x
1x
1x
1x
1x
1x
2x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
| const botFactory = require('./lib/botFactory');
const botbuilder = require('botbuilder');
const unit = require('../');
let bot = null;
describe('Test service messages like typing, endconversation and etc', function () {
function botWithSuggestedActions() {
bot.dialog('/test', [
function (session) {
let text = 'Hello world!';
var msg = new botbuilder.Message(session)
.text(text)
.suggestedActions(
botbuilder.SuggestedActions.create(
session, [
botbuilder.CardAction.imBack(session, "add", "Add"),
botbuilder.CardAction.imBack(session, "modules", "Modules"),
botbuilder.CardAction.imBack(session, "hello", "Hello"),
botbuilder.CardAction.imBack(session, "settings", "Settings")
]
));
session.send(msg);
session.endConversation();
}
]);
}
beforeEach(()=> {
bot = botFactory();
});
it('Test typing', function (done) {
let script = require('./scripts/BotMessage/typing');
bot.dialog('/test', [
function (session) {
session.sendTyping();
session.endDialog('Hello world!');
}
]);
unit(bot, script, {
title: 'Test typing'
}).then(function () {
done();
});
});
it('Test endConversation', (done) => {
let script = require('./scripts/BotMessage/endConversation');
bot.dialog('/test', [
function (session) {
session.endConversation('Hello world!');
}
]);
unit(bot, script, {
title: 'Test endConversation'
}).then(function () {
done();
});
});
it('Testing suggested actions', (done) => {
let script = require('./scripts/BotMessage/suggestedActions');
botWithSuggestedActions();
unit(bot, script, {
title: 'Testing suggested actions'
}).then(function () {
done();
});
});
it('Testing that bot error message contains information with differences about suggested actions', (done) => {
botWithSuggestedActions();
let script = require('./scripts/BotMessage/suggestActionContentDiffers');
unit(bot, script, {
title: 'Testing suggested actions'
}).then( () => {
fail('Impossible case');
done();
}, (error) => {
errorMsg = error.toString();
expect(error.includes("settings")).toBe(true );
expect(error.includes("wrongmessage")).toBe(true);
done()
});
})
it('Test that error raised if there are no suggested actions in expected message', (done) => {
bot.dialog('/test', [
function (session) {
let text = 'Hello world!';
var msg = new botbuilder.Message(session)
.text(text);
session.send(msg);
session.endConversation();
}
]);
let script = require('./scripts/BotMessage/emptySuggestedActions');
unit(bot, script, {
title: 'Testing suggested actions'
}).then( () => {
fail('Impossible case');
done();////
}, (error) => {
done()
});
});
it('Test that error raised if count of received suggested actions differs from expected', (done) => {
botWithSuggestedActions();
let script = require('./scripts/BotMessage/suggestedActionsCountDiffers');
unit(bot, script, {
title: 'Testing suggested actions'
}).then( () => {
fail('Impossible case');
done();////
}, (error) => {
done()
});
})
}) |