Skip to content

Commit

Permalink
Added test for .createAttachment method.
Browse files Browse the repository at this point in the history
  • Loading branch information
philliphenslee committed Oct 25, 2015
1 parent 0fe0f73 commit efbac51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
3 changes: 0 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ util.inherits(SmartSlack, EventEmitter);
* @return {object} Attachment The attachment instance
*/
SmartSlack.prototype.createAttachment = function(text) {
if (!_.isString(text)) {
throw new Error(errors.missing_required_arg);
}
return new Attachment(text);
};

Expand Down
4 changes: 2 additions & 2 deletions lib/slack/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function post(method, options, callback) {
if (options.attachments) {
options.attachments = JSON.stringify(options.attachments);
}
console.log(options);

var postData = querystring.stringify(options);

var requestOptions = {
Expand Down Expand Up @@ -90,5 +90,5 @@ function post(method, options, callback) {
request.write(postData);
request.end();
}

module.exports.post = post;

18 changes: 17 additions & 1 deletion test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,29 @@ describe('SmartSlack', function () {
});
});

describe('#createAttachment', function () {

it('exists as method on SmartSlack', function (done) {
var slackClient = new SmartSlack(mockopts);
expect(typeof slackClient.createAttachment).to.equal('function');
done();
});
it('should return an attachment object instance', function (done) {
var slackClient = new SmartSlack(mockopts);
var attachment = slackClient.createAttachment('The attachment text');
expect(attachment).to.be.an('object');
expect(attachment.text).to.equal('The attachment text');
done();
});
});

describe('#start', function () {

it('exists as method on SmartSlack', function (done) {
var slackClient = new SmartSlack(mockopts);
expect(typeof slackClient.start).to.equal('function');
done();
})
});
});

describe('#postDirectMessage', function () {
Expand Down

0 comments on commit efbac51

Please sign in to comment.