aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPete Bacon Darwin2013-10-10 09:11:21 +0100
committerIgor Minar2013-10-10 11:58:15 -0700
commit07272608d8ae39a5dd220cdb5637b1439342d5c3 (patch)
tree7f0140b96fac88eee30cf94e01a9589cd25c8b37 /test
parentb019a48bb1176f3c9ce29b628a321b6ffe873393 (diff)
downloadangular.js-07272608d8ae39a5dd220cdb5637b1439342d5c3.tar.bz2
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
Diffstat (limited to 'test')
-rw-r--r--test/helpers/matchers.js12
-rw-r--r--test/helpers/privateMocksSpec.js2
-rw-r--r--test/ngMock/angular-mocksSpec.js2
-rw-r--r--test/ngRoute/directive/ngViewSpec.js22
-rw-r--r--test/ngRoute/routeSpec.js24
5 files changed, 31 insertions, 31 deletions
diff --git a/test/helpers/matchers.js b/test/helpers/matchers.js
index 14430b37..c5d7d6cf 100644
--- a/test/helpers/matchers.js
+++ b/test/helpers/matchers.js
@@ -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;
diff --git a/test/helpers/privateMocksSpec.js b/test/helpers/privateMocksSpec.js
index e58a2b75..d5a1e188 100644
--- a/test/helpers/privateMocksSpec.js
+++ b/test/helpers/privateMocksSpec.js
@@ -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);
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js
index 851f7803..80580fb1 100644
--- a/test/ngMock/angular-mocksSpec.js
+++ b/test/ngMock/angular-mocksSpec.js
@@ -160,7 +160,7 @@ describe('ngMock', function() {
describe('$log', function() {
- forEach([true, false], function(debugEnabled) {
+ angular.forEach([true, false], function(debugEnabled) {
describe('debug ' + debugEnabled, function() {
beforeEach(module(function($logProvider) {
$logProvider.debugEnabled(debugEnabled);
diff --git a/test/ngRoute/directive/ngViewSpec.js b/test/ngRoute/directive/ngViewSpec.js
index d38b3ba9..2d74760c 100644
--- a/test/ngRoute/directive/ngViewSpec.js
+++ b/test/ngRoute/directive/ngViewSpec.js
@@ -279,7 +279,7 @@ describe('ngView', function() {
it('should be async even if served from cache', function() {
module(function($routeProvider) {
- $routeProvider.when('/foo', {controller: noop, templateUrl: 'myUrl1'});
+ $routeProvider.when('/foo', {controller: angular.noop, templateUrl: 'myUrl1'});
});
inject(function($route, $rootScope, $location, $templateCache) {
@@ -498,16 +498,16 @@ describe('ngView', function() {
$location.url('/foo');
$rootScope.$digest();
- forEach(element.contents(), function(node) {
+ angular.forEach(element.contents(), function(node) {
if(node.nodeType == 3 /* text node */) {
- expect(jqLite(node).scope()).not.toBe($route.current.scope);
- expect(jqLite(node).controller()).not.toBeDefined();
+ expect(angular.element(node).scope()).not.toBe($route.current.scope);
+ expect(angular.element(node).controller()).not.toBeDefined();
} else if(node.nodeType == 8 /* comment node */) {
- expect(jqLite(node).scope()).toBe(element.scope());
- expect(jqLite(node).controller()).toBe(element.controller());
+ expect(angular.element(node).scope()).toBe(element.scope());
+ expect(angular.element(node).controller()).toBe(element.controller());
} else {
- expect(jqLite(node).scope()).toBe($route.current.scope);
- expect(jqLite(node).controller()).toBeDefined();
+ expect(angular.element(node).scope()).toBe($route.current.scope);
+ expect(angular.element(node).controller()).toBeDefined();
}
});
});
@@ -530,7 +530,7 @@ describe('ngView animations', function() {
// we need to run animation on attached elements;
return function(_$rootElement_) {
$rootElement = _$rootElement_;
- body = jqLite(document.body);
+ body = angular.element(document.body);
};
}));
@@ -541,8 +541,8 @@ describe('ngView animations', function() {
beforeEach(module(function($provide, $routeProvider) {
- $routeProvider.when('/foo', {controller: noop, templateUrl: '/foo.html'});
- $routeProvider.when('/bar', {controller: noop, templateUrl: '/bar.html'});
+ $routeProvider.when('/foo', {controller: angular.noop, templateUrl: '/foo.html'});
+ $routeProvider.when('/bar', {controller: angular.noop, templateUrl: '/bar.html'});
return function($templateCache) {
$templateCache.put('/foo.html', [200, '<div>data</div>', {}]);
$templateCache.put('/bar.html', [200, '<div>data2</div>', {}]);
diff --git a/test/ngRoute/routeSpec.js b/test/ngRoute/routeSpec.js
index bd7966e1..de7ccb8d 100644
--- a/test/ngRoute/routeSpec.js
+++ b/test/ngRoute/routeSpec.js
@@ -25,7 +25,7 @@ describe('$route', function() {
module(function($routeProvider) {
$routeProvider.when('/Book/:book/Chapter/:chapter',
- {controller: noop, templateUrl: 'Chapter.html'});
+ {controller: angular.noop, templateUrl: 'Chapter.html'});
$routeProvider.when('/Blank', {});
});
inject(function($route, $location, $rootScope) {
@@ -69,9 +69,9 @@ describe('$route', function() {
module(function($routeProvider) {
$routeProvider.when('/Book1/:book/Chapter/:chapter/:highlight*/edit',
- {controller: noop, templateUrl: 'Chapter.html'});
+ {controller: angular.noop, templateUrl: 'Chapter.html'});
$routeProvider.when('/Book2/:book/:highlight*/Chapter/:chapter',
- {controller: noop, templateUrl: 'Chapter.html'});
+ {controller: angular.noop, templateUrl: 'Chapter.html'});
$routeProvider.when('/Blank', {});
});
inject(function($route, $location, $rootScope) {
@@ -128,9 +128,9 @@ describe('$route', function() {
module(function($routeProvider) {
$routeProvider.when('/Book1/:book/Chapter/:chapter/:highlight*/edit',
- {controller: noop, templateUrl: 'Chapter.html', caseInsensitiveMatch: true});
+ {controller: angular.noop, templateUrl: 'Chapter.html', caseInsensitiveMatch: true});
$routeProvider.when('/Book2/:book/:highlight*/Chapter/:chapter',
- {controller: noop, templateUrl: 'Chapter.html'});
+ {controller: angular.noop, templateUrl: 'Chapter.html'});
$routeProvider.when('/Blank', {});
});
inject(function($route, $location, $rootScope) {
@@ -618,8 +618,8 @@ describe('$route', function() {
inject(function($route, $httpBackend, $location, $rootScope, $routeParams) {
var log = '';
- $rootScope.$on('$routeChangeStart', function(e, next) { log += '$before' + toJson($routeParams) + ';'});
- $rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after' + toJson($routeParams) + ';'});
+ $rootScope.$on('$routeChangeStart', function(e, next) { log += '$before' + angular.toJson($routeParams) + ';'});
+ $rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after' + angular.toJson($routeParams) + ';'});
$httpBackend.whenGET('r1.html').respond('R1');
$httpBackend.whenGET('r2.html').respond('R2');
@@ -876,7 +876,7 @@ describe('$route', function() {
var reloaded = jasmine.createSpy('route reload');
module(function($routeProvider) {
- $routeProvider.when('/foo', {controller: noop});
+ $routeProvider.when('/foo', {controller: angular.noop});
});
inject(function($route, $location, $rootScope, $routeParams) {
@@ -901,7 +901,7 @@ describe('$route', function() {
routeUpdate = jasmine.createSpy('route update');
module(function($routeProvider) {
- $routeProvider.when('/foo', {controller: noop, reloadOnSearch: false});
+ $routeProvider.when('/foo', {controller: angular.noop, reloadOnSearch: false});
});
inject(function($route, $location, $rootScope) {
@@ -931,7 +931,7 @@ describe('$route', function() {
var routeChange = jasmine.createSpy('route change');
module(function($routeProvider) {
- $routeProvider.when('/foo/:fooId', {controller: noop, reloadOnSearch: false});
+ $routeProvider.when('/foo/:fooId', {controller: angular.noop, reloadOnSearch: false});
});
inject(function($route, $location, $rootScope) {
@@ -963,8 +963,8 @@ describe('$route', function() {
var routeParamsWatcher = jasmine.createSpy('routeParamsWatcher');
module(function($routeProvider) {
- $routeProvider.when('/foo', {controller: noop});
- $routeProvider.when('/bar/:barId', {controller: noop, reloadOnSearch: false});
+ $routeProvider.when('/foo', {controller: angular.noop});
+ $routeProvider.when('/bar/:barId', {controller: angular.noop, reloadOnSearch: false});
});
inject(function($route, $location, $rootScope, $routeParams) {