Skip to content

Commit 49fdb53

Browse files
authored
fix(gatsby-plugin-manifest): fix plugin option schema and add a test for it (#27565)
* fix(gatsby-plugin-manifest): fix plugin option schema and add a test for it * Remove .only * Fix dependency version
1 parent 1d7bc94 commit 49fdb53

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/gatsby-plugin-manifest/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"dependencies": {
1010
"@babel/runtime": "^7.11.2",
1111
"gatsby-core-utils": "^1.3.23",
12+
"gatsby-plugin-utils": "0.2.35",
1213
"semver": "^7.3.2",
1314
"sharp": "^0.25.4"
1415
},

packages/gatsby-plugin-manifest/src/__tests__/gatsby-node.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ const reporter = {
6161
}
6262
}),
6363
}
64-
const { onPostBootstrap } = require(`../gatsby-node`)
64+
const { onPostBootstrap, pluginOptionsSchema } = require(`../gatsby-node`)
65+
const { testPluginOptionsSchema } = require(`gatsby-plugin-utils`)
6566

6667
const apiArgs = {
6768
reporter,
@@ -524,3 +525,15 @@ describe(`Test plugin manifest options`, () => {
524525
expect(fs.copyFileSync).toHaveBeenCalledTimes(0)
525526
})
526527
})
528+
529+
describe(`pluginOptionsSchema`, () => {
530+
it(`validates options correctly`, () => {
531+
expect(testPluginOptionsSchema(pluginOptionsSchema, manifestOptions))
532+
.toMatchInlineSnapshot(`
533+
Object {
534+
"errors": Array [],
535+
"isValid": true,
536+
}
537+
`)
538+
})
539+
})

packages/gatsby-plugin-manifest/src/gatsby-node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function checkCache(cache, icon, srcIcon, srcIconDigest, callback) {
5959
}
6060

6161
if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
62-
exports.pluginOptionsSchema = ({ Joi }) => {
62+
exports.pluginOptionsSchema = ({ Joi }) =>
6363
Joi.object({
6464
name: Joi.string(),
6565
short_name: Joi.string(),
@@ -89,13 +89,13 @@ if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
8989
src: Joi.string(),
9090
sizes: Joi.string(),
9191
type: Joi.string(),
92+
purpose: Joi.string(),
9293
})
9394
),
9495
icon_options: Joi.object({
9596
purpose: Joi.string(),
9697
}),
9798
})
98-
}
9999
}
100100

101101
/**

0 commit comments

Comments
 (0)