Skip to content

Commit

Permalink
test: add e2e test for onSuccess callback
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Apr 17, 2019
1 parent 4fbcd5e commit dd655ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/basic/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const router = new VueRouter({
// Route components will be rendered inside <router-view>.
new Vue({
router,
data: () => ({ n: 0 }),
template: `
<div id="app">
<h1>Basic</h1>
Expand All @@ -43,9 +44,22 @@ new Vue({
<li><router-link to="/é?t=%25ñ">/é?t=%ñ</router-link></li>
<li><router-link to="/é#%25ñ">/é#%25ñ</router-link></li>
</ul>
<button id="navigate-btn" @click="navigateAndIncrement">On Success</button>
<pre id="counter">{{ n }}</pre>
<pre id="query-t">{{ $route.query.t }}</pre>
<pre id="hash">{{ $route.hash }}</pre>
<router-view class="view"></router-view>
</div>
`
`,

methods: {
navigateAndIncrement () {
const increment = () => this.n++
if (this.$route.path === '/') {
this.$router.push('/foo', increment)
} else {
this.$router.push('/', increment)
}
}
}
}).$mount('#app')
9 changes: 9 additions & 0 deletions test/e2e/specs/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ module.exports = {
.url('http://localhost:8080/basic/%C3%A9')
.waitForElementVisible('#app', 1000)
.assert.containsText('.view', 'unicode')

// regression onComplete
// https://github.com/vuejs/vue-router/issues/2721
.assert.containsText('#counter', '0')
.click('#navigate-btn')
.assert.containsText('#counter', '1')
.click('#navigate-btn')
.assert.containsText('#counter', '2')

.end()
}
}

0 comments on commit dd655ff

Please sign in to comment.