Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mottox2 committed Mar 20, 2020
1 parent 219d82b commit ba7da6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions packages/gatsby/src/query/__tests__/data-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ const setup = async ({ restart = isFirstRun, clearCache = false } = {}) => {
}

jest.doMock(`../query-runner`, () => {
const actualQueryRunner = jest.requireActual(`../query-runner`)
return jest.fn(actualQueryRunner)
const { queryRunner: actualQueryRunner } = jest.requireActual(
`../query-runner`
)
return {
queryRunner: jest.fn(actualQueryRunner),
}
})

jest.doMock(`../../utils/api-runner-node`, () => apiName => {
Expand All @@ -146,7 +150,8 @@ const setup = async ({ restart = isFirstRun, clearCache = false } = {}) => {
const { store, emitter } = require(`../../redux`)
const { saveState } = require(`../../db`)
const reporter = require(`gatsby-cli/lib/reporter`)
const queryRunner = require(`../query-runner`)
// const queryRunnerMock = require(`../query-runner`)
const { queryRunner } = require(`../query-runner`)
const { boundActionCreators } = require(`../../redux/actions`)
const doubleBoundActionCreators = Object.keys(boundActionCreators).reduce(
(acc, actionName) => {
Expand Down Expand Up @@ -175,6 +180,8 @@ const setup = async ({ restart = isFirstRun, clearCache = false } = {}) => {
}
}

// queryRunnerMock.mockClear()
// console.log("=======", queryRunner.mock)
queryRunner.mockClear()

store.dispatch({
Expand Down Expand Up @@ -430,7 +437,7 @@ describe(`query caching between builds`, () => {
siteMetadata: {
title: `My Site`,
description: `Description of site
--edited
edited content #${nodeChangeCounter++}
`,
Expand Down Expand Up @@ -509,7 +516,7 @@ describe(`query caching between builds`, () => {
id: `test-2`,
slug: `bar`,
content: `Dolor sit amet.
--edited
edited content #${nodeChangeCounter++}
`,
Expand Down Expand Up @@ -607,7 +614,7 @@ describe(`query caching between builds`, () => {
createNotUsedNode({
id: `not-used`,
content: `Content
--edited
edited content #${nodeChangeCounter++}`,
})
Expand Down Expand Up @@ -679,7 +686,7 @@ describe(`query caching between builds`, () => {
id: `test-1`,
slug: `foo`,
content: `Lorem ipsum.
--edited
edited content #${nodeChangeCounter++}`,
})
Expand Down Expand Up @@ -838,7 +845,7 @@ describe(`query caching between builds`, () => {
siteMetadata: {
title: `My Site`,
description: `Description of site
--edited
edited content #${nodeChangeCounter++}
`,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/query/queue.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Queue = require(`better-queue`)
const { store } = require(`../redux`)
const FastMemoryStore = require(`../query/better-queue-custom-store`)
const queryRunner = require(`../query/query-runner`)
const { queryRunner } = require(`../query/query-runner`)
const websocketManager = require(`../utils/websocket-manager`)
const { GraphQLRunner } = require(`./graphql-runner`)

Expand Down

0 comments on commit ba7da6e

Please sign in to comment.