|
|
@@ -122,6 +122,23 @@ describe('projectData', function () {
|
|
|
expect(invoked).to.be.eq(1);
|
|
|
});
|
|
|
|
|
|
+ it('should pass the "factoryArgs" option to the schema factory in the nested schema', function () {
|
|
|
+ let invoked = 0;
|
|
|
+ const factoryArgs = [1, 2, 3];
|
|
|
+ const factory = (...args) => {
|
|
|
+ invoked++;
|
|
|
+ expect(args).to.be.eql(factoryArgs);
|
|
|
+ return {bar: true, baz: false};
|
|
|
+ };
|
|
|
+ const res = projectData(
|
|
|
+ {foo: {schema: factory}},
|
|
|
+ {foo: {bar: 10, baz: 20}},
|
|
|
+ {factoryArgs},
|
|
|
+ );
|
|
|
+ expect(res).to.be.eql({foo: {bar: 10}});
|
|
|
+ expect(invoked).to.be.eq(1);
|
|
|
+ });
|
|
|
+
|
|
|
it('should require a factory value to be an object or a non-empty string', function () {
|
|
|
const throwable = v => () => projectData(() => v, {});
|
|
|
const error = s =>
|