Skip to content

Commit dfbc209

Browse files
committed
fix failing tests
1 parent 5964ff9 commit dfbc209

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/gatsby/src/redux/machines/__tests__/page-component.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const { interpret } = require(`xstate`)
22
const machine = require(`../page-component`)
33

4-
jest.mock(`../../../query/query-watcher`)
5-
const { runQueryForPage } = require(`../../../query/query-watcher`)
4+
jest.mock(`../../../query`)
5+
const { enqueueExtractedQueryId, runQueuedQueries } = require(`../../../query`)
66

77
const getService = (args = {}) =>
88
interpret(
@@ -19,7 +19,8 @@ const sleep = (delay = 50) => new Promise(resolve => setTimeout(resolve, delay))
1919

2020
describe(`bootstrap`, () => {
2121
beforeEach(() => {
22-
runQueryForPage.mockClear()
22+
enqueueExtractedQueryId.mockClear()
23+
runQueuedQueries.mockClear()
2324
})
2425

2526
it(`handles not running queries during bootstrap`, () => {
@@ -56,7 +57,7 @@ describe(`bootstrap`, () => {
5657
service.send({ type: `NEW_PAGE_CREATED`, path: `/test` })
5758
// there is setTimeout in action handler for `NEW_PAGE_CREATED`
5859
await sleep()
59-
expect(runQueryForPage).not.toBeCalled()
60+
expect(runQueuedQueries).not.toBeCalled()
6061
})
6162

6263
it(`will queue query when page if new page is created after bootstrap`, async () => {
@@ -65,6 +66,6 @@ describe(`bootstrap`, () => {
6566
service.send({ type: `NEW_PAGE_CREATED`, path })
6667
// there is setTimeout in action handler for `NEW_PAGE_CREATED`
6768
await sleep()
68-
expect(runQueryForPage).toBeCalledWith(path)
69+
expect(runQueuedQueries).toBeCalledWith(path)
6970
})
7071
})

0 commit comments

Comments
 (0)