Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Moocar committed Apr 17, 2019
1 parent 5964ff9 commit dfbc209
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/gatsby/src/redux/machines/__tests__/page-component.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { interpret } = require(`xstate`)
const machine = require(`../page-component`)

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

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

describe(`bootstrap`, () => {
beforeEach(() => {
runQueryForPage.mockClear()
enqueueExtractedQueryId.mockClear()
runQueuedQueries.mockClear()
})

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

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

0 comments on commit dfbc209

Please sign in to comment.