Forráskód Böngészése

Update `addSchema` comments, new test.

Afshin Darian 7 éve
szülő
commit
8842f604f4

+ 2 - 0
packages/coreutils/src/settingregistry.ts

@@ -329,10 +329,12 @@ class DefaultSchemaValidator implements ISchemaValidator {
     const validator = this._validator;
     const validate = validator.getSchema('main');
 
+    // Validate against the main schema.
     if (!(validate(schema) as boolean)) {
       return validate.errors as ISchemaValidator.IError[];
     }
 
+    // Validate against the JSON schema meta-schema.
     if (!(validator.validateSchema(schema) as boolean)) {
       return validator.errors as ISchemaValidator.IError[];
     }

+ 12 - 0
test/src/coreutils/settingregistry.spec.ts

@@ -73,6 +73,18 @@ describe('@jupyterlab/coreutils', () => {
         expect(errors).to.not.be(null);
       });
 
+      it('should be safe to call multiple times', () => {
+        const validator = new DefaultSchemaValidator();
+        const plugin = 'foo';
+        const schema = { type: 'object' };
+
+        let errors = validator.addSchema(plugin, schema);
+
+        expect(errors).to.be(null);
+        errors = validator.addSchema(plugin, schema);
+        expect(errors).to.be(null);
+      });
+
     });
 
   });