File tree 5 files changed +24
-19
lines changed
5 files changed +24
-19
lines changed Original file line number Diff line number Diff line change 14
14
"angular" : " 1.*"
15
15
},
16
16
"devDependencies" : {
17
- "angular-mocks" : " ~1.*" ,
18
- "jquery" : " ~2.1.3"
17
+ "angular-mocks" : " ~1.*"
19
18
}
20
19
}
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ module.exports = function (config) {
15
15
16
16
// list of files / patterns to load in the browser
17
17
files : [
18
- 'bower_components/jquery/dist/jquery.min.js' ,
19
18
'bower_components/angular/angular.js' ,
20
19
21
20
'bower_components/angular-mocks/angular-mocks.js' ,
Original file line number Diff line number Diff line change 135
135
callback ( ) ;
136
136
} else {
137
137
// Generate link on demand
138
- var script = $document . get ( 0 ) . createElement ( 'script' ) ;
138
+ var script = $window . document . createElement ( 'script' ) ;
139
139
script . async = true ;
140
140
script . defer = true ;
141
141
script . src = 'https://www.google.com/recaptcha/api.js?onload=' + provider . onLoadFunctionName + '&render=explicit' ;
142
- $document . get ( 0 ) . body . appendChild ( script ) ;
142
+ $document . find ( 'body' ) . append ( script ) ;
143
143
}
144
144
145
145
return {
Original file line number Diff line number Diff line change @@ -20,7 +20,12 @@ function ServiceDriver() {
20
20
return _this ;
21
21
} ,
22
22
mockDocument : function ( mockDocument ) {
23
- mockModules . $document . get = mockDocument . get ;
23
+ mockModules . $document . find = mockDocument . find ;
24
+
25
+ return _this ;
26
+ } ,
27
+ mockWindow : function ( mockWindow ) {
28
+ mockModules . $window . document = mockWindow . document ;
24
29
25
30
return _this ;
26
31
}
Original file line number Diff line number Diff line change @@ -83,35 +83,37 @@ describe('service', function () {
83
83
84
84
describe ( 'without loaded api' , function ( ) {
85
85
var scriptTagSpy ,
86
- appendChildSpy ,
86
+ appendSpy ,
87
87
funcName ;
88
88
89
89
beforeEach ( function ( ) {
90
90
scriptTagSpy = jasmine . createSpy ( 'scriptTagSpy' ) ;
91
- appendChildSpy = jasmine . createSpy ( 'appendChildSpy ' ) ;
91
+ appendSpy = jasmine . createSpy ( 'appendSpy ' ) ;
92
92
93
93
driver
94
94
. given . onLoadFunctionName ( funcName = 'my-func' )
95
95
. given . mockDocument ( {
96
- get : function ( ) {
97
- return {
98
- createElement : function ( ) {
99
- return scriptTagSpy ;
100
- } ,
101
- body : {
102
- appendChild : appendChildSpy
103
- }
104
- } ;
96
+ find : function ( ) {
97
+ return {
98
+ append : appendSpy
99
+ } ;
100
+ }
101
+ } )
102
+ . given . mockWindow ( {
103
+ document : {
104
+ createElement : function ( ) {
105
+ return scriptTagSpy ;
105
106
}
106
- } )
107
+ }
108
+ } )
107
109
. when . created ( ) ;
108
110
109
111
} ) ;
110
112
111
113
it ( 'should add script tag to body' , function ( ) {
112
114
expect ( scriptTagSpy . async ) . toBe ( true ) ;
113
115
expect ( scriptTagSpy . defer ) . toBe ( true ) ;
114
- expect ( appendChildSpy ) . toHaveBeenCalledWith ( scriptTagSpy ) ;
116
+ expect ( appendSpy ) . toHaveBeenCalledWith ( scriptTagSpy ) ;
115
117
} ) ;
116
118
117
119
it ( 'should add callback function name to src' , function ( ) {
You can’t perform that action at this time.
0 commit comments