Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4c6d26a

Browse files
committed
fix(strict mode): fix all issues discovered by strict mode and unit/e2e tests
1 parent c43ce91 commit 4c6d26a

File tree

8 files changed

+24
-27
lines changed

8 files changed

+24
-27
lines changed

src/Angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ var _undefined = undefined,
115115
angularCallbacks = extensionMap(angular, 'callbacks'),
116116
nodeName_,
117117
rngScript = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/,
118-
uid = ['0', '0', '0'];
118+
uid = ['0', '0', '0'],
119119
DATE_ISOSTRING_LN = 24;
120120

121121
/**

src/angular-mocks.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,16 @@ function TzDate(offset, timestamp) {
523523
};
524524

525525
//hide all methods not implemented in this mock that the Date prototype exposes
526-
var unimplementedMethods = ['getMilliseconds', 'getTime', 'getUTCDay',
526+
var self = this,
527+
unimplementedMethods = ['getMilliseconds', 'getUTCDay',
527528
'getUTCMilliseconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
528529
'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear',
529530
'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds',
530531
'setYear', 'toDateString', 'toJSON', 'toGMTString', 'toLocaleFormat', 'toLocaleString',
531532
'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
532533

533534
angular.forEach(unimplementedMethods, function(methodName) {
534-
this[methodName] = function() {
535+
self[methodName] = function() {
535536
throw {
536537
name: "MethodNotImplemented",
537538
message: "Method '" + methodName + "' is not implemented in the TzDate mock"

src/filters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ angularFilter.number = function(number, fractionSize){
114114
pow = Math.pow(10, fractionSize),
115115
whole = '' + number,
116116
formatedText = '',
117-
i;
117+
i, fraction;
118118

119119
if (whole.indexOf('e') > -1) return whole;
120120

src/parser.js

-2
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,9 @@ function parser(text, json){
290290
var token = peek(e1, e2, e3, e4);
291291
if (token) {
292292
if (json && !token.json) {
293-
index = token.index;
294293
throwError("is not valid json", token);
295294
}
296295
tokens.shift();
297-
this.currentToken = token;
298296
return token;
299297
}
300298
return false;

test/scenario/output/HtmlSpec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
describe('angular.scenario.output.html', function() {
2-
var runner, model, spec, listeners;
3-
var ui, context;
2+
var runner, model, spec, step, listeners, ui, context;
43

54
beforeEach(function() {
65
listeners = [];

test/service/deferSpec.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,31 @@ describe('$defer', function() {
4040

4141

4242
it('should call eval after each callback is executed', function() {
43-
var eval = this.spyOn(scope, '$eval').andCallThrough();
43+
var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
4444

4545
$defer(function() {});
46-
expect(eval).not.toHaveBeenCalled();
46+
expect(evalSpy).not.toHaveBeenCalled();
4747

4848
$browser.defer.flush();
49-
expect(eval).toHaveBeenCalled();
49+
expect(evalSpy).toHaveBeenCalled();
5050

51-
eval.reset(); //reset the spy;
51+
evalSpy.reset(); //reset the spy;
5252

5353
$defer(function() {});
5454
$defer(function() {});
5555
$browser.defer.flush();
56-
expect(eval.callCount).toBe(2);
56+
expect(evalSpy.callCount).toBe(2);
5757
});
5858

5959

6060
it('should call eval even if an exception is thrown in callback', function() {
61-
var eval = this.spyOn(scope, '$eval').andCallThrough();
61+
var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
6262

6363
$defer(function() {throw "Test Error";});
64-
expect(eval).not.toHaveBeenCalled();
64+
expect(evalSpy).not.toHaveBeenCalled();
6565

6666
$browser.defer.flush();
67-
expect(eval).toHaveBeenCalled();
67+
expect(evalSpy).toHaveBeenCalled();
6868
});
6969

7070
it('should allow you to specify the delay time', function(){

test/service/xhr.cacheSpec.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,21 @@ describe('$xhr.cache', function() {
124124

125125

126126
it('should call eval after callbacks for both cache hit and cache miss execute', function() {
127-
var eval = this.spyOn(scope, '$eval').andCallThrough();
127+
var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
128128

129129
$browserXhr.expectGET('/url').respond('+');
130130
cache('GET', '/url', null, callback);
131-
expect(eval).not.toHaveBeenCalled();
131+
expect(evalSpy).not.toHaveBeenCalled();
132132

133133
$browserXhr.flush();
134-
expect(eval).toHaveBeenCalled();
134+
expect(evalSpy).toHaveBeenCalled();
135135

136-
eval.reset(); //reset the spy
136+
evalSpy.reset(); //reset the spy
137137

138138
cache('GET', '/url', null, callback);
139-
expect(eval).not.toHaveBeenCalled();
139+
expect(evalSpy).not.toHaveBeenCalled();
140140

141141
$browser.defer.flush();
142-
expect(eval).toHaveBeenCalled();
142+
expect(evalSpy).toHaveBeenCalled();
143143
});
144144
});

test/testabilityPatch.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _jQuery.event.special.change = undefined;
88

99

1010
if (window.jstestdriver) {
11-
jstd = jstestdriver;
11+
window.jstd = jstestdriver;
1212
window.dump = function(){
1313
var args = [];
1414
forEach(arguments, function(arg){
@@ -175,8 +175,7 @@ extend(angular, {
175175
'isFunction': isFunction,
176176
'isObject': isObject,
177177
'isNumber': isNumber,
178-
'isArray': isArray,
179-
'forEach': forEach
178+
'isArray': isArray
180179
});
181180

182181

@@ -317,8 +316,8 @@ function assertThrows(error, fn){
317316
assertEquals(error, exception);
318317
}
319318

320-
log = noop;
321-
error = noop;
319+
window.log = noop;
320+
window.error = noop;
322321

323322
function rethrow(e) {
324323
if(e) {

0 commit comments

Comments
 (0)