Skip to content

Commit

Permalink
Added repro test for vuejs#1695.
Browse files Browse the repository at this point in the history
  • Loading branch information
lbogdan committed Aug 25, 2017
1 parent 8104236 commit 8920c30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion examples/route-props/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ function dynamicPropsFn (route) {
}
}

const Child = {
name: 'child',
props: { name: { default: 'name' }},
template: `<div><h2 class="hello">Hello {{ name }}</h2></div>`
}

const Parent = {
name: 'parent',
components: { Child },
template: `<child v-bind="$attrs"></child>`
}

const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: [
{ path: '/', component: Hello }, // No props, no nothing
{ path: '/hello/:name', component: Hello, props: true }, // Pass route.params to props
{ path: '/static', component: Hello, props: { name: 'world' }}, // static values
{ path: '/dynamic/:years', component: Hello, props: dynamicPropsFn } // custom logic for mapping between route and props
{ path: '/dynamic/:years', component: Hello, props: dynamicPropsFn }, // custom logic for mapping between route and props
{ path: '/attrs', component: Parent, props: { name: 'attrs' }}
]
})

Expand All @@ -32,6 +45,7 @@ new Vue({
<li><router-link to="/hello/you">/hello/you</router-link></li>
<li><router-link to="/static">/static</router-link></li>
<li><router-link to="/dynamic/1">/dynamic/1</router-link></li>
<li><router-link to="/attrs">/attrs</router-link></li>
</ul>
<router-view class="view"></router-view>
</div>
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/specs/route-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
browser
.url('http://localhost:8080/route-props/')
.waitForElementVisible('#app', 1000)
.assert.count('li a', 4)
.assert.count('li a', 5)

.assert.urlEquals('http://localhost:8080/route-props/')
.assert.containsText('.hello', 'Hello Vue!')
Expand All @@ -20,6 +20,10 @@ module.exports = {
.assert.urlEquals('http://localhost:8080/route-props/dynamic/1')
.assert.containsText('.hello', 'Hello ' + ((new Date()).getFullYear() + 1)+ '!')

.click('li:nth-child(5) a')
.assert.urlEquals('http://localhost:8080/route-props/attrs')
.assert.containsText('.hello', 'Hello attrs')

.end()
}
}

0 comments on commit 8920c30

Please sign in to comment.