-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e849351
commit 1f1d870
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/gatsby-transformer-remark/__tests__/__snapshots__/gatsby-node.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Process markdown content correctly Correctly creates a new MarkdownRemark node 1`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"children": Array [], | ||
"content": " | ||
Where oh where is my little pony? | ||
", | ||
"contentDigest": "54cfa2ad99756f2fa232cac585280a37", | ||
"frontmatter": Object { | ||
"date": "12/12/2014", | ||
"parent": "whatever", | ||
"title": "my little pony", | ||
}, | ||
"id": "whatever >>> MarkdownRemark", | ||
"mediaType": "text/x-markdown", | ||
"parent": "whatever", | ||
"type": "MarkdownRemark", | ||
}, | ||
], | ||
] | ||
`; | ||
|
||
exports[`Process markdown content correctly Correctly creates a new MarkdownRemark node 2`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"children": Array [ | ||
"whatever >>> MarkdownRemark", | ||
], | ||
"content": "--- | ||
title: \\"my little pony\\" | ||
date: \\"12/12/2014\\" | ||
--- | ||
Where oh where is my little pony? | ||
", | ||
"contentDigest": "whatever", | ||
"id": "whatever", | ||
"mediaType": "text/x-markdown", | ||
}, | ||
], | ||
] | ||
`; |
43 changes: 43 additions & 0 deletions
43
packages/gatsby-transformer-remark/__tests__/gatsby-node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const Promise = require("bluebird") | ||
|
||
const { onNodeCreate } = require("../src/gatsby-node") | ||
|
||
describe(`Process markdown content correctly`, () => { | ||
const node = { | ||
id: "whatever", | ||
contentDigest: "whatever", | ||
mediaType: `text/x-markdown`, | ||
children: [], | ||
} | ||
|
||
// Make some fake functions its expecting. | ||
const loadNodeContent = node => { | ||
return Promise.resolve(node.content) | ||
} | ||
|
||
it(`Correctly creates a new MarkdownRemark node`, async () => { | ||
const content = `--- | ||
title: "my little pony" | ||
date: "12/12/2014" | ||
--- | ||
Where oh where is my little pony? | ||
` | ||
node.content = content | ||
|
||
const createNode = jest.fn() | ||
const updateNode = jest.fn() | ||
const boundActionCreators = { createNode, updateNode } | ||
|
||
await onNodeCreate({ | ||
node, | ||
loadNodeContent, | ||
boundActionCreators, | ||
}).then(() => { | ||
expect(createNode.mock.calls).toMatchSnapshot() | ||
expect(updateNode.mock.calls).toMatchSnapshot() | ||
expect(createNode).toHaveBeenCalledTimes(1) | ||
expect(updateNode).toHaveBeenCalledTimes(1) | ||
}) | ||
}) | ||
}) |