Permalink
Browse files

Updated tests

  • Loading branch information...
1 parent d57923a commit dcd33eb28acb44acb4bca9bab5d1a10a49b444ee @Baggz committed Nov 24, 2011
View
@@ -1,12 +1,15 @@
// Load dependencies
var amanda = require('../src/amanda.js');
-exports['Test ‘addValidator’'] = function(test) {
+/**
+ * Test #1
+ */
+exports['Test #1'] = function(test) {
/**
* AddValidator
*/
- amanda.addValidator('unique', function(paramName, paramValue, validator, validators, callback) {
+ amanda.addValidator('unique', function(value, options, callback) {
var takenUsernames = [
'Baggz',
@@ -20,8 +23,8 @@ exports['Test ‘addValidator’'] = function(test) {
* unique: true
* }
*/
- if (validator && takenUsernames.indexOf(paramValue) !== -1) {
- return callback('Oops! This username - ' + paramValue + ' - is taken.');
+ if (options && takenUsernames.indexOf(value) !== -1) {
+ return callback('Oops! This username - ' + value + ' - is taken.');
} else {
return callback(null);
}
@@ -32,6 +35,7 @@ exports['Test ‘addValidator’'] = function(test) {
* Schema
*/
var schema = {
+ reqired: true,
unique: true
};
View
No changes.
No changes.
@@ -1,13 +1,17 @@
// Load dependencies
var amanda = require('../../src/amanda.js');
-exports['Test ‘values’'] = function(test) {
+/**
+ * Test #1
+ */
+exports['Test ‘#1'] = function(test) {
var count = 0;
var schema = {
+ required: true,
type: 'string',
- values: [
+ enum: [
'admin',
'administrator'
]
@@ -1,11 +1,15 @@
// Load dependencies
var amanda = require('../../src/amanda.js');
-exports['Test ‘except’'] = function(test) {
+/**
+ * Test #1
+ */
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
+ required: true,
type: 'string',
except: [
'admin',
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘alpha’
+ * Test #1
*/
-exports['Test ‘alpha’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'alpha'
+ required: true,
+ format: 'alpha'
};
[
@@ -33,15 +33,18 @@ exports['Test ‘alpha’'] = function(test) {
123,
null,
[],
- function() {}
+ {},
+ function() {},
+ null,
+ undefined
].forEach(function(data) {
amanda.validate(data, schema, function(error) {
count += 1;
test.ok(error);
});
});
- test.equal(count, 12);
+ test.equal(count, 15);
test.done();
};
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘alphanumeric’
+ * Test #1
*/
-exports['Test ‘alphanumeric’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'alphanumeric'
+ required: true,
+ format: 'alphanumeric'
};
[
@@ -30,21 +30,23 @@ exports['Test ‘alphanumeric’'] = function(test) {
});
[
- undefined,
'+@#$~^*{}',
'lorem ipsum',
' ',
null,
[],
- function() {}
+ {},
+ function() {},
+ null,
+ undefined
].forEach(function(data) {
amanda.validate(data, schema, function(error) {
count += 1;
test.ok(error);
});
});
- test.equal(count, 15);
+ test.equal(count, 17);
test.done();
};
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘date’
+ * Test #1
*/
-exports['Test ‘date’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'date'
+ required: true,
+ format: 'date'
};
[
@@ -26,21 +26,25 @@ exports['Test ‘date’'] = function(test) {
0,
1,
2,
+ '123',
+ '+@#$~^*{}',
+ 'lorem ipsum',
+ ' ',
+ 123,
null,
- {},
[],
+ {},
function() {},
- 'Hello!',
- undefined,
- ''
+ null,
+ undefined
].forEach(function(data) {
amanda.validate(data, schema, function(error) {
count += 1;
test.ok(error);
});
});
- test.equal(count, 11);
+ test.equal(count, 15);
test.done();
};
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
* Test ‘decimal’
*/
-exports['Test ‘decimal’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'decimal'
+ required: true,
+ format: 'decimal'
};
[
@@ -31,15 +31,24 @@ exports['Test ‘decimal’'] = function(test) {
[
1.123981273,
- 19723.129319
+ 19723.129319,
+ '+@#$~^*{}',
+ 'lorem ipsum',
+ ' ',
+ null,
+ [],
+ {},
+ function() {},
+ null,
+ undefined
].forEach(function(data) {
amanda.validate(data, schema, function(error) {
count += 1;
test.ok(error);
});
});
- test.equal(count, 10);
+ test.equal(count, 19);
test.done();
};
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘email’
+ * Test #1
*/
-exports['Test ‘email’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'email'
+ required: true,
+ format: 'email'
};
var domains = [
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘int’
+ * Test #1
*/
-exports['Test ‘int’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'int'
+ required: true,
+ format: 'int'
};
[
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘ip’
+ * Test #1
*/
-exports['Test ‘ip’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'ip'
+ required: true,
+ format: 'ip'
};
[
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘percentage’
+ * Test #1
*/
-exports['Test ‘percentage’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'decimal'
+ required: true,
+ format: 'percentage'
};
var percentage = [
@@ -85,7 +85,6 @@ exports['Test ‘percentage’'] = function(test) {
40,
35,
33,
- 0,
100,
15,
6,
@@ -1,16 +1,16 @@
// Load dependencies
-var amanda = require('../../../src/amanda.js'),
- async = require('async');
+var amanda = require('../../../src/amanda.js');
/**
- * Test ‘port’
+ * Test #1
*/
-exports['Test ‘port’'] = function(test) {
+exports['Test #1'] = function(test) {
var count = 0;
var schema = {
- type: 'port'
+ required: true,
+ format: 'port'
};
[
Oops, something went wrong.

0 comments on commit dcd33eb

Please sign in to comment.