Permalink
Browse files

User: added test for bad repo URL validation

  • Loading branch information...
1 parent 8148253 commit 5918240b4020c1730cf2fd8fc8cca405a0bef8c0 @afeld committed May 2, 2012
Showing with 24 additions and 3 deletions.
  1. +24 −3 test/user_test.js
View
@@ -7,6 +7,24 @@ require('../config/db');
// Create a Test Suite
vows.describe('User').addBatch({
+ 'with a bad Github repo': {
+ topic: function () {
+ return new User({
+ repos: [
+ { url: 'gobbldy-gook' }
+ ]
+ });
+ },
+
+ 'when saved': {
+ topic: function(user){ user.save(this.callback); },
+
+ 'should give a validation error on the repo url': function(err){
+ assert.ok(err.errors.url, 'repos should have thrown a validation error');
+ }
+ }
+ },
+
'with a real Github repo': {
topic: function () {
return new User({
@@ -20,9 +38,12 @@ vows.describe('User').addBatch({
topic: function(user){ user.save(this.callback); },
'should not have any errors': function(err){
- assert.equal(err.errors, null);
+ assert.ok(!err, 'no error should have been thrown');
}
}
-
}
-}).export(module);
+}).export(module, {
+ // handing errors from mongoose is a pain without this flag... see
+ // https://github.com/cloudhead/vows/issues/24
+ error: false
+});

0 comments on commit 5918240

Please sign in to comment.