Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-transformer-remark): restore behavior of serializing date-like fields to string #11716

Merged
merged 6 commits into from
Feb 12, 2019
Prev Previous commit
Next Next commit
chore: de-dry
  • Loading branch information
DSchau committed Feb 8, 2019
commit 88e5e2bb6168aa6ca5654f28a7ef0f84bbfcac55
39 changes: 26 additions & 13 deletions packages/gatsby-transformer-remark/src/__tests__/on-node-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,36 +107,49 @@ date: ${date}

yadda yadda
`
const setup = mdNode =>
onCreateNode({
node: mdNode,
it(`coerces a date a date object`, async () => {
node.content = getContent(`2019-01-01`)
const parsed = await onCreateNode({
node,
actions,
createNodeId,
loadNodeContent,
})
it(`coerces a date a date object`, async () => {
node.content = getContent(`2019-01-01`)
const parsed = await setup(node)

expect(parsed.frontmatter.date).toEqual(expect.any(Date))
})

it.skip(`coerces a date string into a date object`, async () => {
node.content = getContent(JSON.stringify(`2019-01-01`))
const parsed = await setup(node)
const parsed = await onCreateNode({
node,
actions,
createNodeId,
loadNodeContent,
})

expect(parsed.frontmatter.date).toEqual(expect.any(Date))
})

it.skip(`parses date fields and date strings into the same date`, async () => {
const [uno, dos] = await Promise.all([
setup({
...node,
content: getContent(`2019-01-01`),
onCreateNode({
node: {
...node,
content: getContent(`2019-01-01`),
},
actions,
createNodeId,
loadNodeContent,
}),
setup({
...node,
content: getContent(JSON.stringify(`2019-01-01`)),
onCreateNode({
node: {
...node,
content: getContent(JSON.stringify(`2019-01-01`)),
},
actions,
createNodeId,
loadNodeContent,
}),
])

Expand Down