Skip to content

Commit 4276c0c

Browse files
committed
Removed jQuery dependency
1 parent 98dabbd commit 4276c0c

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

bower.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"angular": "1.*"
1515
},
1616
"devDependencies": {
17-
"angular-mocks": "~1.*",
18-
"jquery": "~2.1.3"
17+
"angular-mocks": "~1.*"
1918
}
2019
}

karma.conf.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = function (config) {
1515

1616
// list of files / patterns to load in the browser
1717
files: [
18-
'bower_components/jquery/dist/jquery.min.js',
1918
'bower_components/angular/angular.js',
2019

2120
'bower_components/angular-mocks/angular-mocks.js',

src/service.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@
135135
callback();
136136
} else {
137137
// Generate link on demand
138-
var script = $document.get(0).createElement('script');
138+
var script = $window.document.createElement('script');
139139
script.async = true;
140140
script.defer = true;
141141
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);
143143
}
144144

145145
return {

tests/service.driver.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ function ServiceDriver() {
2020
return _this;
2121
},
2222
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;
2429

2530
return _this;
2631
}

tests/service_test.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,37 @@ describe('service', function () {
8383

8484
describe('without loaded api', function () {
8585
var scriptTagSpy,
86-
appendChildSpy,
86+
appendSpy,
8787
funcName;
8888

8989
beforeEach(function () {
9090
scriptTagSpy = jasmine.createSpy('scriptTagSpy');
91-
appendChildSpy = jasmine.createSpy('appendChildSpy');
91+
appendSpy = jasmine.createSpy('appendSpy');
9292

9393
driver
9494
.given.onLoadFunctionName(funcName = 'my-func')
9595
.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;
105106
}
106-
})
107+
}
108+
})
107109
.when.created();
108110

109111
});
110112

111113
it('should add script tag to body', function () {
112114
expect(scriptTagSpy.async).toBe(true);
113115
expect(scriptTagSpy.defer).toBe(true);
114-
expect(appendChildSpy).toHaveBeenCalledWith(scriptTagSpy);
116+
expect(appendSpy).toHaveBeenCalledWith(scriptTagSpy);
115117
});
116118

117119
it('should add callback function name to src', function () {

0 commit comments

Comments
 (0)