Created
September 15, 2017 19:10
-
-
Save selfcontained/a5fb22cc2a7a9dd787c9d09ba68ae3f0 to your computer and use it in GitHub Desktop.
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
const slapp = require('slapp') | |
slapp.message('^(hi|hello|hey).*', ['direct_mention', 'direct_message'], helloHandler) | |
// Pull slapp message handler into a function you can export and test | |
function helloHandler (msg, text, greeting) { | |
msg.say(`${greeting}, how are you?`) | |
} | |
// write a test for just the handler | |
describe('hello handler', () => { | |
it('should reply w/ greeting', () => { | |
let msg = {} | |
let sayStub = sinon.stub(msg, 'say') | |
helloHandler(msg, '', 'hello') | |
assert(sayStub.calledWith('hello, how are you?')) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment