Merge branch 'master' into collision

This commit is contained in:
Rich Harris
2018-05-04 17:05:18 -04:00
committed by GitHub
21 changed files with 105 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
<:Head>
<title>{{status}}</title>
</:Head>
<svelte:head>
<title>{status}</title>
</svelte:head>
<h1>Not found</h1>
<p>{{error.message}}</p>
<p>{error.message}</p>

View File

@@ -1,6 +1,6 @@
<:Head>
<svelte:head>
<title>Internal server error</title>
</:Head>
</svelte:head>
<h1>Internal server error</h1>
<p>{{error.message}}</p>
<p>{error.message}</p>

View File

@@ -1,6 +1,6 @@
<:Head>
<svelte:head>
<title>About</title>
</:Head>
</svelte:head>
<h1>About this site</h1>

View File

@@ -1,11 +1,11 @@
<:Head>
<title>{{post.title}}</title>
</:Head>
<svelte:head>
<title>{post.title}</title>
</svelte:head>
<h1>{{post.title}}</h1>
<h1>{post.title}</h1>
<div class='content'>
{{{post.html}}}
{@html post.html}
</div>
<script>

View File

@@ -1,17 +1,17 @@
<:Head>
<svelte:head>
<title>Blog</title>
</:Head>
</svelte:head>
<h1>Recent posts</h1>
<ul>
{{#each posts as post}}
{#each posts as post}
<!-- we're using the non-standard `rel=prefetch` attribute to
tell Sapper to load the data for the page as soon as
the user hovers over the link or taps it, instead of
waiting for the 'click' event -->
<li><a rel='prefetch' href='blog/{{post.slug}}'>{{post.title}}</a></li>
{{/each}}
<li><a rel='prefetch' href='blog/{post.slug}'>{post.title}</a></li>
{/each}
</ul>
<script>

View File

@@ -1,4 +1,4 @@
<h1>{{message}}</h1>
<h1>{message}</h1>
<script>
export default {

View File

@@ -1,6 +1,6 @@
<:Head>
<svelte:head>
<title>Sapper project template</title>
</:Head>
</svelte:head>
<h1>Great success!</h1>
@@ -11,7 +11,7 @@
<a href='blog/nope'>broken link</a>
<a href='blog/throw-an-error'>error link</a>
<a href='credentials?creds=include'>credentials</a>
<a rel=prefetch class='{{page === "blog" ? "selected" : ""}}' href='blog'>blog</a>
<a rel=prefetch class='{page === "blog" ? "selected" : ""}' href='blog'>blog</a>
<div class='hydrate-test'></div>

View File

@@ -1,4 +1,4 @@
<h1>{{foo.bar()}}</h1>
<h1>{foo.bar()}</h1>
<script>
export default {

View File

@@ -1,4 +1,4 @@
<h1>{{set.has('x')}}</h1>
<h1>{set.has('x')}</h1>
<script>
export default {

View File

@@ -1,4 +1,4 @@
<p>URL is {{url}}</p>
<p>URL is {url}</p>
<script>
export default {

View File

@@ -1 +1 @@
<h1>{{$title}}</h1>
<h1>{$title}</h1>

View File

@@ -1,3 +1,4 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const Nightmare = require('nightmare');
@@ -38,6 +39,7 @@ describe('sapper', function() {
rimraf.sync('export');
rimraf.sync('build');
rimraf.sync('.sapper');
rimraf.sync('start.js');
this.timeout(process.env.CI ? 30000 : 10000);
@@ -148,7 +150,7 @@ function run({ mode, basepath = '' }) {
before(() => {
const promise = mode === 'production'
? exec(`node ${cli} build`).then(() => ports.find(3000))
? exec(`node ${cli} build -l`).then(() => ports.find(3000))
: ports.find(3000).then(port => {
exec(`node ${cli} dev`);
return ports.wait(port).then(() => port);
@@ -160,6 +162,10 @@ function run({ mode, basepath = '' }) {
const dir = mode === 'production' ? 'build' : '.sapper';
if (mode === 'production') {
assert.ok(fs.existsSync('build/index.js'));
}
proc = require('child_process').fork(`${dir}/server.js`, {
cwd: process.cwd(),
env: {
@@ -301,14 +307,17 @@ function run({ mode, basepath = '' }) {
});
});
it('reuses prefetch promise', () => {
it.skip('reuses prefetch promise', () => {
return nightmare
.goto(`${base}/blog`)
.init()
.then(() => {
return capture(() => {
return nightmare
.mouseover('[href="blog/what-is-sapper"]')
.evaluate(() => {
const a = document.querySelector('[href="blog/what-is-sapper"]');
a.dispatchEvent(new MouseEvent('mousemove'));
})
.wait(200);
});
})

View File

@@ -172,6 +172,17 @@ describe('create_routes', () => {
);
});
it('ignores files and directories with leading dots except .well-known', () => {
const routes = create_routes({
files: ['.well-known', '.unknown']
});
assert.deepEqual(
routes.map(r => r.file),
['.well-known']
);
});
it('matches /foo/:bar before /:baz/qux', () => {
const a = create_routes({
files: ['foo/[bar].html', '[baz]/qux.html']