From 05c4582dd289f562b2f5ddd8d698df1ab73ea80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frantis=CC=8Cek=20Ha=CC=81ba?= Date: Wed, 7 Mar 2012 23:13:18 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20the=20obsolete=20=E2=80=98ArraysSingle?= =?UTF-8?q?Error=E2=80=99=20test=20suite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/validation/arraysSingleError.js | 308 -------------------------- 1 file changed, 308 deletions(-) delete mode 100644 tests/validation/arraysSingleError.js diff --git a/tests/validation/arraysSingleError.js b/tests/validation/arraysSingleError.js deleted file mode 100644 index adf6663..0000000 --- a/tests/validation/arraysSingleError.js +++ /dev/null @@ -1,308 +0,0 @@ -// Load dependencies -var amanda = require('../../dist/latest.js'); - -// Error methods -var errorMethods = [ - 'getProperties', - 'getMessages' -]; - -/** - * Test #1 - */ -exports['Test #1'] = function(test) { - - var a = 0; - - var schema = { - type: 'array' - }; - - [ - 'Hello', - 123, - true, - {}, - function() {} - ].forEach(function(input) { - - amanda.validate(input, schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '', - propertyValue: input, - validator: 'type', - validatorValue: 'array' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - }); - - test.equal(a, 5); - test.done(); - -}; - -/** - * Test #2 - */ -exports['Test #2'] = function(test) { - - var a = 0; - - var schema = { - type: 'array', - items: { - type: 'string' - } - }; - - amanda.validate([ - 'abc', - 'def', - 123, - 'jkl', - 'mno', - 456 - ], schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '[2]', - propertyValue: 123, - validator: 'type', - validatorValue: 'string' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - test.equal(a, 1); - test.done(); - -}; - -/** - * Test #3 - */ -exports['Test #3'] = function(test) { - - var a = 0; - - var schema = { - type: 'array', - items: { - type: 'array' - } - }; - - [ - 'Hello', - 123, - true, - {}, - function() {} - ].forEach(function(input) { - - amanda.validate(input, schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '', - propertyValue: input, - validator: 'type', - validatorValue: 'array' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - }); - - amanda.validate([], schema, function(error) { - - a += 1; - - test.equal(error, undefined) - - }); - - [ - 'Hello', - 123, - true, - {}, - function() {} - ].forEach(function(input) { - - amanda.validate([input], schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '[0]', - propertyValue: input, - validator: 'type', - validatorValue: 'array' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - }); - - amanda.validate([[], 123], schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '[1]', - propertyValue: 123, - validator: 'type', - validatorValue: 'array' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - amanda.validate([[]], schema, function(error) { - - a += 1; - - test.equal(error, undefined); - - }); - - test.equal(a, 13); - test.done(); - -}; - -/** - * Test #4 - */ -exports['Test #4'] = function(test) { - - var a = 0; - - var schema = { - type: 'array', - items: { - type: 'array', - items: { - type: 'array' - } - } - }; - - amanda.validate([], schema, function(error) { - - a += 1; - - test.equal(error, undefined); - - }); - - amanda.validate([[]], schema, function(error) { - - a += 1; - - test.equal(error, undefined); - - }); - - amanda.validate([[[]]], schema, function(error) { - - a += 1; - - test.equal(error, undefined); - - }); - - amanda.validate([[123]], schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '[0][0]', - propertyValue: 123, - validator: 'type', - validatorValue: 'array' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - amanda.validate([123], schema, function(error) { - - a += 1; - - delete error[0].message; - - test.deepEqual(error[0], { - property: '[0]', - propertyValue: 123, - validator: 'type', - validatorValue: 'array' - }); - - test.equal(error.length, 1); - - errorMethods.forEach(function(method) { - test.ok(error[method]); - }); - - }); - - test.equal(a, 5); - test.done(); - -}; \ No newline at end of file