Skip to content

Commit

Permalink
fix(gatsby-plugin-manifest): fix plugin option schema and add a test …
Browse files Browse the repository at this point in the history
…for it (#27565)

* fix(gatsby-plugin-manifest): fix plugin option schema and add a test for it

* Remove .only

* Fix dependency version
  • Loading branch information
mxstbr authored Oct 27, 2020
1 parent 1d7bc94 commit 49fdb53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/gatsby-plugin-manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"@babel/runtime": "^7.11.2",
"gatsby-core-utils": "^1.3.23",
"gatsby-plugin-utils": "0.2.35",
"semver": "^7.3.2",
"sharp": "^0.25.4"
},
Expand Down
15 changes: 14 additions & 1 deletion packages/gatsby-plugin-manifest/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const reporter = {
}
}),
}
const { onPostBootstrap } = require(`../gatsby-node`)
const { onPostBootstrap, pluginOptionsSchema } = require(`../gatsby-node`)
const { testPluginOptionsSchema } = require(`gatsby-plugin-utils`)

const apiArgs = {
reporter,
Expand Down Expand Up @@ -524,3 +525,15 @@ describe(`Test plugin manifest options`, () => {
expect(fs.copyFileSync).toHaveBeenCalledTimes(0)
})
})

describe(`pluginOptionsSchema`, () => {
it(`validates options correctly`, () => {
expect(testPluginOptionsSchema(pluginOptionsSchema, manifestOptions))
.toMatchInlineSnapshot(`
Object {
"errors": Array [],
"isValid": true,
}
`)
})
})
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function checkCache(cache, icon, srcIcon, srcIconDigest, callback) {
}

if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
exports.pluginOptionsSchema = ({ Joi }) => {
exports.pluginOptionsSchema = ({ Joi }) =>
Joi.object({
name: Joi.string(),
short_name: Joi.string(),
Expand Down Expand Up @@ -89,13 +89,13 @@ if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
src: Joi.string(),
sizes: Joi.string(),
type: Joi.string(),
purpose: Joi.string(),
})
),
icon_options: Joi.object({
purpose: Joi.string(),
}),
})
}
}

/**
Expand Down

0 comments on commit 49fdb53

Please sign in to comment.