Skip to content

Commit 52fb3d9

Browse files
Fix issue from PR feedback
1 parent a79fbdf commit 52fb3d9

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

test/common/TestBot.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,15 @@ async function createTestBot(settings = null) {
208208
setupEnv(settings);
209209
setupNock(settings);
210210

211-
return new Promise(async (done) => {
212-
// create new robot, without http, using the mock adapter
213-
const botName = settings?.name || 'hubot';
214-
const botAlias = settings?.alias || null;
215-
const robot = new Robot(MockAdapter, false, botName, botAlias);
216-
await robot.loadAdapter();
211+
const botName = settings?.name || 'hubot';
212+
const botAlias = settings?.alias || null;
213+
const robot = new Robot(MockAdapter, false, botName, botAlias);
214+
await robot.loadAdapter();
217215

218-
grafanaScript(robot);
216+
grafanaScript(robot);
219217

220-
robot.adapter.on('connected', () => {
221-
// create a user
218+
const connectedPromise = new Promise((resolve) => {
219+
robot.adapter.once('connected', () => {
222220
const user = robot.brain.userForId('1', {
223221
name: settings?.testUserName || 'mocha',
224222
room: '#mocha',
@@ -230,11 +228,12 @@ async function createTestBot(settings = null) {
230228
robot.adapterName = settings.adapterName;
231229
}
232230

233-
done(context);
231+
resolve(context);
234232
});
235-
236-
robot.run();
237233
});
234+
235+
robot.run();
236+
return connectedPromise;
238237
}
239238

240239
module.exports = {

0 commit comments

Comments
 (0)