@@ -56,6 +56,9 @@ export default (robot) => {
5656 robot.respond(/helo room/, async res => {
5757 await res.send('Hello World!')
5858 })
59+ robot.router.get('/helo', async (req, res) => {
60+ res.send("HELO World! I'm Dumbotheelephant.")
61+ })
5962}` )
6063
6164 File . writeFileSync ( './tests/doubles/DummyAdapter.mjs' , `
@@ -125,14 +128,21 @@ export default (robot) => {
125128 describe('Xample testing Hubot scripts', () => {
126129 let robot = null
127130 beforeEach(async () => {
128- robot = new Robot(dummyRobot, false , 'Dumbotheelephant')
131+ robot = new Robot(dummyRobot, true , 'Dumbotheelephant')
129132 await robot.loadAdapter()
130- await robot.loadFile('./scripts', 'Xample.mjs')
131133 await robot.run()
134+ await robot.loadFile('./scripts', 'Xample.mjs')
132135 })
133136 afterEach(() => {
134137 robot.shutdown()
135138 })
139+ it('should handle /helo request', async () => {
140+ const expected = "HELO World! I'm Dumbotheelephant."
141+ const url = 'http://localhost:' + robot.server.address().port + '/helo'
142+ const response = await fetch(url)
143+ const actual = await response.text()
144+ assert.strictEqual(actual, expected)
145+ })
136146 it('should reply with expected message', async () => {
137147 const expected = "HELO World! I'm Dumbotheelephant."
138148 const user = robot.brain.userForId('test-user', { name: 'test user' })
0 commit comments