Skip to content

Commit

Permalink
Added to test in api.spec, and users.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphenslee committed Oct 24, 2015
1 parent 0a7ebf6 commit d999c58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 12 additions & 0 deletions test/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ describe('api', function () {
});

});
it('should return an error if unable to parse JSON response', function (done) {
var scope = nock('https://slack.com')
.post('/api/api.test')
.reply(200, '#JSON-CANT_PARSE#');

api.post('api.test', null, function (err, result) {
expect(err).to.be.an('error');
expect(err.message).to.equal('Unexpected token #');
done();
});

});
});

after(function () {
Expand Down
8 changes: 5 additions & 3 deletions test/users.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('users', function () {
});

});

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

var scope = nock('https://slack.com')
Expand Down Expand Up @@ -159,14 +160,15 @@ describe('users', function () {
.post('/api/users.list')
.reply(200, { ok: false, error: 'user_not_found' });

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

});

// function get(name, callback)
describe('#getPresence', function () {

Expand Down Expand Up @@ -264,7 +266,7 @@ describe('users', function () {

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

users.setPresence('away', function (err, result) {
users.setPresence('invalid_presence', function (err, result) {
expect(err).to.not.equal(null);
expect(err.message).to.equal('must supply valid argument(s)');
});
Expand Down

0 comments on commit d999c58

Please sign in to comment.