mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-20 14:25:07 +00:00
overhaul tests
This commit is contained in:
19
test/apps/errors/src/routes/blog/[slug].html
Normal file
19
test/apps/errors/src/routes/blog/[slug].html
Normal 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>
|
||||
9
test/apps/errors/src/routes/blog/[slug].json.js
Normal file
9
test/apps/errors/src/routes/blog/[slug].json.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export function get(req, res) {
|
||||
res.writeHead(404, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
|
||||
res.end(JSON.stringify({
|
||||
message: 'not found'
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user