-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3b1120
commit f154099
Showing
13 changed files
with
48 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ describe('Validation', function () { | |
describe('array', function () { | ||
describe('when array is invalid', function () { | ||
it('should return error when array is not a array', function (done) { | ||
var customer = this.getCustomerFactory({tags: 'not array'}); | ||
var customer = this.getCustomerFactory({tags: 'not array', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('tags'); | ||
expect(err[0].message).to.be(errorExpectedMessage); | ||
|
@@ -27,23 +27,23 @@ describe('Validation', function () { | |
|
||
describe('when array is valid', function () { | ||
it('should not return error when array is an array with string', function (done) { | ||
var customer = this.getCustomerFactory({tags: ['rico', 'com', 'vc']}); | ||
var customer = this.getCustomerFactory({tags: ['rico', 'com', 'vc'], email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not return error when array is an array with integers', function (done) { | ||
var customer = this.getCustomerFactory({tags: [1, 2, 3]}); | ||
var customer = this.getCustomerFactory({tags: [1, 2, 3], email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should return Model instances', function (done) { | ||
var customer = this.getCustomerFactory({name:"Marcos", hdhd:56756}); | ||
var customer = this.getCustomerFactory({name:"Marcos", hdhd:56756, email:'[email protected]'}); | ||
customer.create(function (err) { | ||
Customer.get(function(err, customers) { | ||
expect(err).to.be(null); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ describe('Validation', function () { | |
describe('date', function () { | ||
describe('when date is invalid', function () { | ||
it('should return error when date is not a date', function (done) { | ||
var customer = this.getCustomerFactory({birthDate: 'not@email'}); | ||
var customer = this.getCustomerFactory({birthDate: 'not@email', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('birthDate'); | ||
expect(err[0].message).to.contain(Message.errorExpected('birthDate', 'date', customer.birthDate)); | ||
|
@@ -23,7 +23,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should return error when date has an additional number', function (done) { | ||
var customer = this.getCustomerFactory({birthDate: '1991-01-021'}); | ||
var customer = this.getCustomerFactory({birthDate: '1991-01-021', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('birthDate'); | ||
expect(err[0].message).to.contain(Message.errorExpected('birthDate', 'date', customer.birthDate)); | ||
|
@@ -32,7 +32,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should return error when date is a date that not exists', function (done) { | ||
var customer = this.getCustomerFactory({birthDate: '1991-06-31'}); | ||
var customer = this.getCustomerFactory({birthDate: '1991-06-31', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('birthDate'); | ||
expect(err[0].message).to.contain(Message.errorExpected('birthDate', 'date', customer.birthDate)); | ||
|
@@ -43,15 +43,15 @@ describe('Validation', function () { | |
|
||
describe('when date is valid', function () { | ||
it('should not return error when date is in a string format', function (done) { | ||
var customer = this.getCustomerFactory({birthDate: '1991-01-01'}); | ||
var customer = this.getCustomerFactory({birthDate: '1991-01-01', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not return error when date is in a date object', function (done) { | ||
var customer = this.getCustomerFactory({birthDate: new Date()}); | ||
var customer = this.getCustomerFactory({birthDate: new Date(), email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ describe('Validation', function () { | |
describe('datetime', function () { | ||
describe('when datetime is invalid', function () { | ||
it('should return error when date is not a date', function (done) { | ||
var customer = this.getCustomerFactory({createdAt: 'not@email'}); | ||
var customer = this.getCustomerFactory({createdAt: 'not@email', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('createdAt'); | ||
expect(err[0].message).to.contain(Message.errorExpected('createdAt', 'date', customer.createdAt)); | ||
|
@@ -23,7 +23,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should return error when date has an additional number', function (done) { | ||
var customer = this.getCustomerFactory({createdAt: '1991-01-021'}); | ||
var customer = this.getCustomerFactory({createdAt: '1991-01-021', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('createdAt'); | ||
expect(err[0].message).to.contain(Message.errorExpected('createdAt', 'date', customer.createdAt)); | ||
|
@@ -32,7 +32,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should return error when date is a date that not exists', function (done) { | ||
var customer = this.getCustomerFactory({createdAt: '1991-06-31'}); | ||
var customer = this.getCustomerFactory({createdAt: '1991-06-31', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('createdAt'); | ||
expect(err[0].message).to.contain(Message.errorExpected('createdAt', 'date', customer.createdAt)); | ||
|
@@ -43,23 +43,23 @@ describe('Validation', function () { | |
|
||
describe('when datetime is valid', function () { | ||
it('should not return error when date is in a string format', function (done) { | ||
var customer = this.getCustomerFactory({createdAt: '1991-01-01'}); | ||
var customer = this.getCustomerFactory({createdAt: '1991-01-01', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not return error when datetime is in a string format', function (done) { | ||
var customer = this.getCustomerFactory({createdAt: '1991-01-01T02:00:00.000Z'}); | ||
var customer = this.getCustomerFactory({createdAt: '1991-01-01T02:00:00.000Z', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not return error when date is in a date object', function (done) { | ||
var customer = this.getCustomerFactory({createdAt: new Date()}); | ||
var customer = this.getCustomerFactory({createdAt: new Date(), email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ describe('Validation', function () { | |
describe('enumerable', function () { | ||
describe('when enumerable is invalid', function () { | ||
it('should return error when value is a string and is not in the options accept', function (done) { | ||
var customer = this.getCustomerFactory({gender: 'R'}); | ||
var customer = this.getCustomerFactory({gender: 'R', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('gender'); | ||
expect(err[0].message).to.contain('gender must be one of M, F'); | ||
|
@@ -22,7 +22,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should return error when value is an integer and is not in the options accept', function (done) { | ||
var customer = this.getCustomerFactory({statusId: 4}); | ||
var customer = this.getCustomerFactory({statusId: 4, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('statusId'); | ||
expect(err[0].message).to.contain('statusId must be one of 0, 1'); | ||
|
@@ -33,15 +33,15 @@ describe('Validation', function () { | |
|
||
describe('when enumerable is valid', function () { | ||
it('should not return error when value is an integer and is in the options accept', function (done) { | ||
var customer = this.getCustomerFactory({statusId: 0}); | ||
var customer = this.getCustomerFactory({statusId: 0, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not return error when value is a string and is in the options accept', function (done) { | ||
var customer = this.getCustomerFactory({gender: 'F'}); | ||
var customer = this.getCustomerFactory({gender: 'F', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ describe('Validation', function () { | |
describe('float', function () { | ||
describe('when float is invalid', function () { | ||
it('should return error when float is not an float', function (done) { | ||
var customer = this.getCustomerFactory({income: 'not Income'}); | ||
var customer = this.getCustomerFactory({income: 'not Income', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('income'); | ||
expect(err[0].message).to.contain(errorExpectedMessage); | ||
done(); | ||
}); | ||
}); | ||
it('should return error when float is a float in a string', function (done) { | ||
var customer = this.getCustomerFactory({income: '10.5'}); | ||
var customer = this.getCustomerFactory({income: '10.5', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('income'); | ||
expect(err[0].message).to.contain(errorExpectedMessage); | ||
|
@@ -35,15 +35,15 @@ describe('Validation', function () { | |
|
||
describe('when float is valid', function () { | ||
it('should not return error when float is an float', function (done) { | ||
var customer = this.getCustomerFactory({income: 10.5}); | ||
var customer = this.getCustomerFactory({income: 10.5, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not return error when float is an integer', function (done) { | ||
var customer = this.getCustomerFactory({income: 10}); | ||
var customer = this.getCustomerFactory({income: 10, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ describe('Validation', function () { | |
} | ||
} | ||
validators.push(validator); | ||
var customer = this.getCustomerFactory({name: 'Sanji'}, {validators:validators}); | ||
var customer = this.getCustomerFactory({name: 'Sanji', email:'[email protected]'}, {validators:validators}); | ||
customer.create() | ||
.then(function(customer) { | ||
customer.name = 'sanji'; | ||
|
@@ -64,7 +64,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should trigger validations parameter form Validator', function (done) { | ||
var customer = this.getCustomerFactory({name: 'sanji'}); | ||
var customer = this.getCustomerFactory({name: 'sanji', email:'[email protected]'}); | ||
var validators = []; | ||
var validator = new Validator({validate: firstLetterUpperCase}); | ||
var error = this.error; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ describe('Validation', function () { | |
describe('integer', function () { | ||
describe('when integer is invalid', function () { | ||
it('should return error when integer is not an integer', function (done) { | ||
var customer = this.getCustomerFactory({age: 'not Age'}); | ||
var customer = this.getCustomerFactory({age: 'not Age', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('age'); | ||
expect(err[0].message).to.contain(errorExpectedMessage); | ||
done(); | ||
}); | ||
}); | ||
it('should return error when integer is an integer in a string', function (done) { | ||
var customer = this.getCustomerFactory({age: '10'}); | ||
var customer = this.getCustomerFactory({age: '10', email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('age'); | ||
expect(err[0].message).to.contain(errorExpectedMessage); | ||
|
@@ -35,7 +35,7 @@ describe('Validation', function () { | |
|
||
describe('when integer is valid', function () { | ||
it('should not return error when integer is an integer', function (done) { | ||
var customer = this.getCustomerFactory({age: 100}); | ||
var customer = this.getCustomerFactory({age: 100, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ describe('Validation', function () { | |
describe('when nested object is invalid', function () { | ||
it('should return error when address is not an object', function (done) { | ||
var address = 'not an object'; | ||
var customer = this.getCustomerFactory({address: address}); | ||
var customer = this.getCustomerFactory({address: address, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err[0].field).to.be('address'); | ||
expect(err[0].message).to.contain(errorExpectedMessage); | ||
|
@@ -30,15 +30,15 @@ describe('Validation', function () { | |
}); | ||
it('should have only schema properties in nested array', function () { | ||
var address = {addressName: 'Street X', number: 'X100', zipCode: '010400', q:1}; | ||
var customer = this.getCustomerFactory({address: address}); | ||
var customer = this.getCustomerFactory({address: address, email:'[email protected]'}); | ||
expect(customer.address.q).to.not.be(1); | ||
}); | ||
}); | ||
|
||
describe('when nested object is valid', function () { | ||
it('should validate fields in nested object', function (done) { | ||
var address = {addressName: 'Street X', number: 'X100', zipCode: '010400'}; | ||
var customer = this.getCustomerFactory({address: address}); | ||
var customer = this.getCustomerFactory({address: address, email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.not.be(null); | ||
expect(err[0].field).to.be('address.number'); | ||
|
@@ -48,7 +48,7 @@ describe('Validation', function () { | |
it('should validate fields in nested objects in array', function (done) { | ||
var phone1 = {number: 'X100', areaCode: 11}; | ||
var phone2 = {number: 995952478, areaCode: 11}; | ||
var customer = this.getCustomerFactory({phones:[phone2, phone1]}); | ||
var customer = this.getCustomerFactory({phones:[phone2, phone1], email:'[email protected]'}); | ||
customer.isValid(function (err) { | ||
expect(err).to.not.be(null); | ||
expect(err[0].field).to.be('phones[1].number'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ describe('Validation', function () { | |
describe('when not error', function () { | ||
|
||
it('should trigger validations parameter form Validator', function (done) { | ||
var customer = this.getCustomerFactory({name: 'Sanji'}); | ||
var customer = this.getCustomerFactory({name: 'Sanji', email:'[email protected]'}); | ||
var validators = []; | ||
var validator = new Validator({validate: firstLetterUpperCase}); | ||
var error = this.error; | ||
|
@@ -43,7 +43,7 @@ describe('Validation', function () { | |
describe('when has error', function () { | ||
|
||
it('should trigger validations parameter from Model instance', function (done) { | ||
var customer = this.getCustomerFactory({name: 'sanji'}); | ||
var customer = this.getCustomerFactory({name: 'sanji', email:'[email protected]'}); | ||
var validators = []; | ||
var validator = new Validator({validate: firstLetterUpperCase}); | ||
var error = this.error; | ||
|
@@ -68,7 +68,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should trigger validations parameter from Validator', function (done) { | ||
var customer = this.getCustomerFactory({name: 'sanji'}); | ||
var customer = this.getCustomerFactory({name: 'sanji', email:'[email protected]'}); | ||
var validators = []; | ||
var validator = new Validator({validate: firstLetterUpperCase}); | ||
var error = this.error; | ||
|
@@ -93,7 +93,7 @@ describe('Validation', function () { | |
}); | ||
|
||
it('should trigger validations parameter from Validator using async-validator sintaxe', function (done) { | ||
var customer = this.getCustomerFactory({name: 'sanji', age: 2}); | ||
var customer = this.getCustomerFactory({name: 'sanji', age: 2, email:'[email protected]'}); | ||
var validators = []; | ||
|
||
var asyncSchema = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ describe('Validation', function () { | |
}; | ||
var validator = new Validator({validate: schema}); | ||
validators.push(validator); | ||
var customer = this.getCustomerFactory({name:undefined}); | ||
var customer = this.getCustomerFactory({name:undefined, email:'[email protected]'}); | ||
customer.isValid(validators, function (err) { | ||
expect(err[0].field).to.be('name'); | ||
done(); | ||
|
@@ -39,7 +39,7 @@ describe('Validation', function () { | |
}; | ||
var validator = new Validator({validate: schema}); | ||
validators.push(validator); | ||
var customer = this.getCustomerFactory({name:"Marcos"}, {validators:validators}); | ||
var customer = this.getCustomerFactory({name:"Marcos", email:'[email protected]'}, {validators:validators}); | ||
customer.isValid(function (err) { | ||
expect(err).to.be(null); | ||
done(); | ||
|
Oops, something went wrong.