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
Aliaksandr
committed
Jan 12, 2015
1 parent
b826c00
commit 3437d96
Showing
1 changed file
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
"use strict"; | ||
|
||
var tester = require('./_lib/tester'); | ||
|
||
var Schema = require('./_lib/schema'); | ||
|
||
var sh1 = Schema.create().object(function (r, o) { | ||
r('some_1'); | ||
r('some_2'); | ||
o('some_3'); | ||
}); | ||
|
||
exports['valid object'] = tester({ | ||
schema: sh1, | ||
expect: true, | ||
value: { | ||
some_1: 1, | ||
some_2: 2, | ||
some_3: 3, | ||
some_4: 3 | ||
} | ||
}); | ||
|
||
var sh2 = sh1.clone().strict(); | ||
exports['invalid object'] = tester({ | ||
schema: sh2, | ||
vErr: { | ||
rule: 'available_fields', | ||
params: ['some_1', 'some_2', 'some_3'], | ||
path: [] | ||
}, | ||
value: { | ||
some_1: 1, | ||
some_2: 2, | ||
some_3: 3, | ||
some_4: 3 | ||
} | ||
}); | ||
|
||
|
||
var sh3 = sh1.clone().array(); | ||
exports['valid array-object'] = tester({ | ||
schema: sh3, | ||
expect: true, | ||
value: [{ | ||
some_1: 1, | ||
some_2: 2, | ||
some_3: 3, | ||
some_4: 3 | ||
}] | ||
}); | ||
|
||
|
||
var sh4 = sh3.clone().strict(); | ||
exports['invalid array-object'] = tester({ | ||
schema: sh4, | ||
vErr: { | ||
rule: 'available_fields', | ||
params: ['some_1', 'some_2', 'some_3'], | ||
path: ['0'] | ||
}, | ||
value: [{ | ||
some_1: 1, | ||
some_2: 2, | ||
some_3: 3, | ||
some_4: 3 | ||
}] | ||
}); |