From a78f644875849b41ca9344a3fd6c1dcc9f40fd9d Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Sat, 24 Sep 2022 08:19:07 -0700 Subject: [PATCH] Add strict meta schema validation test for block.json (#44423) --- 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 8e4ee17b48ff5..1bc75555d6b88 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 ); } );