File tree Expand file tree Collapse file tree 3 files changed +592
-7
lines changed Expand file tree Collapse file tree 3 files changed +592
-7
lines changed Original file line number Diff line number Diff line change 1+ /* global Vue */
2+
13var apiURL = 'https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha='
24
35/**
46 * Actual demo
57 */
68
7- var demo = new Vue ( {
9+ new Vue ( {
810
911 el : '#demo' ,
1012
@@ -34,14 +36,21 @@ var demo = new Vue({
3436
3537 methods : {
3638 fetchData : function ( ) {
37- var xhr = new XMLHttpRequest ( )
3839 var self = this
39- xhr . open ( 'GET' , apiURL + self . currentBranch )
40- xhr . onload = function ( ) {
41- self . commits = JSON . parse ( xhr . responseText )
42- console . log ( self . commits [ 0 ] . html_url )
40+ if ( navigator . userAgent . indexOf ( 'PhantomJS' ) > - 1 ) {
41+ // use mocks in e2e to avoid dependency on network / authentication
42+ setTimeout ( function ( ) {
43+ self . commits = window . MOCKS [ self . currentBranch ]
44+ } , 0 )
45+ } else {
46+ var xhr = new XMLHttpRequest ( )
47+ xhr . open ( 'GET' , apiURL + self . currentBranch )
48+ xhr . onload = function ( ) {
49+ self . commits = JSON . parse ( xhr . responseText )
50+ console . log ( self . commits [ 0 ] . html_url )
51+ }
52+ xhr . send ( )
4353 }
44- xhr . send ( )
4554 }
4655 }
4756} )
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ <h1>Latest Vue.js Commits</h1>
4242 </ li >
4343 </ ul >
4444 </ div >
45+ < script src ="mock.js "> </ script >
4546 < script src ="app.js "> </ script >
4647 </ body >
4748</ html >
You can’t perform that action at this time.
0 commit comments