test: failing test for custom keyword mutating data, #141, #392

master
Evgeny Poberezkin 2017-01-20 20:26:14 +00:00
parent ac5e2cee55
commit 82002ec5e8
1 changed files with 43 additions and 0 deletions

View File

@ -1041,4 +1041,47 @@ describe('Custom keywords', function () {
validate(2) .should.equal(true);
});
});
describe.skip('mutating data', function() {
beforeEach(function() {
const collectionFormat = {
csv: function (data, dataPath, parentData, parentDataProperty, rootData) {
parentData[parentDataProperty] = data.split(',');
return true;
}
};
ajv.addKeyword('collectionFormat', {
type: 'string',
compile: function(schema) { return collectionFormat[schema]; },
metaSchema: {
enum: ['csv']
}
});
});
it('should allow custom keywords mutating data', function() {
var validate = ajv.compile({
type: 'object',
properties: {
foo: {
allOf: [
{ collectionFormat: 'csv' },
{
type: 'array',
items: { type: 'string' },
}
]
}
},
additionalProperties: false
})
var obj = { foo: 'bar,baz,quux' };
validate(obj) .should.equal(true)
obj .should.eql({ foo: ['bar', 'baz', 'quux'] })
});
});
});