e22m4u 1 месяц назад
Родитель
Сommit
7c15aa68f6
1 измененных файлов с 17 добавлено и 0 удалено
  1. 17 0
      src/project-data.spec.js

+ 17 - 0
src/project-data.spec.js

@@ -122,6 +122,23 @@ describe('projectData', function () {
     expect(invoked).to.be.eq(1);
     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 () {
   it('should require a factory value to be an object or a non-empty string', function () {
     const throwable = v => () => projectData(() => v, {});
     const throwable = v => () => projectData(() => v, {});
     const error = s =>
     const error = s =>