From 48697a2b86dbb12ea8de64cc5fece7caf68b321e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 17 Oct 2011 16:56:56 -0700 Subject: refactor(injector): turn scope into a service - turn scope into a $rootScope service. - injector is now a starting point for creating angular application. - added inject() method which wraps jasmine its/beforeEach/afterEach, and which allows configuration and injection of services. - refactor tests to use inject() where possible BREAK: - removed angular.scope() method --- test/AngularSpec.js | 87 ++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 51 deletions(-) (limited to 'test/AngularSpec.js') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 299bfb8a..eb64a825 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -371,22 +371,16 @@ describe('angular', function() { '' + ''); }); - - - xit('should add custom css when specified via css', function() { - //TODO - }); }); describe('angular service', function() { - it('should override services', function() { - var scope = createScope(); - angular.service('fake', function() { return 'old'; }); - angular.service('fake', function() { return 'new'; }); - - expect(scope.$service('fake')).toEqual('new'); - }); + it('should override services', inject(function(service){ + service('fake', function() { return 'old'; }); + service('fake', function() { return 'new'; }); + }, function(fake) { + expect(fake).toEqual('new'); + })); it('should not preserve properties on override', function() { angular.service('fake', {$one: true}, {$two: true}, {three: true}); @@ -410,19 +404,19 @@ describe('angular', function() { it('should inject dependencies specified by $inject', function() { angular.service('svc1', function() { return 'svc1'; }); angular.service('svc2', function(svc1) { return 'svc2-' + svc1; }, {$inject: ['svc1']}); - expect(angular.scope().$service('svc2')).toEqual('svc2-svc1'); + expect(createInjector()('svc2')).toEqual('svc2-svc1'); }); it('should inject dependencies specified by $inject and ignore function argument name', function() { angular.service('svc1', function() { return 'svc1'; }); angular.service('svc2', function(foo) { return 'svc2-' + foo; }, {$inject: ['svc1']}); - expect(angular.scope().$service('svc2')).toEqual('svc2-svc1'); + expect(createInjector()('svc2')).toEqual('svc2-svc1'); }); it('should eagerly instantiate a service if $eager is true', function() { var log = []; angular.service('svc1', function() { log.push('svc1'); }, {$eager: true}); - angular.scope(); + createInjector(); expect(log).toEqual(['svc1']); }); }); @@ -464,55 +458,46 @@ describe('angular', function() { }); describe('compile', function() { - var scope, template; - - afterEach(function() { - dealoc(scope); - }); - - it('should link to existing node and create scope', function() { - template = angular.element('