-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add theme.json schema tests (#44252)
Co-authored-by: Alex Lende <[email protected]>
- Loading branch information
1 parent
f07982a
commit ffa4819
Showing
3 changed files
with
119 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import Ajv from 'ajv-draft-04'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import themeSchema from '../../schemas/json/theme.json'; | ||
|
||
describe( 'theme.json schema', () => { | ||
const ajv = new Ajv( { | ||
// Used for matching unknown blocks without repeating core blocks names | ||
// with patternProperties in settings.blocks and settings.styles | ||
allowMatchingProperties: true, | ||
} ); | ||
|
||
it( '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( themeSchema ); | ||
|
||
expect( result.errors ).toBe( null ); | ||
} ); | ||
} ); |