mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-28 21:05:43 +08:00
fix(modules): stop leaking global variables in tests
The routeUtils.js file was declaring a number of functions that were leaking into other modules such as ngMocks causing tests to pass incorrectly. Closes #4360
This commit is contained in:
committed by
Igor Minar
parent
b019a48bb1
commit
07272608d8
@@ -74,11 +74,11 @@ beforeEach(function() {
|
||||
this.message = function() {
|
||||
var expected;
|
||||
if (this.actual.message && this.actual.name == 'Error') {
|
||||
expected = toJson(this.actual.message);
|
||||
expected = angular.toJson(this.actual.message);
|
||||
} else {
|
||||
expected = toJson(this.actual);
|
||||
expected = angular.toJson(this.actual);
|
||||
}
|
||||
return "Expected " + expected + " to be an Error with message " + toJson(message);
|
||||
return "Expected " + expected + " to be an Error with message " + angular.toJson(message);
|
||||
};
|
||||
return this.actual.name == 'Error' && this.actual.message == message;
|
||||
},
|
||||
@@ -187,9 +187,9 @@ beforeEach(function() {
|
||||
codeRegex = new RegExp('^\\[' + escapeRegexp(namespace) + ':' + escapeRegexp(code) + '\\]'),
|
||||
not = this.isNot ? "not " : "",
|
||||
regex = jasmine.isA_("RegExp", content) ? content :
|
||||
isDefined(content) ? new RegExp(escapeRegexp(content)) : undefined;
|
||||
angular.isDefined(content) ? new RegExp(escapeRegexp(content)) : undefined;
|
||||
|
||||
if(!isFunction(this.actual)) {
|
||||
if(!angular.isFunction(this.actual)) {
|
||||
throw new Error('Actual is not a function');
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ beforeEach(function() {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (isDefined(regex)) {
|
||||
if (angular.isDefined(regex)) {
|
||||
return regex.test(exceptionMessage);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('private mocks', function() {
|
||||
var stylesheet = createMockStyleSheet($document, $window);
|
||||
expect(doc.styleSheets.length).toBe(count + 1);
|
||||
|
||||
jqLite(doc.body).append($rootElement);
|
||||
angular.element(doc.body).append($rootElement);
|
||||
|
||||
var elm = $compile('<div class="padded">...</div>')($rootScope);
|
||||
$rootElement.append(elm);
|
||||
|
||||
Reference in New Issue
Block a user