Skip to content

Commit

Permalink
feat(script): agrega un nuevo comando 'dame un piolin' (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoavila authored and gmq committed Oct 18, 2021
1 parent 0fd45a9 commit d12d3d6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/dameunpiolin.js
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)))
}
34 changes: 34 additions & 0 deletions test/dameunpiolin.test.js
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)
})

0 comments on commit d12d3d6

Please sign in to comment.