Skip to content

Commit

Permalink
Merge pull request #7 from mbland/integration-test-fix
Browse files Browse the repository at this point in the history
Integration test fixes in light of new Promise warnings
  • Loading branch information
mbland authored Dec 1, 2016
2 parents d4f9a27 + 4534793 commit 113d851
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
7 changes: 5 additions & 2 deletions scripts/slack-github-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ function fileIssue(filer, response) {
return issueUrl;
})
.catch(function(err) {
var result = err;

if (err) {
response.reply(err.message || err);
result = err.message || err;
response.reply(result);
}
return Promise.reject(err);
return result;
});
}

Expand Down
20 changes: 10 additions & 10 deletions test/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ chai.should();
chai.use(chaiAsPromised);

describe('Integration test', function() {
var room, listenerCallbackPromise, logHelper, apiStubServer, config,
var room, listenerResult, logHelper, apiStubServer, config,
apiServerDefaults, reactionAddedMessage, patchReactMethodOntoRoom,
patchListenerCallbackAndImpl, sendReaction, initLogMessages,
wrapInfoMessages, matchingRule = 'reactionName: evergreen_tree, ' +
Expand All @@ -37,6 +37,7 @@ describe('Integration test', function() {
apiStubServer = new ApiStubServer();
process.env.HUBOT_SLACK_TOKEN = '<hubot-slack-api-token>';
process.env.HUBOT_GITHUB_TOKEN = '<hubot-github-api-token>';
delete process.env.HUBOT_LOG_LEVEL;
config = helpers.baseConfig();
config.slackApiBaseUrl = apiStubServer.address() + '/slack/';
config.githubApiBaseUrl = apiStubServer.address() + '/github/';
Expand Down Expand Up @@ -157,7 +158,7 @@ describe('Integration test', function() {
});

listener.callback = function(response) {
listenerCallbackPromise = callback(response);
listenerResult = callback(response);
};
};

Expand All @@ -178,7 +179,7 @@ describe('Integration test', function() {
sendReaction = function(reactionName) {
logHelper.beginCapture();
return room.user.react('mbland', reactionName)
.then(function() { return listenerCallbackPromise; })
.then(function() { return listenerResult; })
.then(helpers.resolveNextTick, helpers.rejectNextTick)
.then(logHelper.endCaptureResolve(), logHelper.endCaptureReject());
};
Expand Down Expand Up @@ -239,8 +240,8 @@ describe('Integration test', function() {

response.statusCode = 500;
response.payload = payload;
return sendReaction(helpers.REACTION)
.should.be.rejectedWith(errorReply).then(function() {
return sendReaction(helpers.REACTION).should.become(errorReply)
.then(function() {
var logMessages;

room.messages.should.eql([
Expand All @@ -267,10 +268,9 @@ describe('Integration test', function() {
response.payload = { message: 'should not happen' };
});

return sendReaction('sad-face').should.be.rejectedWith(null)
.then(function() {
room.messages.should.eql([['mbland', 'sad-face']]);
logHelper.filteredMessages().should.eql(initLogMessages());
});
return sendReaction('sad-face').should.become(null).then(function() {
room.messages.should.eql([['mbland', 'sad-face']]);
logHelper.filteredMessages().should.eql(initLogMessages());
});
});
});

0 comments on commit 113d851

Please sign in to comment.