-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add theme.json schema tests #44252
Merged
ajlende
merged 10 commits into
WordPress:trunk
from
alecgeatches:add/theme-schema-tests
Sep 21, 2022
Merged
Add theme.json schema tests #44252
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d0c0de7
Add failing theme.json schema test
alecgeatches 5ed79cd
Fix missing property object types
alecgeatches 968f0df
Remove type conflict in fontWeight
alecgeatches 98d948f
Refactor fontSizes.fluid into non-union type
alecgeatches 54c074d
Fix core/archives non-property block having additionalProperties: false
alecgeatches 373515a
Fix stylesProperties type
alecgeatches d49897c
Fix styleProperties border direction properties
alecgeatches 3c32915
Fix core/archives block to have object type
alecgeatches 88b8a08
Regenerate schema docs
alecgeatches c19d390
Add note about using compile instead of validateSchema
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,23 @@ | ||
/** | ||
* 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( 'compiles in strict mode', async () => { | ||
const result = ajv.compile( themeSchema ); | ||
|
||
expect( result.errors ).toBe( null ); | ||
} ); | ||
} ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See point 3 from this discussion about why
compile()
is being used here instead ofvalidate()
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alecgeatches I found a couple notes about this in the Ajv docs and issues.
Looks like I was wrong about using
validate
for validating against a meta schema in the first place. And it's intentional that strict mode only applies tocompile
, so that's why we should be using it instead ofvalidateSchema
to validate our schema. 🙃