@@ -4,7 +4,7 @@ var expect = require('chai').expect
4
4
describe ( 'async-validate:' , function ( ) {
5
5
6
6
var descriptor = {
7
- mock : { type : 'function' } ,
7
+ mock : { type : 'function' }
8
8
}
9
9
10
10
it ( 'should error on value that is not a function' , function ( done ) {
@@ -18,7 +18,7 @@ describe('async-validate:', function() {
18
18
19
19
it ( 'should error on invalid arity (len: 1)' , function ( done ) {
20
20
var descriptor = {
21
- mock : { type : 'function' , len : 1 } ,
21
+ mock : { type : 'function' , len : 1 }
22
22
}
23
23
var schema = new Schema ( descriptor ) ;
24
24
schema . validate ( { mock : function ( ) { } } , function ( err , res ) {
@@ -32,7 +32,7 @@ describe('async-validate:', function() {
32
32
33
33
it ( 'should error on invalid arity (min: 1)' , function ( done ) {
34
34
var descriptor = {
35
- mock : { type : 'function' , min : 1 } ,
35
+ mock : { type : 'function' , min : 1 }
36
36
}
37
37
var schema = new Schema ( descriptor ) ;
38
38
schema . validate ( { mock : function ( ) { } } , function ( err , res ) {
@@ -45,10 +45,10 @@ describe('async-validate:', function() {
45
45
46
46
it ( 'should error on invalid arity (max: 0)' , function ( done ) {
47
47
var descriptor = {
48
- mock : { type : 'function' , max : 0 } ,
48
+ mock : { type : 'function' , max : 0 }
49
49
}
50
50
var schema = new Schema ( descriptor ) ;
51
- schema . validate ( { mock : function ( foo ) { } } , function ( err , res ) {
51
+ schema . validate ( { mock : function ( foo ) { foo ( ) ; } } , function ( err , res ) {
52
52
expect ( res . errors . length ) . to . eql ( 1 ) ;
53
53
expect ( res . errors [ 0 ] . message ) . to . eql (
54
54
'mock cannot have more than 0 arguments' ) ;
@@ -58,10 +58,12 @@ describe('async-validate:', function() {
58
58
59
59
it ( 'should error on invalid arity (min: 0, max: 1)' , function ( done ) {
60
60
var descriptor = {
61
- mock : { type : 'function' , min : 0 , max : 1 } ,
61
+ mock : { type : 'function' , min : 0 , max : 1 }
62
62
}
63
- var schema = new Schema ( descriptor ) ;
64
- schema . validate ( { mock : function ( foo , bar ) { } } , function ( err , res ) {
63
+ var schema = new Schema ( descriptor )
64
+ , source = { mock : function ( foo , bar ) { foo ( ) ; bar ( ) } } ;
65
+
66
+ schema . validate ( source , function ( err , res ) {
65
67
expect ( res . errors . length ) . to . eql ( 1 ) ;
66
68
expect ( res . errors [ 0 ] . message ) . to . eql (
67
69
'mock must have arguments length between 0 and 1' ) ;
0 commit comments