Skip to content

Commit

Permalink
added tests for tag support on node-asana-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Ridge committed Nov 30, 2012
1 parent 9d420d5 commit d90558a
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/assert.js
Expand Up @@ -15,7 +15,7 @@ assert.hasNameAndId = function (obj) {
assert.hasNameAndId(item);
});
}

assert.isObject(obj);
assert.include(obj, 'id');
assert.include(obj, 'name');
Expand All @@ -35,3 +35,12 @@ assert.isTask = function (task) {
assert.isArray(task.followers);
!task.due_on || assert.isString(task.due_on)
};

assert.isTag = function (tag) {
assert.isNumber(tag.id);
assert.isString(tag.name);
assert.isString(tag.notes);
assert.isString(tag.created_at);
assert.isArray(tag.followers);
assert.isObject(tag.workspace);
};
77 changes: 77 additions & 0 deletions test/tags-test.js
@@ -0,0 +1,77 @@
/*
* tags-test.js: Tests for the tag resources of the Asana API.
*
* (C) 2012 Charlie Robbins
*
*/

var vows = require('vows'),
assert = require('./assert'),
helpers = require('./helpers');

var config = helpers.loadConfig();

vows.describe('asana-api/tags').addBatch({
"When using an instance of asana.Client": {
topic: helpers.createClient(),
"the tags.list() method": {
topic: function (client) {
client.tags.list(this.callback);
},
"should respond with a list of tags": function (err, tags) {
assert.isNull(err);
assert.isArray(tags);
assert.hasNameAndId(tags);
}
},
"the tags.get() method": {
topic: function (client) {
if (config.tags && config.tags[0])
client.tags.get(config.tags[0], this.callback);
else
this.callback("no tag configured on config.json");
},
"should respond with a valid tag": function (err, tag) {
assert.isNull(err);
assert.isTag(tag);
}
},
"the tags.tasks() method": {
topic: function (client) {
if (config.tags && config.tags[0])
client.tags.tasks(config.tags[0], this.callback);
else
this.callback("no tags configured in config.json");
},
"should respond with valid tasks": function (err, tasks) {
assert.isNull(err);
assert.isArray(tasks);
assert.hasNameAndId(tasks);
}
},
"the tags.create() method": {
topic: function(client) {
client.tags.create(config.workspaces[0], {
name: 'testing tag'
}, this.callback);
},
"should respond with a valid tag": function(err, tag) {
assert.isNull(err);
assert.isTag(tag);
}
},
"the tags.update() method": {
topic: function(client) {
if (config.tags && config.tags[0])
client.tags.update(config.tags[0],{name: 'testing tag2'}, this.callback);
else
this.callback("no tags configured in config.json");
},
"should respond with a valid tag": function(err, tag) {
assert.isNull(err);
assert.deepEqual('testing tag2', tag.name);
assert.isTag(tag);
}
}
}
}).export(module);

0 comments on commit d90558a

Please sign in to comment.