mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 12:54:38 +00:00
overhaul tests
This commit is contained in:
1
test/apps/basics/src/routes/[slug].html
Normal file
1
test/apps/basics/src/routes/[slug].html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>{params.slug.toUpperCase()}</h1>
|
||||
3
test/apps/basics/src/routes/_error.html
Normal file
3
test/apps/basics/src/routes/_error.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>{status}</h1>
|
||||
|
||||
<p>{error.message}</p>
|
||||
1
test/apps/basics/src/routes/a.html
Normal file
1
test/apps/basics/src/routes/a.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>a</h1>
|
||||
0
test/apps/basics/src/routes/ambiguous/[slug].html
Normal file
0
test/apps/basics/src/routes/ambiguous/[slug].html
Normal file
3
test/apps/basics/src/routes/ambiguous/[slug].json.js
Normal file
3
test/apps/basics/src/routes/ambiguous/[slug].json.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function get(req, res) {
|
||||
res.end(req.params.slug);
|
||||
}
|
||||
11
test/apps/basics/src/routes/b/index.html
Normal file
11
test/apps/basics/src/routes/b/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<h1>{letter}</h1>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
preload() {
|
||||
return this.fetch('b.json').then(r => r.json()).then(letter => {
|
||||
return { letter };
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
3
test/apps/basics/src/routes/b/index.json.js
Normal file
3
test/apps/basics/src/routes/b/index.json.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function get(req, res) {
|
||||
res.end(JSON.stringify('b'));
|
||||
}
|
||||
1
test/apps/basics/src/routes/const.html
Normal file
1
test/apps/basics/src/routes/const.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>reserved words are okay as routes</h1>
|
||||
9
test/apps/basics/src/routes/delete-test/[id].json.js
Normal file
9
test/apps/basics/src/routes/delete-test/[id].json.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export function del(req, res) {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
|
||||
res.end(JSON.stringify({
|
||||
id: req.params.id
|
||||
}));
|
||||
}
|
||||
19
test/apps/basics/src/routes/delete-test/index.html
Normal file
19
test/apps/basics/src/routes/delete-test/index.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<button class='del' on:click='del()'>delete</button>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
oncreate() {
|
||||
window.deleted = null;
|
||||
},
|
||||
|
||||
methods: {
|
||||
del() {
|
||||
fetch(`delete-test/42.json`, { method: 'DELETE' })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
window.deleted = data;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
9
test/apps/basics/src/routes/echo-query/index.html
Normal file
9
test/apps/basics/src/routes/echo-query/index.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>message: "{message}"</h1>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
preload({ query }) {
|
||||
return query;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
7
test/apps/basics/src/routes/index.html
Normal file
7
test/apps/basics/src/routes/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<h1>Great success!</h1>
|
||||
|
||||
<a href="a">a</a>
|
||||
<a href="ambiguous/ok.json">ok</a>
|
||||
<a href="echo-query?message">ok</a>
|
||||
|
||||
<div class='hydrate-test'></div>
|
||||
9
test/apps/basics/src/routes/unsafe-replacement.html
Normal file
9
test/apps/basics/src/routes/unsafe-replacement.html
Normal file
@@ -0,0 +1,9 @@
|
||||
$&
|
||||
|
||||
<script>
|
||||
export default {
|
||||
preload() {
|
||||
return '$&';
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user