Skip to content

Commit 64d58a5

Browse files
committed
refactor(mocks): simplify the implementation
1 parent 3bf4390 commit 64d58a5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/ngMock/angular-mocks.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -2125,7 +2125,7 @@ if(window.jasmine || window.mocha) {
21252125
window.inject = angular.mock.inject = function() {
21262126
var blockFns = Array.prototype.slice.call(arguments, 0);
21272127
var errorForStack = new Error('Declaration Location');
2128-
return isSpecRunning() ? workFn.call(currentSpec) : workFn;
2128+
return isSpecRunning() ? workFn() : workFn;
21292129
/////////////////////
21302130
function workFn() {
21312131
var modules = currentSpec.$modules || [];
@@ -2138,9 +2138,8 @@ if(window.jasmine || window.mocha) {
21382138
}
21392139
for(var i = 0, ii = blockFns.length; i < ii; i++) {
21402140
try {
2141-
/* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */
2142-
injector.invoke(blockFns[i] || angular.noop, this);
2143-
/* jshint +W040 */
2141+
// jasmine sets this to be the current spec, so we are mimicing that
2142+
injector.invoke(blockFns[i] || angular.noop, currentSpec);
21442143
} catch (e) {
21452144
if (e.stack && errorForStack) {
21462145
throw new ErrorAddingDeclarationLocationStack(e, errorForStack);

0 commit comments

Comments
 (0)