Skip to content

Commit

Permalink
Added test to for im module
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphenslee committed Oct 23, 2015
1 parent 759f7e3 commit 5b8754f
Showing 1 changed file with 57 additions and 10 deletions.
67 changes: 57 additions & 10 deletions lib/slack/im.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ describe('im', function () {
done();
});

it('should return an error to callback if missing required string argument', function (done) {

im.close(null, function (err, result) {
expect(err).to.not.equal(null);
expect(err.message).to.equal('must supply valid argument(s)');
});
done();
});

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

var scope = nock('https://slack.com')
Expand All @@ -56,9 +47,20 @@ describe('im', function () {
expect(result).to.be.an('object');
expect(result.ok).to.equal(true);
done();
});
})
});

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

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

im.close('channelid', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('channel_not_found');
done();
})
});
});

Expand Down Expand Up @@ -91,8 +93,19 @@ describe('im', function () {
expect(result.ok).to.equal(true);
done();
});
});

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

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

im.getList(function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('channel_not_found');
done();
})
});
});

Expand Down Expand Up @@ -133,8 +146,18 @@ describe('im', function () {
expect(result.ok).to.equal(true);
done();
});
});
it('should return an api error to caller', function (done) {

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

im.getHistory('channelid', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('channel_not_found');
done();
})
});
});

Expand Down Expand Up @@ -170,6 +193,18 @@ describe('im', function () {
done();
});
});
it('should return an api error to caller', function (done) {

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

im.mark('channelid', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('channel_not_found');
done();
})
});
});


Expand Down Expand Up @@ -216,5 +251,17 @@ describe('im', function () {
done();
});
});
it('should return an api error to caller', function (done) {

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

im.open('channelid', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('user_not_found');
done();
})
});
});
});

0 comments on commit 5b8754f

Please sign in to comment.