Skip to content

Commit

Permalink
Update resolve() test spec.
Browse files Browse the repository at this point in the history
Basic implementation appears to be working as expected, all test passing
and 100% coverage maintained.
  • Loading branch information
tmpfs committed Jan 12, 2016
1 parent f813eda commit ef53cae
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion test/spec/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ describe("async-validate:", function() {
}
}

var mixed = {
type: 'object',
fields: {
performer: {
type: 'array',
values: {
type: 'object',
resolve: resolve
}
}
}
}

it("should use resolve function error on required (Person)", function(done) {
var schema = new Schema(descriptor)
, source = {performer: {type: 'Person'}};
Expand Down Expand Up @@ -80,7 +93,7 @@ describe("async-validate:", function() {

it("should use resolve function (Group type)", function(done) {
var schema = new Schema(descriptor)
, source = {performer: {type: 'Group', name: 'joe'}};
, source = {performer: {type: 'Group', name: 'john'}};
schema.validate(source, function(err, res){
expect(err).to.be.null;
expect(res).to.be.null;
Expand All @@ -98,4 +111,19 @@ describe("async-validate:", function() {
done();
});

it("should use resolve function (mixed types)", function(done) {
var schema = new Schema(mixed)
, source = {
performer: [
{type: 'Person', name: 'joe'},
{type: 'Group', name: 'john'}
]
};
schema.validate(source, function(err, res){
expect(err).to.be.null;
expect(res).to.be.null;
done();
});
});

});

0 comments on commit ef53cae

Please sign in to comment.