Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const chai = require('chai');
const expect = chai.expect;

const Validator = require("../src/");
var Validator = require("../src");
Copy link

@rajitha1998 rajitha1998 Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using const makes the most sense here. Since we don't want to overwrite the Validator variable which contains the library that has been imported. Is there any reason that it has to be changed to var @UdeshUK .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense. I'll revert it back.


describe("JS Input Validator", function() {
describe("Run()", function() {
Expand Down Expand Up @@ -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]);
});
});
});
Expand Down