File tree 3 files changed +592
-7
lines changed
3 files changed +592
-7
lines changed Original file line number Diff line number Diff line change
1
+ /* global Vue */
2
+
1
3
var apiURL = 'https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha='
2
4
3
5
/**
4
6
* Actual demo
5
7
*/
6
8
7
- var demo = new Vue ( {
9
+ new Vue ( {
8
10
9
11
el : '#demo' ,
10
12
@@ -34,14 +36,21 @@ var demo = new Vue({
34
36
35
37
methods : {
36
38
fetchData : function ( ) {
37
- var xhr = new XMLHttpRequest ( )
38
39
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 ( )
43
53
}
44
- xhr . send ( )
45
54
}
46
55
}
47
56
} )
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ <h1>Latest Vue.js Commits</h1>
42
42
</ li >
43
43
</ ul >
44
44
</ div >
45
+ < script src ="mock.js "> </ script >
45
46
< script src ="app.js "> </ script >
46
47
</ body >
47
48
</ html >
You can’t perform that action at this time.
0 commit comments