overhaul tests

This commit is contained in:
Rich Harris
2018-10-07 18:23:43 -04:00
committed by GitHub
parent 18acef3190
commit 5e59855a15
183 changed files with 4145 additions and 3126 deletions

View File

@@ -0,0 +1,3 @@
<h1>{status}</h1>
<p>{error.message}</p>

View File

@@ -0,0 +1,19 @@
<h1>{post.title}</h1>
<script>
export default {
preload({ params }) {
const { slug } = params;
return this.fetch(`blog/${slug}.json`).then(r => {
return r.json().then(data => {
if (r.status !== 200) {
this.error(r.status, data);
}
return data;
});
});
}
};
</script>

View File

@@ -0,0 +1,9 @@
export function get(req, res) {
res.writeHead(404, {
'Content-Type': 'application/json'
});
res.end(JSON.stringify({
message: 'not found'
}));
}

View File

@@ -0,0 +1,5 @@
<h1>root</h1>
<a href="nope">nope</a>
<a href="blog/nope">blog/nope</a>
<a href="throw">throw</a>

View File

@@ -0,0 +1,4 @@
export function get(req, res) {
res.writeHead(500);
res.end('nope');
}

View File

@@ -0,0 +1,7 @@
<script>
export default {
preload() {
throw new Error('nope');
}
};
</script>

View File

@@ -0,0 +1,3 @@
export function get(req, res) {
throw new Error('oops');
}