From cda42b21c3bac3b50fd38c02b43790d4c37b245f Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 23 Sep 2022 09:36:19 -0700 Subject: [PATCH] Add meta schema validation test for block.json --- test/integration/blocks-schema.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/integration/blocks-schema.test.js b/test/integration/blocks-schema.test.js index 8e4ee17b48ff51..1bc75555d6b880 100644 --- a/test/integration/blocks-schema.test.js +++ b/test/integration/blocks-schema.test.js @@ -21,6 +21,16 @@ describe( 'block.json schema', () => { ] ); const ajv = new Ajv(); + test( 'strictly adheres to the draft-04 meta schema', () => { + // Use ajv.compile instead of ajv.validateSchema to validate the schema + // because validateSchema only checks syntax, whereas, compile checks + // if the schema is semantically correct with strict mode. + // See https://github.com/ajv-validator/ajv/issues/1434#issuecomment-822982571 + const result = ajv.compile( blockSchema ); + + expect( result.errors ).toBe( null ); + } ); + test( 'found block folders', () => { expect( blockFolders.length ).toBeGreaterThan( 0 ); } );