test(e2e): use better mocking strategy for commits example

This commit is contained in:
Evan You
2019-12-11 10:15:52 -05:00
parent f48a4f71a7
commit c202bd6ac0
5 changed files with 37 additions and 27 deletions

View File

@@ -1,5 +1,4 @@
<script src="../../dist/vue.global.js"></script>
<script src="../mocks/commits.js"></script>
<div id="demo">
<h1>Latest Vue.js Commits</h1>
@@ -42,18 +41,11 @@ const App = {
methods: {
fetchData() {
if (window.location.hash === '#test') {
// use mocks in e2e to avoid dependency on network / authentication
setTimeout(() => {
this.commits = window.MOCKS[this.currentBranch]
}, 0)
} else {
fetch(`${API_URL}${this.currentBranch}`)
.then(res => res.json())
.then(data => {
this.commits = data
})
}
fetch(`${API_URL}${this.currentBranch}`)
.then(res => res.json())
.then(data => {
this.commits = data
})
},
truncate(v) {
const newline = v.indexOf('\n')