From a57162349ef2f03faaad54f3b30e52e912bf3a8a Mon Sep 17 00:00:00 2001 From: Benjamin Stepp Date: Tue, 12 Apr 2016 23:22:14 -0500 Subject: [PATCH] Integration test for the rewritePath function * Also updates the `spawn` support function to reject a promise if given a non-zero exit code. --- test/fixtures/path-rewrite/config.toml | 0 test/fixtures/path-rewrite/gatsby-node.js | 7 +++++ test/fixtures/path-rewrite/html.js | 29 +++++++++++++++++++ test/fixtures/path-rewrite/pages/_template.js | 15 ++++++++++ .../path-rewrite/pages/dont-move-me.md | 3 ++ test/fixtures/path-rewrite/pages/move-me.md | 3 ++ test/integration/user-rewrites-path.js | 29 +++++++++++++++++++ test/support.js | 10 +++++-- 8 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/path-rewrite/config.toml create mode 100644 test/fixtures/path-rewrite/gatsby-node.js create mode 100644 test/fixtures/path-rewrite/html.js create mode 100644 test/fixtures/path-rewrite/pages/_template.js create mode 100644 test/fixtures/path-rewrite/pages/dont-move-me.md create mode 100644 test/fixtures/path-rewrite/pages/move-me.md create mode 100644 test/integration/user-rewrites-path.js diff --git a/test/fixtures/path-rewrite/config.toml b/test/fixtures/path-rewrite/config.toml new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/test/fixtures/path-rewrite/gatsby-node.js b/test/fixtures/path-rewrite/gatsby-node.js new file mode 100644 index 0000000000000..945f367ccbcc6 --- /dev/null +++ b/test/fixtures/path-rewrite/gatsby-node.js @@ -0,0 +1,7 @@ +exports.rewritePath = function rewritePath (parsedPath) { + if (parsedPath.name === 'move-me') { + return '/moved/' + } else { + return undefined + } +} diff --git a/test/fixtures/path-rewrite/html.js b/test/fixtures/path-rewrite/html.js new file mode 100644 index 0000000000000..44460f143ac7f --- /dev/null +++ b/test/fixtures/path-rewrite/html.js @@ -0,0 +1,29 @@ +import React from 'react' +import { prefixLink } from 'gatsby-helpers' + +module.exports = React.createClass({ + displayName: 'HTML', + propTypes: { + body: React.PropTypes.string, + }, + render () { + const { body } = this.props + + return ( + + + + + + + +
+