Skip to content

Commit

Permalink
Merge pull request #12 from hubotio/multiline-support
Browse files Browse the repository at this point in the history
feat: Multiline support
  • Loading branch information
joeyguerra committed Jun 9, 2023
2 parents 3ed291f + 17b4d2a commit c7a7150
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ module.exports = function (robot) {
robot.respond(/ADAPTER$/i, msg => {
msg.send(robot.adapterName)
})

robot.respond(/ECHO (.*)$/i, msg => {
robot.respond(/ECHO ([\s\S]*)$/im, msg => {
msg.send(msg.match[1])
})

Expand Down
11 changes: 11 additions & 0 deletions test/diagnostics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@ describe('diagnostics', () => describe('respond to diagnostic commands', () => {
})
return this.robot.adapter.receive(new TextMessage(this.user, 'hubot time'))
}))

context('when asked to echo a multiline string', () => it('echoes the multiline string', function (done) {
this.robot.adapter.on('send', function (envelope, strings) {
expect(strings.length).to.eql(1)
expect(strings[0]).to.eql('horses are weird\nviolets are blue')

return done()
})

return this.robot.adapter.receive(new TextMessage(this.user, 'hubot echo horses are weird\nviolets are blue'))
}))
}))

0 comments on commit c7a7150

Please sign in to comment.