aboutsummaryrefslogtreecommitdiffstats
path: root/test/service
diff options
context:
space:
mode:
authorMisko Hevery2011-11-01 21:09:54 -0700
committerMisko Hevery2011-11-14 16:39:32 -0800
commited36b9da3be338fe9eb36f3eeea901d6f51cd768 (patch)
treeffdc924e4b1fc1c6912674c82e029bf975ca9fca /test/service
parentc925f8a6578e05c8136c206f2fd98eeaaf1c0f16 (diff)
downloadangular.js-ed36b9da3be338fe9eb36f3eeea901d6f51cd768.tar.bz2
refactor(injector): switch to injector 2.0 introduce modules
Diffstat (limited to 'test/service')
-rw-r--r--test/service/compilerSpec.js10
-rw-r--r--test/service/cookiesSpec.js4
-rw-r--r--test/service/deferSpec.js4
-rw-r--r--test/service/exceptionHandlerSpec.js6
-rw-r--r--test/service/locationSpec.js18
-rw-r--r--test/service/logSpec.js8
-rw-r--r--test/service/scopeSpec.js18
-rw-r--r--test/service/xhr.bulkSpec.js10
-rw-r--r--test/service/xhr.cacheSpec.js12
-rw-r--r--test/service/xhr.errorSpec.js8
-rw-r--r--test/service/xhrSpec.js8
11 files changed, 47 insertions, 59 deletions
diff --git a/test/service/compilerSpec.js b/test/service/compilerSpec.js
index 4e0dbed6..ccf70aaf 100644
--- a/test/service/compilerSpec.js
+++ b/test/service/compilerSpec.js
@@ -3,7 +3,7 @@
describe('compiler', function() {
var compiler, textMmarkup, attrMarkup, directives, widgets, compile, log, $rootScope;
- beforeEach(inject(function(service){
+ beforeEach(inject(function($provide){
textMmarkup = [];
attrMarkup = [];
widgets = extensionMap({}, 'widget');
@@ -26,10 +26,10 @@ describe('compiler', function() {
};
log = "";
- service('$textMarkup', valueFn(textMmarkup));
- service('$attrMarkup', valueFn(attrMarkup));
- service('$directive', valueFn(directives));
- service('$widget', valueFn(widgets));
+ $provide.value('$textMarkup', textMmarkup);
+ $provide.value('$attrMarkup', attrMarkup);
+ $provide.value('$directive', directives);
+ $provide.value('$widget', widgets);
}));
diff --git a/test/service/cookiesSpec.js b/test/service/cookiesSpec.js
index 2569645b..66bdc504 100644
--- a/test/service/cookiesSpec.js
+++ b/test/service/cookiesSpec.js
@@ -1,8 +1,8 @@
'use strict';
describe('$cookies', function() {
- beforeEach(inject(function(service) {
- service('$browser', function(){
+ beforeEach(inject(function($provide) {
+ $provide.factory('$browser', function(){
return angular.extend(new MockBrowser(), {cookieHash: {preexisting:'oldCookie'}});
});
}));
diff --git a/test/service/deferSpec.js b/test/service/deferSpec.js
index 98ddeac5..2468512d 100644
--- a/test/service/deferSpec.js
+++ b/test/service/deferSpec.js
@@ -1,8 +1,8 @@
'use strict';
describe('$defer', function() {
- beforeEach(inject(function(service) {
- service('$exceptionHandler', function(){
+ beforeEach(inject(function($provide) {
+ $provide.factory('$exceptionHandler', function(){
return jasmine.createSpy('$exceptionHandler');
});
}));
diff --git a/test/service/exceptionHandlerSpec.js b/test/service/exceptionHandlerSpec.js
index 3bfb70c0..821ad7b8 100644
--- a/test/service/exceptionHandlerSpec.js
+++ b/test/service/exceptionHandlerSpec.js
@@ -4,9 +4,9 @@ describe('$exceptionHandler', function() {
it('should log errors', inject(
- function(service){
- service('$exceptionHandler', $exceptionHandlerFactory);
- service('$log', valueFn($logMock));
+ function($provide){
+ $provide.factory('$exceptionHandler', $exceptionHandlerFactory);
+ $provide.value('$log', $logMock);
},
function($log, $exceptionHandler) {
$log.error.rethrow = false;
diff --git a/test/service/locationSpec.js b/test/service/locationSpec.js
index 38df2619..65ca36a7 100644
--- a/test/service/locationSpec.js
+++ b/test/service/locationSpec.js
@@ -308,13 +308,9 @@ describe('$location', function() {
function initService(html5Mode, hashPrefix, supportHistory) {
- return function(service){
- service('$locationConfig', function(){
- return {html5Mode: html5Mode, hashPrefix: hashPrefix};
- });
- service('$sniffer', function(){
- return {history: supportHistory};
- });
+ return function($provide){
+ $provide.value('$locationConfig', {html5Mode: html5Mode, hashPrefix: hashPrefix});
+ $provide.value('$sniffer', {history: supportHistory});
};
}
function initBrowser(url, basePath) {
@@ -580,7 +576,7 @@ describe('$location', function() {
var root, link, originalBrowser, lastEventPreventDefault;
function configureService(linkHref, html5Mode, supportHist, attrs, content) {
- return function(service){
+ return function($provide){
var jqRoot = jqLite('<div></div>');
attrs = attrs ? ' ' + attrs + ' ' : '';
link = jqLite('<a href="' + linkHref + '"' + attrs + '>' + content + '</a>')[0];
@@ -588,9 +584,9 @@ describe('$location', function() {
jqLite(document.body).append(jqRoot);
- service('$document', function(){ return jqRoot; });
- service('$sniffer', function(){ return {history: supportHist}; });
- service('$locationConfig', function(){ return {html5Mode: html5Mode, hashPrefix: '!'}; });
+ $provide.value('$document', jqRoot);
+ $provide.value('$sniffer', {history: supportHist});
+ $provide.value('$locationConfig', {html5Mode: html5Mode, hashPrefix: '!'});
};
}
diff --git a/test/service/logSpec.js b/test/service/logSpec.js
index 8c56d99e..3b860756 100644
--- a/test/service/logSpec.js
+++ b/test/service/logSpec.js
@@ -9,12 +9,12 @@ describe('$log', function() {
function info() { logger+= 'info;'; }
function error() { logger+= 'error;'; }
- beforeEach(inject(function(service){
+ beforeEach(inject(function($provide){
$window = {};
logger = '';
- service('$log', $logFactory);
- service('$exceptionHandler', valueFn(rethrow));
- service('$window', valueFn($window));
+ $provide.factory('$log', $logFactory);
+ $provide.value('$exceptionHandler', rethrow);
+ $provide.value('$window', $window);
}));
it('should use console if present', inject(
diff --git a/test/service/scopeSpec.js b/test/service/scopeSpec.js
index 2cd2f635..b7f50edb 100644
--- a/test/service/scopeSpec.js
+++ b/test/service/scopeSpec.js
@@ -2,8 +2,8 @@
describe('Scope', function() {
- beforeEach(inject(function(service) {
- service('$exceptionHandler', $exceptionHandlerMockFactory);
+ beforeEach(inject(function($provide) {
+ $provide.factory('$exceptionHandler', $exceptionHandlerMockFactory);
}));
@@ -66,7 +66,7 @@ describe('Scope', function() {
this.callCount = 0;
this.name = name;
}
- Cntl.$inject = ['$browser'];
+ Cntl.$inject = ['$browser', 'name'];
Cntl.prototype = {
myFn: function() {
@@ -75,7 +75,7 @@ describe('Scope', function() {
}
};
- var cntl = $rootScope.$new(Cntl, ['misko']);
+ var cntl = $rootScope.$new(Cntl, {name:'misko'});
expect($rootScope.$browser).toBeUndefined();
expect($rootScope.myFn).toBeUndefined();
@@ -285,7 +285,7 @@ describe('Scope', function() {
it('should return a function that allows listeners to be unregistered', inject(function($rootScope) {
- var root = angular.injector()('$rootScope'),
+ var root = angular.injector('NG')('$rootScope'),
listener = jasmine.createSpy('watch listener'),
listenerRemove;
@@ -470,7 +470,7 @@ describe('Scope', function() {
it('should add listener for both $emit and $broadcast events', inject(function($rootScope) {
var log = '',
- root = angular.injector()('$rootScope'),
+ root = angular.injector('NG')('$rootScope'),
child = root.$new();
function eventFn() {
@@ -490,7 +490,7 @@ describe('Scope', function() {
it('should return a function that deregisters the listener', inject(function($rootScope) {
var log = '',
- root = angular.injector()('$rootScope'),
+ root = angular.injector('NG')('$rootScope'),
child = root.$new(),
listenerRemove;
@@ -669,7 +669,7 @@ describe('Scope', function() {
describe('listener', function() {
it('should receive event object', inject(function($rootScope) {
- var scope = angular.injector()('$rootScope'),
+ var scope = angular.injector('NG')('$rootScope'),
child = scope.$new(),
event;
@@ -685,7 +685,7 @@ describe('Scope', function() {
it('should support passing messages as varargs', inject(function($rootScope) {
- var scope = angular.injector()('$rootScope'),
+ var scope = angular.injector('NG')('$rootScope'),
child = scope.$new(),
args;
diff --git a/test/service/xhr.bulkSpec.js b/test/service/xhr.bulkSpec.js
index 6f273f64..6e55b387 100644
--- a/test/service/xhr.bulkSpec.js
+++ b/test/service/xhr.bulkSpec.js
@@ -3,12 +3,10 @@
describe('$xhr.bulk', function() {
var log;
- beforeEach(inject(function(service) {
- service('$xhr.error', function(){
- return jasmine.createSpy('$xhr.error');
- });
- service.alias('$xhr.error', '$xhrError');
- service.alias('$xhr.bulk', '$xhrBulk');
+ beforeEach(inject(function($provide) {
+ $provide.value('$xhr.error', jasmine.createSpy('$xhr.error'));
+ $provide.factory('$xhrError', ['$xhr.error', identity]);
+ $provide.factory('$xhrBulk', ['$xhr.bulk', identity]);
log = '';
}));
diff --git a/test/service/xhr.cacheSpec.js b/test/service/xhr.cacheSpec.js
index 328dfe3a..b6eeb6aa 100644
--- a/test/service/xhr.cacheSpec.js
+++ b/test/service/xhr.cacheSpec.js
@@ -3,13 +3,11 @@
describe('$xhr.cache', function() {
var log;
- beforeEach(inject(function(service) {
- service('$xhr.error', function(){
- return jasmine.createSpy('$xhr.error');
- });
- service.alias('$xhr.cache', '$xhrCache');
- service.alias('$xhr.bulk', '$xhrBulk');
- service.alias('$xhr.error', '$xhrError');
+ beforeEach(inject(function($provide) {
+ $provide.value('$xhr.error', jasmine.createSpy('$xhr.error'));
+ $provide.factory('$xhrError', ['$xhr.error', identity]);
+ $provide.factory('$xhrBulk', ['$xhr.bulk', identity]);
+ $provide.factory('$xhrCache', ['$xhr.cache', identity]);
log = '';
}));
diff --git a/test/service/xhr.errorSpec.js b/test/service/xhr.errorSpec.js
index 0ed5ab59..f9ce2b72 100644
--- a/test/service/xhr.errorSpec.js
+++ b/test/service/xhr.errorSpec.js
@@ -3,11 +3,9 @@
describe('$xhr.error', function() {
var log;
- beforeEach(inject(function(service) {
- service('$xhr.error', function(){
- return jasmine.createSpy('$xhr.error');
- });
- service.alias('$xhr.error', '$xhrError');
+ beforeEach(inject(function($provide) {
+ $provide.value('$xhr.error', jasmine.createSpy('$xhr.error'));
+ $provide.factory('$xhrError', ['$xhr.error', identity]);
log = '';
}));
diff --git a/test/service/xhrSpec.js b/test/service/xhrSpec.js
index 997994d7..83c5f93f 100644
--- a/test/service/xhrSpec.js
+++ b/test/service/xhrSpec.js
@@ -4,12 +4,10 @@ describe('$xhr', function() {
var log;
- beforeEach(inject(function(service) {
+ beforeEach(inject(function($provide) {
log = '';
- service('$xhr.error', function(){
- return jasmine.createSpy('xhr.error');
- });
- service.alias('$xhr.error', '$xhrError');
+ $provide.value('$xhr.error', jasmine.createSpy('xhr.error'));
+ $provide.factory('$xhrError', ['$xhr.error', identity]);
}));