From 938555d5671d7a5f9e125106f84f99becbae98ba Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 28 Mar 2019 17:50:05 +0100 Subject: [PATCH] test(nested-routes): add e2e test for implicit params --- examples/nested-routes/app.js | 20 ++++++++++++++++---- test/e2e/specs/nested-routes.js | 9 ++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/nested-routes/app.js b/examples/nested-routes/app.js index 420389275c..1d3b011ac0 100644 --- a/examples/nested-routes/app.js +++ b/examples/nested-routes/app.js @@ -36,15 +36,22 @@ const Quy = { ` } -const Quux = { template: '
quux
' } -const Zap = { template: '

zap

{{ $route.params.zapId }}
' } +const Quux = { + template: `
quuxgo to quuy
` +} +const Quuy = { template: '
quuy
' } +const Zap = { + template: '

zap

{{ $route.params.zapId }}
' +} 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 @@ -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 }, @@ -91,6 +101,8 @@ new Vue({
  • /parent/zap
  • /parent/zap/1
  • { params: { zapId: 2 }} (relative params)
  • +
  • /parent/qux/1/quux
  • +
  • /parent/qux/2/quux
  • diff --git a/test/e2e/specs/nested-routes.js b/test/e2e/specs/nested-routes.js index 1e4063aab9..21726c769b 100644 --- a/test/e2e/specs/nested-routes.js +++ b/test/e2e/specs/nested-routes.js @@ -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') @@ -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)