Skip to content

Commit 09d54e7

Browse files
me4502DSchau
authored andcommitted
test(gatsby-plugin-manifest): cleanup tests (#13240)
## Description Cleaning up a few of the manifest tests, as mentioned in #13059 ## Related Issues #13059
1 parent a00a955 commit 09d54e7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

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

+19-11
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ describe(`Test plugin manifest options`, () => {
102102
theme_color: `#a2466c`,
103103
display: `standalone`,
104104
})
105-
const [filePath, contents] = fs.writeFileSync.mock.calls[0]
106-
expect(filePath).toEqual(path.join(`public`, `manifest.webmanifest`))
105+
const contents = fs.writeFileSync.mock.calls[0][1]
106+
expect(fs.writeFileSync).toHaveBeenCalledWith(
107+
path.join(`public`, `manifest.webmanifest`),
108+
expect.anything()
109+
)
107110
expect(sharp).toHaveBeenCalledTimes(0)
108111
expect(contents).toMatchSnapshot()
109112
})
@@ -142,9 +145,8 @@ describe(`Test plugin manifest options`, () => {
142145
path.dirname(`other-icons/icon-48x48.png`)
143146
)
144147

145-
const calls = fs.mkdirSync.mock.calls
146-
expect(calls[0][0]).toEqual(firstIconPath)
147-
expect(calls[1][0]).toEqual(secondIconPath)
148+
expect(fs.mkdirSync).toHaveBeenNthCalledWith(1, firstIconPath)
149+
expect(fs.mkdirSync).toHaveBeenNthCalledWith(2, secondIconPath)
148150
})
149151

150152
it(`invokes sharp if icon argument specified`, async () => {
@@ -208,8 +210,10 @@ describe(`Test plugin manifest options`, () => {
208210
})
209211

210212
expect(sharp).toHaveBeenCalledTimes(0)
211-
const content = JSON.parse(fs.writeFileSync.mock.calls[0][1])
212-
expect(content).toEqual(manifestOptions)
213+
expect(fs.writeFileSync).toHaveBeenCalledWith(
214+
expect.anything(),
215+
JSON.stringify(manifestOptions)
216+
)
213217
})
214218

215219
it(`does file name based cache busting`, async () => {
@@ -226,8 +230,10 @@ describe(`Test plugin manifest options`, () => {
226230
})
227231

228232
expect(sharp).toHaveBeenCalledTimes(3)
229-
const content = JSON.parse(fs.writeFileSync.mock.calls[0][1])
230-
expect(content).toEqual(manifestOptions)
233+
expect(fs.writeFileSync).toHaveBeenCalledWith(
234+
expect.anything(),
235+
JSON.stringify(manifestOptions)
236+
)
231237
})
232238

233239
it(`does not do cache cache busting`, async () => {
@@ -244,8 +250,10 @@ describe(`Test plugin manifest options`, () => {
244250
})
245251

246252
expect(sharp).toHaveBeenCalledTimes(3)
247-
const content = JSON.parse(fs.writeFileSync.mock.calls[0][1])
248-
expect(content).toEqual(manifestOptions)
253+
expect(fs.writeFileSync).toHaveBeenCalledWith(
254+
expect.anything(),
255+
JSON.stringify(manifestOptions)
256+
)
249257
})
250258

251259
it(`icon options iterator adds options and the icon array take precedence`, async () => {

0 commit comments

Comments
 (0)