Skip to content

Commit 938555d

Browse files
committed
test(nested-routes): add e2e test for implicit params
1 parent d5129a3 commit 938555d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Diff for: examples/nested-routes/app.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,22 @@ const Quy = {
3636
</div>
3737
`
3838
}
39-
const Quux = { template: '<div>quux</div>' }
40-
const Zap = { template: '<div><h3>zap</h3><pre>{{ $route.params.zapId }}</pre></div>' }
39+
const Quux = {
40+
template: `<div>quux<router-link :to="{ name: 'quuy' }">go to quuy</router-link></div>`
41+
}
42+
const Quuy = { template: '<div>quuy</div>' }
43+
const Zap = {
44+
template: '<div><h3>zap</h3><pre>{{ $route.params.zapId }}</pre></div>'
45+
}
4146

4247
const router = new VueRouter({
4348
mode: 'history',
4449
base: __dirname,
4550
routes: [
4651
{ path: '/', redirect: '/parent' },
47-
{ path: '/parent', component: Parent,
52+
{
53+
path: '/parent',
54+
component: Parent,
4855
children: [
4956
// an empty path will be treated as the default, e.g.
5057
// components rendered at /parent: Root -> Parent -> Default
@@ -65,7 +72,10 @@ const router = new VueRouter({
6572
{
6673
path: 'qux/:quxId',
6774
component: Qux,
68-
children: [{ path: 'quux', name: 'quux', component: Quux }]
75+
children: [
76+
{ path: 'quux', name: 'quux', component: Quux },
77+
{ path: 'quuy', name: 'quuy', component: Quuy }
78+
]
6979
},
7080

7181
{ path: 'quy/:quyId', component: Quy },
@@ -91,6 +101,8 @@ new Vue({
91101
<li><router-link :to="{name: 'zap'}">/parent/zap</router-link></li>
92102
<li><router-link :to="{name: 'zap', params: {zapId: 1}}">/parent/zap/1</router-link></li>
93103
<li><router-link :to="{ params: { zapId: 2 }}">{ params: { zapId: 2 }} (relative params)</router-link></li>
104+
<li><router-link to="/parent/qux/1/quux">/parent/qux/1/quux</router-link></li>
105+
<li><router-link to="/parent/qux/2/quux">/parent/qux/2/quux</router-link></li>
94106
</ul>
95107
<router-view class="view"></router-view>
96108
</div>

Diff for: test/e2e/specs/nested-routes.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
browser
44
.url('http://localhost:8080/nested-routes/')
55
.waitForElementVisible('#app', 1000)
6-
.assert.count('li a', 9)
6+
.assert.count('li a', 11)
77
.assert.urlEquals('http://localhost:8080/nested-routes/parent')
88
.assert.containsText('.view', 'Parent')
99
.assert.containsText('.view', 'default')
@@ -70,6 +70,13 @@ module.exports = {
7070
return (zapId === '2')
7171
}, null, 'relative params')
7272

73+
.click('li:nth-child(10) a')
74+
.assert.urlEquals('http://localhost:8080/nested-routes/parent/qux/1/quux')
75+
.click('li:nth-child(11) a')
76+
.assert.urlEquals('http://localhost:8080/nested-routes/parent/qux/2/quux')
77+
.click('.nested-child a')
78+
.assert.urlEquals('http://localhost:8080/nested-routes/parent/qux/2/quuy')
79+
7380
// check initial visit
7481
.url('http://localhost:8080/nested-routes/parent/foo')
7582
.waitForElementVisible('#app', 1000)

0 commit comments

Comments
 (0)