mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-10 15:54:42 +00:00
fix(strict mode): fix all issues discovered by strict mode and unit/e2e tests
This commit is contained in:
parent
c43ce91b25
commit
4c6d26a38f
8 changed files with 24 additions and 27 deletions
|
|
@ -115,7 +115,7 @@ var _undefined = undefined,
|
||||||
angularCallbacks = extensionMap(angular, 'callbacks'),
|
angularCallbacks = extensionMap(angular, 'callbacks'),
|
||||||
nodeName_,
|
nodeName_,
|
||||||
rngScript = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/,
|
rngScript = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/,
|
||||||
uid = ['0', '0', '0'];
|
uid = ['0', '0', '0'],
|
||||||
DATE_ISOSTRING_LN = 24;
|
DATE_ISOSTRING_LN = 24;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
5
src/angular-mocks.js
vendored
5
src/angular-mocks.js
vendored
|
|
@ -523,7 +523,8 @@ function TzDate(offset, timestamp) {
|
||||||
};
|
};
|
||||||
|
|
||||||
//hide all methods not implemented in this mock that the Date prototype exposes
|
//hide all methods not implemented in this mock that the Date prototype exposes
|
||||||
var unimplementedMethods = ['getMilliseconds', 'getTime', 'getUTCDay',
|
var self = this,
|
||||||
|
unimplementedMethods = ['getMilliseconds', 'getUTCDay',
|
||||||
'getUTCMilliseconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
|
'getUTCMilliseconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
|
||||||
'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear',
|
'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear',
|
||||||
'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds',
|
'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds',
|
||||||
|
|
@ -531,7 +532,7 @@ function TzDate(offset, timestamp) {
|
||||||
'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
|
'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
|
||||||
|
|
||||||
angular.forEach(unimplementedMethods, function(methodName) {
|
angular.forEach(unimplementedMethods, function(methodName) {
|
||||||
this[methodName] = function() {
|
self[methodName] = function() {
|
||||||
throw {
|
throw {
|
||||||
name: "MethodNotImplemented",
|
name: "MethodNotImplemented",
|
||||||
message: "Method '" + methodName + "' is not implemented in the TzDate mock"
|
message: "Method '" + methodName + "' is not implemented in the TzDate mock"
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ angularFilter.number = function(number, fractionSize){
|
||||||
pow = Math.pow(10, fractionSize),
|
pow = Math.pow(10, fractionSize),
|
||||||
whole = '' + number,
|
whole = '' + number,
|
||||||
formatedText = '',
|
formatedText = '',
|
||||||
i;
|
i, fraction;
|
||||||
|
|
||||||
if (whole.indexOf('e') > -1) return whole;
|
if (whole.indexOf('e') > -1) return whole;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,11 +290,9 @@ function parser(text, json){
|
||||||
var token = peek(e1, e2, e3, e4);
|
var token = peek(e1, e2, e3, e4);
|
||||||
if (token) {
|
if (token) {
|
||||||
if (json && !token.json) {
|
if (json && !token.json) {
|
||||||
index = token.index;
|
|
||||||
throwError("is not valid json", token);
|
throwError("is not valid json", token);
|
||||||
}
|
}
|
||||||
tokens.shift();
|
tokens.shift();
|
||||||
this.currentToken = token;
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
describe('angular.scenario.output.html', function() {
|
describe('angular.scenario.output.html', function() {
|
||||||
var runner, model, spec, listeners;
|
var runner, model, spec, step, listeners, ui, context;
|
||||||
var ui, context;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
listeners = [];
|
listeners = [];
|
||||||
|
|
|
||||||
|
|
@ -40,31 +40,31 @@ describe('$defer', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should call eval after each callback is executed', function() {
|
it('should call eval after each callback is executed', function() {
|
||||||
var eval = this.spyOn(scope, '$eval').andCallThrough();
|
var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
|
||||||
|
|
||||||
$defer(function() {});
|
$defer(function() {});
|
||||||
expect(eval).not.toHaveBeenCalled();
|
expect(evalSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
$browser.defer.flush();
|
$browser.defer.flush();
|
||||||
expect(eval).toHaveBeenCalled();
|
expect(evalSpy).toHaveBeenCalled();
|
||||||
|
|
||||||
eval.reset(); //reset the spy;
|
evalSpy.reset(); //reset the spy;
|
||||||
|
|
||||||
$defer(function() {});
|
$defer(function() {});
|
||||||
$defer(function() {});
|
$defer(function() {});
|
||||||
$browser.defer.flush();
|
$browser.defer.flush();
|
||||||
expect(eval.callCount).toBe(2);
|
expect(evalSpy.callCount).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call eval even if an exception is thrown in callback', function() {
|
it('should call eval even if an exception is thrown in callback', function() {
|
||||||
var eval = this.spyOn(scope, '$eval').andCallThrough();
|
var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
|
||||||
|
|
||||||
$defer(function() {throw "Test Error";});
|
$defer(function() {throw "Test Error";});
|
||||||
expect(eval).not.toHaveBeenCalled();
|
expect(evalSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
$browser.defer.flush();
|
$browser.defer.flush();
|
||||||
expect(eval).toHaveBeenCalled();
|
expect(evalSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow you to specify the delay time', function(){
|
it('should allow you to specify the delay time', function(){
|
||||||
|
|
|
||||||
|
|
@ -124,21 +124,21 @@ describe('$xhr.cache', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should call eval after callbacks for both cache hit and cache miss execute', function() {
|
it('should call eval after callbacks for both cache hit and cache miss execute', function() {
|
||||||
var eval = this.spyOn(scope, '$eval').andCallThrough();
|
var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
|
||||||
|
|
||||||
$browserXhr.expectGET('/url').respond('+');
|
$browserXhr.expectGET('/url').respond('+');
|
||||||
cache('GET', '/url', null, callback);
|
cache('GET', '/url', null, callback);
|
||||||
expect(eval).not.toHaveBeenCalled();
|
expect(evalSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
$browserXhr.flush();
|
$browserXhr.flush();
|
||||||
expect(eval).toHaveBeenCalled();
|
expect(evalSpy).toHaveBeenCalled();
|
||||||
|
|
||||||
eval.reset(); //reset the spy
|
evalSpy.reset(); //reset the spy
|
||||||
|
|
||||||
cache('GET', '/url', null, callback);
|
cache('GET', '/url', null, callback);
|
||||||
expect(eval).not.toHaveBeenCalled();
|
expect(evalSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
$browser.defer.flush();
|
$browser.defer.flush();
|
||||||
expect(eval).toHaveBeenCalled();
|
expect(evalSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ _jQuery.event.special.change = undefined;
|
||||||
|
|
||||||
|
|
||||||
if (window.jstestdriver) {
|
if (window.jstestdriver) {
|
||||||
jstd = jstestdriver;
|
window.jstd = jstestdriver;
|
||||||
window.dump = function(){
|
window.dump = function(){
|
||||||
var args = [];
|
var args = [];
|
||||||
forEach(arguments, function(arg){
|
forEach(arguments, function(arg){
|
||||||
|
|
@ -175,8 +175,7 @@ extend(angular, {
|
||||||
'isFunction': isFunction,
|
'isFunction': isFunction,
|
||||||
'isObject': isObject,
|
'isObject': isObject,
|
||||||
'isNumber': isNumber,
|
'isNumber': isNumber,
|
||||||
'isArray': isArray,
|
'isArray': isArray
|
||||||
'forEach': forEach
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -317,8 +316,8 @@ function assertThrows(error, fn){
|
||||||
assertEquals(error, exception);
|
assertEquals(error, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
log = noop;
|
window.log = noop;
|
||||||
error = noop;
|
window.error = noop;
|
||||||
|
|
||||||
function rethrow(e) {
|
function rethrow(e) {
|
||||||
if(e) {
|
if(e) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue