Skip to content

Commit

Permalink
Added test to group module
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphenslee committed Oct 23, 2015
1 parent 5b8754f commit 04f7fd3
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions lib/slack/groups.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,18 @@ describe('groups', 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/groups.info')
.reply(200, { ok: false, error: 'group_not_found' });

groups.getInfo('groupid', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('group_not_found');
done();
})
});
});

Expand All @@ -111,6 +122,18 @@ describe('groups', function () {
});

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

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

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

// function get(name, callback)
Expand Down Expand Up @@ -138,6 +161,18 @@ describe('groups', function () {
});

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

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

groups.mark('groupid', 'timestamp',function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('group_not_found');
done();
})
});
});

// function get(name, callback)
Expand All @@ -164,6 +199,18 @@ describe('groups', function () {
});

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

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

groups.setPurpose('groupid','purpose', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('group_not_found');
done();
})
});
});

// function get(name, callback)
Expand All @@ -190,9 +237,17 @@ describe('groups', function () {
});

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

after(function () {
cache = null;
var scope = nock('https://slack.com')
.post('/api/groups.setTopic')
.reply(200, { ok: false, error: 'group_not_found' });

groups.setTopic('groupid','topic', function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('group_not_found');
done();
})
});
});
});

0 comments on commit 04f7fd3

Please sign in to comment.