Permalink
Browse files

test updates

  • Loading branch information...
1 parent a5540c8 commit 741611ab87ad8564f4267e9416dabe86e7a05a07 Jen Fong-Adwent committed Sep 12, 2012
Showing with 16 additions and 40 deletions.
  1. +6 −15 test/test.components.js
  2. +6 −15 test/test.elements.js
  3. +4 −10 test/test.projects.js
View
@@ -118,18 +118,15 @@ describe('component', function() {
it('accepts an empty callback', function(done) {
var req = otherComponentReq;
- components.add(req, db);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ components.add(req, db, function(err) {
@karthikv

karthikv Sep 12, 2012

Contributor

This is in the test it('accepts an empty callback'), so it defeats the purpose if you use a callback. That's why I had the setTimeout in there originally. One of the other tests already takes care of checking whether update, when used with a callback, works correctly.

@ednapiranha

ednapiranha Sep 12, 2012

Member

ah it was failing the test before?

@karthikv

karthikv Sep 12, 2012

Contributor

Oh, that's because it actually wasn't accepting an empty callback ;). Here's the one line fix.

diff --git a/lib/screens.js b/lib/screens.js
index 3ac8531..276d1f6 100644
--- a/lib/screens.js
+++ b/lib/screens.js
@@ -240,6 +240,8 @@ var removeScreen = exports.remove;
  *   error - null if the object was removed or an error otherwise
  */
 exports.remove = function(req, db, id, callback) {
+  callback = callback || utils.noop;
+
   removeScreen.call(exports, req, db, id, function(err) {
     if (err) {
       // don't remove the screenshot, as there was an error removing the screen

I can add in a pull request, but you'll need to undo this commit. Feel free to just change it yourself, though, since it's so simple.

components.get(req, db, 2, function(err, component) {
component.type.should.equal(req.body.type);
component.row.should.eql(req.body.row);
component.col.should.eql(req.body.col);
component.action.should.equal(req.body.action);
done();
});
- }, 10);
+ });
});
});
@@ -190,15 +187,12 @@ describe('component', function() {
it('accepts an empty callback', function(done) {
req.body.col = 4;
- components.update(req, db, 1);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ components.update(req, db, 1, function(err) {
components.get(req, db, 1, function(err, component) {
component.col.should.eql(req.body.col);
done();
});
- }, 10);
+ });
});
});
@@ -214,15 +208,12 @@ describe('component', function() {
});
it('accepts an empty callback', function(done) {
- components.remove(req, db, 2);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ components.remove(req, db, 2, function(err) {
components.list(req, db, function(error, componentList) {
componentList.should.eql([]);
done();
});
- }, 10);
+ });
});
it('deletes an element associated with a component', function(done) {
View
@@ -123,10 +123,7 @@ describe('element', function() {
it('accepts an empty callback', function(done) {
var req = otherElementReq;
- elements.add(req, db);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ elements.add(req, db, function(err) {
elements.get(req, db, 2, function(err, element) {
element.type.should.equal(req.body.type);
element.head.should.equal(req.body.head);
@@ -135,7 +132,7 @@ describe('element', function() {
element.level.should.equal(req.body.level);
done();
});
- }, 10);
+ });
});
});
@@ -199,15 +196,12 @@ describe('element', function() {
it('accepts an empty callback', function(done) {
req.body.nextId = 3;
- elements.update(req, db, 1);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ elements.update(req, db, 1, function(err) {
elements.get(req, db, 1, function(err, element) {
element.nextId.should.equal(req.body.nextId);
done();
});
- }, 10);
+ });
});
});
@@ -223,15 +217,12 @@ describe('element', function() {
});
it('accepts an empty callback', function(done) {
- elements.remove(req, db, 2);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ elements.remove(req, db, 2, function(err) {
elements.list(req, db, function(error, elementList) {
elementList.should.eql([]);
done();
});
- }, 10);
+ });
});
});
});
View
@@ -64,16 +64,13 @@ describe('project', function() {
it('accepts an empty callback', function(done) {
var req = otherProjectReq;
- projects.add(req, db);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ projects.add(req, db, function(err) {
projects.get(req, db, 2, function(err, project) {
project.title.should.equal(req.body.title);
project.author.should.equal(req.session.email);
done();
});
- }, 10);
+ });
});
});
@@ -148,15 +145,12 @@ describe('project', function() {
});
it('accepts an empty callback', function(done) {
- projects.remove(req, db, 2);
-
- // wait 10ms for db transaction to complete
- setTimeout(function() {
+ projects.remove(req, db, 2, function(err) {
projects.list(req, db, function(err, projectList) {
projectList.should.eql([]);
done();
});
- }, 10);
+ });
});
it('deletes a screen associated with a project', function(done) {

0 comments on commit 741611a

Please sign in to comment.