Skip to content

Commit

Permalink
test(nested-routes): add e2e test for implicit params
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 28, 2019
1 parent d5129a3 commit 938555d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
20 changes: 16 additions & 4 deletions examples/nested-routes/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ const Quy = {
</div>
`
}
const Quux = { template: '<div>quux</div>' }
const Zap = { template: '<div><h3>zap</h3><pre>{{ $route.params.zapId }}</pre></div>' }
const Quux = {
template: `<div>quux<router-link :to="{ name: 'quuy' }">go to quuy</router-link></div>`
}
const Quuy = { template: '<div>quuy</div>' }
const Zap = {
template: '<div><h3>zap</h3><pre>{{ $route.params.zapId }}</pre></div>'
}

const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: [
{ path: '/', redirect: '/parent' },
{ path: '/parent', component: Parent,
{
path: '/parent',
component: Parent,
children: [
// an empty path will be treated as the default, e.g.
// components rendered at /parent: Root -> Parent -> Default
Expand All @@ -65,7 +72,10 @@ const router = new VueRouter({
{
path: 'qux/:quxId',
component: Qux,
children: [{ path: 'quux', name: 'quux', component: Quux }]
children: [
{ path: 'quux', name: 'quux', component: Quux },
{ path: 'quuy', name: 'quuy', component: Quuy }
]
},

{ path: 'quy/:quyId', component: Quy },
Expand All @@ -91,6 +101,8 @@ new Vue({
<li><router-link :to="{name: 'zap'}">/parent/zap</router-link></li>
<li><router-link :to="{name: 'zap', params: {zapId: 1}}">/parent/zap/1</router-link></li>
<li><router-link :to="{ params: { zapId: 2 }}">{ params: { zapId: 2 }} (relative params)</router-link></li>
<li><router-link to="/parent/qux/1/quux">/parent/qux/1/quux</router-link></li>
<li><router-link to="/parent/qux/2/quux">/parent/qux/2/quux</router-link></li>
</ul>
<router-view class="view"></router-view>
</div>
Expand Down
9 changes: 8 additions & 1 deletion test/e2e/specs/nested-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
browser
.url('http://localhost:8080/nested-routes/')
.waitForElementVisible('#app', 1000)
.assert.count('li a', 9)
.assert.count('li a', 11)
.assert.urlEquals('http://localhost:8080/nested-routes/parent')
.assert.containsText('.view', 'Parent')
.assert.containsText('.view', 'default')
Expand Down Expand Up @@ -70,6 +70,13 @@ module.exports = {
return (zapId === '2')
}, null, 'relative params')

.click('li:nth-child(10) a')
.assert.urlEquals('http://localhost:8080/nested-routes/parent/qux/1/quux')
.click('li:nth-child(11) a')
.assert.urlEquals('http://localhost:8080/nested-routes/parent/qux/2/quux')
.click('.nested-child a')
.assert.urlEquals('http://localhost:8080/nested-routes/parent/qux/2/quuy')

// check initial visit
.url('http://localhost:8080/nested-routes/parent/foo')
.waitForElementVisible('#app', 1000)
Expand Down

0 comments on commit 938555d

Please sign in to comment.