mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
add redirect test to root (“/“)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<a href='about'>about</a>
|
||||
<a href='slow-preload'>slow preload</a>
|
||||
<a href='redirect-from'>redirect</a>
|
||||
<a href='redirect-root'>redirect (root)</a>
|
||||
<a href='blog/nope'>broken link</a>
|
||||
<a href='blog/throw-an-error'>error link</a>
|
||||
<a href='credentials?creds=include'>credentials</a>
|
||||
|
||||
7
test/app/routes/redirect-root.html
Normal file
7
test/app/routes/redirect-root.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
export default {
|
||||
preload() {
|
||||
this.redirect(301, '/');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -436,6 +436,33 @@ function run({ mode, basepath = '' }) {
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects on server (root)', () => {
|
||||
return nightmare.goto(`${base}/redirect-root`)
|
||||
.path()
|
||||
.then(path => {
|
||||
assert.equal(path, `${basepath}/`);
|
||||
})
|
||||
.then(() => nightmare.page.title())
|
||||
.then(title => {
|
||||
assert.equal(title, 'Great success!');
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects in client (root)', () => {
|
||||
return nightmare.goto(base)
|
||||
.wait('[href="redirect-root"]')
|
||||
.click('[href="redirect-root"]')
|
||||
.wait(200)
|
||||
.path()
|
||||
.then(path => {
|
||||
assert.equal(path, `${basepath}/`);
|
||||
})
|
||||
.then(() => nightmare.page.title())
|
||||
.then(title => {
|
||||
assert.equal(title, 'Great success!');
|
||||
});
|
||||
});
|
||||
|
||||
it('handles 4xx error on server', () => {
|
||||
return nightmare.goto(`${base}/blog/nope`)
|
||||
.path()
|
||||
|
||||
Reference in New Issue
Block a user