Skip to content

Commit b84c944

Browse files
fix issue: replyWithTyping is not supported gratifyguy#19
1 parent 53ce0b6 commit b84c944

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

botkit-mock/botMock.js

+16
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ class Bot {
111111
return this.apiResponses.getData(key);
112112
}
113113

114+
startTyping(message, cb){
115+
if (typeof cb === 'function') {
116+
cb()
117+
}
118+
}
119+
120+
stopTyping(message, cb){
121+
if (typeof cb === 'function') {
122+
cb()
123+
}
124+
}
125+
126+
replyWithTyping(message, text){
127+
this.reply(message, text)
128+
}
129+
114130
// reply to user and store reply in array
115131
reply(message, text, cb) {
116132
// check if this is first time then create anwers array

controllers/indexController.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ module.exports = function(bot, controller){
2525
bot.reply(message, 'hello bot multiple');
2626
});
2727

28+
controller.hears(['reply with typing'], 'direct_message', function(bot, message){
29+
bot.replyWithTyping(message, 'hello reply with typing');
30+
});
31+
2832
// simple conversation
2933
controller.hears(['hi'], 'direct_message', function(bot, message){
3034
bot.startConversation(message, function(response, convo){

test/controllerJasmineSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,18 @@ describe("controller tests",()=>{
189189
done()
190190
})
191191
});
192+
193+
it('should return `hello reply with typing` if user types `reply with typing`', (done)=>{
194+
var self = this;
195+
return self.controller.usersInput([{
196+
//by if type null we using type: direct_message
197+
type: null,
198+
first: true,
199+
user: self.slackId,
200+
messages:[{text: 'reply with typing', isAssertion: true}]
201+
}]).then((text)=>{
202+
expect(text).toBe('hello reply with typing');
203+
done()
204+
})
205+
});
192206
});

test/controllerMochaSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,18 @@ describe("controller tests",()=>{
189189
done()
190190
})
191191
});
192+
193+
it('should return `hello reply with typing` if user types `reply with typing`', (done)=>{
194+
var self = this;
195+
return self.controller.usersInput([{
196+
//by if type null we using type: direct_message
197+
type: null,
198+
first: true,
199+
user: self.slackId,
200+
messages:[{text: 'reply with typing', isAssertion: true}]
201+
}]).then((text)=>{
202+
assert.equal(text, 'hello reply with typing');
203+
done()
204+
})
205+
});
192206
});

0 commit comments

Comments
 (0)