Validating Recipe Resource Declarations in GatsbyJS
This test suite validates the recipe validation module in Gatsby Recipes, ensuring proper handling of resource declarations. It verifies error detection for invalid resources and successful validation of legitimate recipe configurations.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
gatsbyjs/gatsby
deprecated-packages/gatsby-recipes/src/validate-recipe.test.js
import validateRecipe from "./validate-recipe"
describe(`validate module validates recipes with resource declarations`, () => {
it(`returns errors for unknown resources`, () => {
const recipe = [{ Fake: [{}] }]
const result = validateRecipe(recipe)[0]
expect(result.validationError).toMatch(`Unknown resource Fake`)
})
it(`returns empty array if there's no errors`, () => {
const recipe = [
{ File: [{ path: `yo.md`, content: `pizza` }] },
{ NPMPackage: [{ name: `wee-package` }] },
]
const validationResponse = validateRecipe(recipe)
expect(validationResponse).toHaveLength(0)
})
})