From 42b9fd4d80c3013b572de01166c341620841346e Mon Sep 17 00:00:00 2001 From: Udesh Kumarasinghe Date: Tue, 7 Jan 2020 06:49:20 +0530 Subject: [PATCH 1/2] Completed todo in tests --- tests/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/index.js b/tests/index.js index 9b9ae27..2b98b01 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,7 +1,7 @@ const chai = require('chai'); const expect = chai.expect; -const Validator = require("../src/"); +var Validator = require("../src"); describe("JS Input Validator", function() { describe("Run()", function() { @@ -45,9 +45,18 @@ describe("JS Input Validator", function() { }; it("should validate input data object against validation schema and return error object", function() { - // const errors = new Validator(schema).run(values); - // TODO: Fix - expect(true).to.equal(true); + const errors = new Validator(schema).run(values); + + const expectedErrors = { + field1: [ 'Invalid data type!', 'Invalid character size! (max)' ], + field2: [ 'field 2 is required!' ], + field4: [ 'Invalid email address' ] + } + + expect(errors.field1[0]).to.equal(expectedErrors.field1[0]); + expect(errors.field1[1]).to.equal(expectedErrors.field1[1]); + expect(errors.field2[0]).to.equal(expectedErrors.field2[0]); + expect(errors.field4[0]).to.equal(expectedErrors.field4[0]); }); }); }); From cc387b3d0e6725118d050824d03be4962861422f Mon Sep 17 00:00:00 2001 From: Udesh Kumarasinghe Date: Tue, 7 Jan 2020 19:04:53 +0530 Subject: [PATCH 2/2] Reverted validator import to constant --- tests/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/index.js b/tests/index.js index 2b98b01..6e76254 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,7 +1,7 @@ const chai = require('chai'); const expect = chai.expect; -var Validator = require("../src"); +const Validator = require("../src/"); describe("JS Input Validator", function() { describe("Run()", function() {