Skip to content

Commit

Permalink
Add a test case for #259
Browse files Browse the repository at this point in the history
This currently fails. The change in #259 will make it pass. Currently
the image comes out at the wrong path (/hello-worldimage.jpg)

ava doesnt have test.failing() yet, and our eslint config prevents the
usage of test.todo() so this will most defininitely blow up travis.
  • Loading branch information
benstepp committed Apr 27, 2016
1 parent 2401473 commit 145b627
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
Empty file.
17 changes: 17 additions & 0 deletions test/fixtures/path-not-ending-in-slash/html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

export default function html (props) {
return (
<html>
<head>
</head>
<body>
<div id="react-mount" dangerouslySetInnerHTML={{ __html: props.body }} />
</body>
</html>
)
}

html.propTypes = {
body: React.PropTypes.string,
}
9 changes: 9 additions & 0 deletions test/fixtures/path-not-ending-in-slash/pages/_template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

export default function template (props) {
return <div>{props.children}</div>
}

template.propTypes = {
children: React.PropTypes.any,
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Hello World
date: "2015-05-01T22:12:03.284Z"
path: "/hello-world"
---

![An Image](./image.jpg)
26 changes: 26 additions & 0 deletions test/integration/user-rewrites-path-not-ending-in-slash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import test from 'ava'
import path from 'path'
import Promise from 'bluebird'
import { build } from '../support'
import fse from 'fs-extra'
const fs = Promise.promisifyAll(fse)

const fixturePath = path.resolve('..', 'fixtures', 'path-not-ending-in-slash')

test.before('build the site', async () => {
await build(fixturePath)
})

test('the index page has been moved to the hardcoded path', async t => {
const indexPath = path.resolve(fixturePath, 'public', 'hello-world', 'index.html')
const file = await fs.statAsync(indexPath)

t.truthy(file)
})

test("the image has been moved to match the moved page's path", async t => {
const imagePath = path.resolve(fixturePath, 'public', 'hello-world', 'image.jpg')
const file = await fs.statAsync(imagePath)

t.truthy(file)
})

0 comments on commit 145b627

Please sign in to comment.