Permalink
Browse files

Added unit tests. Added fixture data from real event data. Made trell…

…o_events monitor method take a third parameter to indicate testing mode.
  • Loading branch information...
1 parent b17a2d4 commit 2079d2e9e28210d7d1727e71a29d83b0599f2e63 @dogeared committed Jan 3, 2013
Showing with 689 additions and 9 deletions.
  1. +6 −2 Makefile
  2. +8 −3 lib/trello_events.js
  3. +8 −4 package.json
  4. +569 −0 test/fixtures/actions_fixture.js
  5. +6 −0 test/mocha.opts
  6. +92 −0 test/unit/trello_events.test.js
View
@@ -1,8 +1,12 @@
default: all
-all: peanut
+all: unit peanut
+
+unit:
+ @NODE_ENV=test ./node_modules/.bin/mocha \
+ --recursive --reporter spec test/unit
peanut:
@NODE_ENV=test peanut
-.PHONY: peanut
+.PHONY: unit peanut
View
@@ -3,13 +3,14 @@ var _ = require('underscore')
var async = require('async')
var Trello = require('node-trello')
-var TrelloEventsClass = function(_key, _token) {
- var key, token, trello, boards
+var TrelloEventsClass = function(_key, _token, testing) {
+ var key, token, trello, boards, timeout
key = _key
token = _token
trello = new Trello(key, token)
boards = {}
+ timeout = 1000
var eventLoop = function(board, callback) {
var processActions = function(err, actions) {
@@ -34,7 +35,7 @@ var TrelloEventsClass = function(_key, _token) {
async.whilst(
function() { return boards[board] },
function(callback) {
- setTimeout(function() { eventLoop(board, callback) }, 1000)
+ setTimeout(function() { eventLoop(board, callback) }, timeout)
},
function(err) {
if (err) throw err
@@ -75,6 +76,10 @@ var TrelloEventsClass = function(_key, _token) {
return boards[board]
}
}
+ if (testing) {
+ trelloEvents.trello = function() { return trello }
+ timeout = 10
+ }
trelloEvents.__proto__ = new emitter()
emitter.call(trelloEvents)
return trelloEvents
View
@@ -1,13 +1,17 @@
{
"name": "trello_tools",
- "version": "0.0.1",
+ "version": "0.0.2",
"dependencies": {
"async": "0.1.22",
- "expect.js": "0.1.2",
- "eyes": "0.1.8",
"node-trello": "0.1.3",
- "oauth": "0.9.8",
"underscore": "1.4.3"
},
+ "devDependencies": {
+ "expect.js": "0.1.2",
+ "eyes": "0.1.8",
+ "mocha": "1.7.4",
+ "sinon": "1.5.2",
+ "sinon-mocha": "0.0.3"
+ },
"engines": { "node": ">=0.6.17" }
}
Oops, something went wrong.

0 comments on commit 2079d2e

Please sign in to comment.