Skip to content

Commit

Permalink
Rename addChildNodeToParentNode to addNodeToParent
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed May 25, 2017
1 parent b8317cf commit 62bbd99
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions packages/gatsby-transformer-json/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ describe(`Process JSON nodes correctly`, () => {
node.content = JSON.stringify(data)

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
loadNodeContent,
boundActionCreators,
}).then(() => {
expect(createNode.mock.calls).toMatchSnapshot()
expect(addChildNodeToParentNode.mock.calls).toMatchSnapshot()
expect(addNodeToParent.mock.calls).toMatchSnapshot()
expect(createNode).toHaveBeenCalledTimes(2)
expect(addChildNodeToParentNode).toHaveBeenCalledTimes(1)
expect(addNodeToParent).toHaveBeenCalledTimes(1)
})
})

Expand All @@ -49,8 +49,8 @@ describe(`Process JSON nodes correctly`, () => {
node.content = JSON.stringify(data)

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
Expand All @@ -71,8 +71,8 @@ describe(`Process JSON nodes correctly`, () => {
node.content = JSON.stringify(data)

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-transformer-json/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const _ = require(`lodash`)
const crypto = require(`crypto`)

async function onNodeCreate({ node, boundActionCreators, loadNodeContent }) {
const { createNode, addChildNodeToParentNode } = boundActionCreators
const { createNode, addNodeToParent } = boundActionCreators

// Don't reprocess our own nodes! (note: this doesn't normally happen
// but since this transformer creates new nodes with the same media-type
Expand Down Expand Up @@ -51,7 +51,7 @@ async function onNodeCreate({ node, boundActionCreators, loadNodeContent }) {

_.each(JSONArray, j => {
createNode(j)
addChildNodeToParentNode({ parent: node, child: j })
addNodeToParent({ parent: node, child: j })
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe(`transformer-react-doc-gen: onNodeCreate`, () => {
loadNodeContent = jest.fn(node => readFile(node.__fixture))
boundActionCreators = {
createNode: jest.fn(n => createdNodes.push(n)),
addChildNodeToParentNode: jest.fn(n => updatedNodes.push(n)),
addNodeToParent: jest.fn(n => updatedNodes.push(n)),
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function onNodeCreate(
{ node, loadNodeContent, boundActionCreators },
pluginOptions
) {
const { createNode, addChildNodeToParentNode } = boundActionCreators
const { createNode, addNodeToParent } = boundActionCreators

if (node.internal.mediaType !== `application/javascript`) return null

Expand All @@ -92,7 +92,7 @@ export default function onNodeCreate(
},
}

addChildNodeToParentNode({ parent: node, child: metadataNode })
addNodeToParent({ parent: node, child: metadataNode })
metadataNode = createPropNodes(
metadataNode,
component,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ Where oh where is my little pony?
node.content = content

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
loadNodeContent,
boundActionCreators,
}).then(() => {
expect(createNode.mock.calls).toMatchSnapshot()
expect(addChildNodeToParentNode.mock.calls).toMatchSnapshot()
expect(addNodeToParent.mock.calls).toMatchSnapshot()
expect(createNode).toHaveBeenCalledTimes(1)
expect(addChildNodeToParentNode).toHaveBeenCalledTimes(1)
expect(addNodeToParent).toHaveBeenCalledTimes(1)
})
})
})
4 changes: 2 additions & 2 deletions packages/gatsby-transformer-remark/src/on-node-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = async function onNodeCreate({
loadNodeContent,
boundActionCreators,
}) {
const { createNode, addChildNodeToParentNode } = boundActionCreators
const { createNode, addNodeToParent } = boundActionCreators

// Don't reprocess our own nodes! (note: this doesn't normally happen
// but since this transformer creates new nodes with the same media-type
Expand Down Expand Up @@ -51,5 +51,5 @@ module.exports = async function onNodeCreate({
}

createNode(markdownNode)
addChildNodeToParentNode({ parent: node, child: markdownNode })
addNodeToParent({ parent: node, child: markdownNode })
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ describe(`Process image nodes correctly`, () => {
},
}
const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
boundActionCreators,
}).then(() => {
expect(createNode.mock.calls).toMatchSnapshot()
expect(addChildNodeToParentNode.mock.calls).toMatchSnapshot()
expect(addNodeToParent.mock.calls).toMatchSnapshot()
expect(createNode).toHaveBeenCalledTimes(1)
expect(addChildNodeToParentNode).toHaveBeenCalledTimes(1)
expect(addNodeToParent).toHaveBeenCalledTimes(1)
})
})
})
4 changes: 2 additions & 2 deletions packages/gatsby-transformer-sharp/src/on-node-create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const _ = require(`lodash`)

module.exports = async function onNodeCreate({ node, boundActionCreators }) {
const { createNode, addChildNodeToParentNode } = boundActionCreators
const { createNode, addNodeToParent } = boundActionCreators

const extensions = [`jpeg`, `jpg`, `png`, `webp`, `tif`, `tiff`, `svg`]
if (!_.includes(extensions, node.extension)) {
Expand All @@ -20,7 +20,7 @@ module.exports = async function onNodeCreate({ node, boundActionCreators }) {
}

createNode(imageNode)
addChildNodeToParentNode({ parent: node, child: imageNode })
addNodeToParent({ parent: node, child: imageNode })

return
}
16 changes: 8 additions & 8 deletions packages/gatsby-transformer-yaml/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ describe(`Process YAML nodes correctly`, () => {
node.content = yaml.safeDump(data)

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
loadNodeContent,
boundActionCreators,
}).then(() => {
expect(createNode.mock.calls).toMatchSnapshot()
expect(addChildNodeToParentNode.mock.calls).toMatchSnapshot()
expect(addNodeToParent.mock.calls).toMatchSnapshot()
expect(createNode).toHaveBeenCalledTimes(2)
expect(addChildNodeToParentNode).toHaveBeenCalledTimes(1)
expect(addNodeToParent).toHaveBeenCalledTimes(1)
})
})

Expand All @@ -47,8 +47,8 @@ describe(`Process YAML nodes correctly`, () => {
node.content = yaml.safeDump(data)

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
Expand All @@ -69,8 +69,8 @@ describe(`Process YAML nodes correctly`, () => {
node.content = yaml.safeDump(data)

const createNode = jest.fn()
const addChildNodeToParentNode = jest.fn()
const boundActionCreators = { createNode, addChildNodeToParentNode }
const addNodeToParent = jest.fn()
const boundActionCreators = { createNode, addNodeToParent }

await onNodeCreate({
node,
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-transformer-yaml/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const _ = require(`lodash`)
const crypto = require(`crypto`)

async function onNodeCreate({ node, boundActionCreators, loadNodeContent }) {
const { createNode, addChildNodeToParentNode } = boundActionCreators
const { createNode, addNodeToParent } = boundActionCreators
if (node.internal.mediaType !== `text/yaml`) {
return
}
Expand Down Expand Up @@ -42,7 +42,7 @@ async function onNodeCreate({ node, boundActionCreators, loadNodeContent }) {

_.each(yamlArray, y => {
createNode(y)
addChildNodeToParentNode({ parent: node, child: y })
addNodeToParent({ parent: node, child: y })
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ actions.addFieldToNode = ({ node, fieldName, fieldValue }, plugin) => {
}
}

actions.addChildNodeToParentNode = ({ parent, child }, plugin) => {
actions.addNodeToParent = ({ parent, child }, plugin) => {
// Update parent
parent.children.push(child.id)
parent.children = _.uniq(parent.children)
Expand Down

0 comments on commit 62bbd99

Please sign in to comment.