Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated tests

  • Loading branch information...
commit 397bddb30caf8eafd7d34dbb91bbb08ba1cab85c 1 parent 1c59c5d
@Baggz Baggz authored
View
35 tests/validators/length.js
@@ -8,51 +8,32 @@ exports['Test #1'] = function(test) {
var count = 0;
- var schema1 = {
+ /**
+ * Schema
+ */
+ var schema = {
required: true,
type: 'string',
- length: [2, 4]
- };
-
- var schema2 = {
- type: 'string',
length: 2
};
[
- 'ab',
+ 'a',
'abc',
'abcd'
].forEach(function(input) {
- amanda.validate(input, schema1, function(error) {
- count += 1;
- test.equal(error, undefined);
- });
- });
-
- [
- '',
- 'a',
- 'abcde'
- ].forEach(function(input) {
- amanda.validate(input, schema1, function(error) {
- count += 1;
- test.ok(error);
- });
- amanda.validate(input, schema2, function(error) {
+ amanda.validate(input, schema, function(error) {
count += 1;
test.ok(error);
});
});
- amanda.validate('ab', schema2, function(error) {
+ amanda.validate('ab', schema, function(error) {
count += 1;
test.equal(error, undefined);
});
-
-
- test.equal(count, 10);
+ test.equal(count, 4);
test.done();
};
View
52 tests/validators/maxLength.js
@@ -0,0 +1,52 @@
+// Load dependencies
+var amanda = require('../../src/amanda.js');
+
+/**
+ * Test #1
+ */
+exports['Test #1'] = function(test) {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ required: true,
+ type: 'string',
+ maxLength: 10
+ };
+
+ [
+ 'a',
+ 'ab',
+ 'abc',
+ 'abcd',
+ 'abcde',
+ 'abcdef',
+ 'abcdefg',
+ 'abcdefgh',
+ 'abcdefghi',
+ 'abcdefghij'
+ ].forEach(function(input) {
+ amanda.validate(input, schema, function(error) {
+ count += 1;
+ test.equal(error, undefined);
+ });
+ });
+
+ [
+ 'abcdefghijk',
+ 'abcdefghijkl',
+ 'abcdefghijklm'
+ ].forEach(function(input) {
+ amanda.validate(input, schema, function(error) {
+ count += 1;
+ test.ok(error);
+ });
+ });
+
+ test.equal(count, 13);
+ test.done();
+
+};
View
47 tests/validators/minLength.js
@@ -0,0 +1,47 @@
+// Load dependencies
+var amanda = require('../../src/amanda.js');
+
+/**
+ * Test #1
+ */
+exports['Test #1'] = function(test) {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ required: true,
+ type: 'string',
+ minLength: 2
+ };
+
+ [
+ '',
+ 'a'
+ ].forEach(function(input) {
+ amanda.validate(input, schema, function(error) {
+ count += 1;
+ test.ok(error);
+ });
+ });
+
+ [
+ 'ab',
+ 'abc',
+ 'abcd',
+ 'abcde',
+ 'abcdef',
+ 'abcdefg',
+ ].forEach(function(input) {
+ amanda.validate(input, schema, function(error) {
+ count += 1;
+ test.equal(error, undefined);
+ });
+ });
+
+ test.equal(count, 8);
+ test.done();
+
+};
Please sign in to comment.
Something went wrong with that request. Please try again.