Skip to content

Commit

Permalink
Added error returning test
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphenslee committed Oct 22, 2015
1 parent 78b9e31 commit b810f07
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions lib/slack/reactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ describe('reactions', function () {
done();
});
});

it('should return an api error to caller', function (done) {

var scope = nock('https://slack.com')
.post('/api/reactions.add')
.reply(200, { ok: false, error: 'api error message'});

reactions.add('emoji', 'channel', 'timestamp', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('api error message');
done();
});
});
});
// function get(name, callback)
describe('#getReactions', function () {
Expand Down Expand Up @@ -80,6 +93,19 @@ describe('reactions', function () {
done();
});
});

it('should return an api error to caller', function (done) {

var scope = nock('https://slack.com')
.post('/api/reactions.get')
.reply(200, { ok: false, error: 'api error message'});

reactions.getReactions('channel', 'timestamp', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('api error message');
done();
});
});
});
// function get(name, callback)
describe('#getList', function () {
Expand Down Expand Up @@ -111,6 +137,19 @@ describe('reactions', function () {
done();
});
});

it('should return an api error to caller', function (done) {

var scope = nock('https://slack.com')
.post('/api/reactions.list')
.reply(200, { ok: false, error: 'api error message'});

reactions.getList('user', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('api error message');
done();
});
});
});
// function get(name, callback)
describe('#remove', function () {
Expand Down Expand Up @@ -142,6 +181,19 @@ describe('reactions', function () {
done();
});
});

it('should return an api error to caller', function (done) {

var scope = nock('https://slack.com')
.post('/api/reactions.remove')
.reply(200, { ok: false, error: 'api error message'});

reactions.remove('channel', 'timestamp', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('api error message');
done();
});
});
});
after(function () {
cache = null;
Expand Down

0 comments on commit b810f07

Please sign in to comment.