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/widget/selectSpec.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'test/widget/selectSpec.js') diff --git a/test/widget/selectSpec.js b/test/widget/selectSpec.js index c3fdc2e6..31e5223d 100644 --- a/test/widget/selectSpec.js +++ b/test/widget/selectSpec.js @@ -1,10 +1,10 @@ 'use strict'; describe('select', function() { - var compile = null, element = null, scope = null, $formFactory = null; + var compile = null, element = null, scope = null; - beforeEach(function() { - scope = null; + beforeEach(inject(function($rootScope) { + scope = $rootScope; element = null; compile = function(html, parent) { if (parent) { @@ -13,12 +13,11 @@ describe('select', function() { } else { element = jqLite(html); } - scope = angular.compile(element)(); + angular.compile(element)($rootScope); scope.$apply(); - $formFactory = scope.$service('$formFactory'); return scope; }; - }); + })); afterEach(function() { dealoc(element); @@ -41,7 +40,7 @@ describe('select', function() { expect(scope.$element.text()).toBe('foobarC'); }); - it('should require', function() { + it('should require', inject(function($formFactory) { compile('' + @@ -91,7 +90,7 @@ describe('select', function() { expect(element[0].childNodes[0].selected).toEqual(true); }); - it('should require', function() { + it('should require', inject(function($formFactory) { compile(''); }).toThrow("Expected ng:options in form of '_select_ (as _label_)? for (_key_,)?_value_ in" + " _collection_' but got 'i dont parse'."); - }); + })); it('should render a list', function() { createSingleSelect(); -- cgit v1.2.3