Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
blainekasten committed Jan 30, 2020
1 parent e074047 commit 178aad6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/gatsby/cache-dir/__tests__/ensure-resources.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react"
import EnsureResources from "../ensure-resources"
import { render, getNodeText, cleanup } from "@testing-library/react"

jest.mock("../loader", () => ({
loadPageSync(path) {
return { loadPageSync: true, path }
},
loadPage(path) {
return Promise.resolve({ loadPage: true, path })
},
}))

afterAll(cleanup)

describe("EnsureResources", () => {
it("works", () => {
const location = {
pathname: "/",
}
const { container } = render(
<EnsureResources location={location}>
{data => JSON.stringify(data.pageResources)}
</EnsureResources>
)
console.log(container)

expect(getNodeText(container)).toMatchInlineSnapshot(
`"{\\"loadPageSync\\":true,\\"path\\":\\"/\\"}"`
)
})
})

0 comments on commit 178aad6

Please sign in to comment.