Permalink
Browse files

Fixed isUpdating and isInserting

  • Loading branch information...
masylum committed Jan 22, 2011
1 parent 01e671d commit 1993f6f8e9cd4171904477ff2c96fe6a0f80f677
Showing with 19 additions and 23 deletions.
  1. +2 −2 lib/validator.js
  2. +1 −1 package.json
  3. +16 −20 test/validator.js
View
@@ -23,11 +23,11 @@ module.exports = function (model, data) {
};
validator.isUpdating = function () {
- return utils.isEmpty(this.model);
+ return !utils.isEmpty(this.model);
};
validator.isInserting = function () {
- return !utils.isEmpty(this.model);
+ return utils.isEmpty(this.model);
};
validator.attrChanged = function (attr) {
View
@@ -1,7 +1,7 @@
{
"name": "mongolia",
"description": "Mongodb driver wrapper. Acts as model.",
- "version": "0.0.9",
+ "version": "0.0.10",
"author": "Pau Ramon <masylum@gmail.com>",
"keywords": ["mongo", "mongodb", "orm", "database", "db"],
"main": "./index",
View
@@ -1,23 +1,3 @@
-/**
- * Module dependencies.
- */
-
-GLOBAL.inspect = require('eyes').inspector({
- styles: {
- all: 'yellow',
- label: 'underline',
- other: 'inverted',
- key: 'bold',
-
- special: 'grey',
- string: 'green',
- number: 'red',
- bool: 'blue',
- regexp: 'green'
- },
- maxLength: 9999999999
-});
-
var validator = require('./../lib/validator');
module.exports['test initial status'] = function (assert) {
@@ -101,3 +81,19 @@ module.exports['test multiple errors per field'] = function (assert) {
assert.eql(val.errors.foo.zemba, ['error1', 'error2']);
assert.eql(val.errors.foo.bla, ['error3']);
};
+
+// isUpdating
+module.exports['test isUpdating'] = function (assert) {
+ var val = validator({}, {foo: 'bar'}),
+ val2 = validator({zemba: 'fleiba'}, {foo: 'bar'});
+ assert.equal(val.isUpdating(), false);
+ assert.equal(val2.isUpdating(), true);
+};
+
+// isInserting
+module.exports['test isInserting'] = function (assert) {
+ var val = validator({}, {foo: 'bar'}),
+ val2 = validator({zemba: 'fleiba'}, {foo: 'bar'});
+ assert.equal(val.isInserting(), true);
+ assert.equal(val2.isInserting(), false);
+};

0 comments on commit 1993f6f

Please sign in to comment.