-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(script): agrega un nuevo comando 'dame un piolin' (#671)
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Description: | ||
// Muestra un Piolin Bendiciones al azar | ||
// | ||
// Dependencies: | ||
// None | ||
// | ||
// Configuration: | ||
// None | ||
// | ||
// Command: | ||
// hubot dame un piolin - Muestra un piolin bendiciones al azar | ||
// hubot dame un piolín - Muestra un piolin bendiciones al azar | ||
// | ||
// Author: | ||
// @nicoavila | ||
|
||
const images = [ | ||
'https://i.imgur.com/RKJwhsn.jpg', | ||
'https://i.imgur.com/tuCGvWq.jpg', | ||
'https://i.imgur.com/Nok5dvX.jpg', | ||
'https://i.imgur.com/aeJoZ0k.jpg', | ||
'https://i.imgur.com/DqXzmfI.jpg' | ||
] | ||
|
||
module.exports = robot => { | ||
robot.respond(/dame un piol[ií]n/gi, msg => msg.send(msg.random(images))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
require('coffee-script/register') | ||
const test = require('ava') | ||
const Helper = require('hubot-test-helper') | ||
|
||
const helper = new Helper('../scripts/dameunpiolin.js') | ||
|
||
class NewMockResponse extends Helper.Response { | ||
random (items) { | ||
return 'https://i.imgur.com/RKJwhsn.jpg' | ||
} | ||
} | ||
|
||
test.beforeEach(t => { | ||
t.context.room = helper.createRoom({ httpd: false, response: NewMockResponse }) | ||
}) | ||
test.afterEach(t => { | ||
t.context.room.destroy() | ||
}) | ||
test.cb('Debe entregar un piolin', t => { | ||
t.context.room.user.say('user', 'hubot piolin') | ||
setTimeout(() => { | ||
t.deepEqual(t.context.room.messages, [['user', 'hubot piolin'], ['hubot', 'https://i.imgur.com/RKJwhsn.jpg']]) | ||
t.end() | ||
}, 500) | ||
}) | ||
test.cb('Debe entregar un piolin', t => { | ||
t.context.room.user.say('user', 'hubot piolín') | ||
setTimeout(() => { | ||
t.deepEqual(t.context.room.messages, [['user', 'hubot piolín'], ['hubot', 'https://i.imgur.com/RKJwhsn.jpg']]) | ||
t.end() | ||
}, 500) | ||
}) |