/
gatsby-node.js
49 lines (44 loc) · 1.3 KB
/
gatsby-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { testPluginOptionsSchema } from "gatsby-plugin-utils"
import { pluginOptionsSchema } from "../gatsby-node"
describe(`gatsby-node.js`, () => {
it(`should provide meaningful errors when fields are invalid`, async () => {
const expectedErrors = [
`"footnotes" must be a boolean`,
`"gfm" must be a boolean`,
`"plugins" must be an array`,
`"jsFrontmatterEngine" must be a boolean`,
]
const { errors, isValid } = await testPluginOptionsSchema(
pluginOptionsSchema,
{
footnotes: `this should be a boolean`,
gfm: `this should be a boolean`,
plugins: `this should be an array`,
jsFrontmatterEngine: `this should be a boolean`,
}
)
expect(isValid).toBe(false)
expect(errors).toEqual(expectedErrors)
})
it(`should validate the schema`, async () => {
const { isValid, errors } = await testPluginOptionsSchema(
pluginOptionsSchema,
{
footnotes: false,
gfm: false,
plugins: [
`gatsby-remark-copy-linked-files`,
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 756,
},
},
],
jsFrontmatterEngine: true,
}
)
expect(isValid).toBe(true)
expect(errors).toEqual([])
})
})