diff options
| author | Misko Hevery | 2011-10-17 16:56:56 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2011-11-14 16:39:31 -0800 | 
| commit | 48697a2b86dbb12ea8de64cc5fece7caf68b321e (patch) | |
| tree | 1fa50659f0bb5de2640dea2a2e5bb5628f2bb14a /test/widget/selectSpec.js | |
| parent | 93b777c916ccff243c5a6080bf5f39860ac7bf39 (diff) | |
| download | angular.js-48697a2b86dbb12ea8de64cc5fece7caf68b321e.tar.bz2 | |
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
Diffstat (limited to 'test/widget/selectSpec.js')
| -rw-r--r-- | test/widget/selectSpec.js | 23 | 
1 files changed, 11 insertions, 12 deletions
| 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('<select name="select" ng:model="selection" required ng:change="log=log+\'change;\'">' +            '<option value=""></option>' +            '<option value="c">C</option>' + @@ -65,7 +64,7 @@ describe('select', function() {        expect(element).toBeValid();        expect(element).toBeDirty();        expect(scope.log).toEqual('change;'); -    }); +    }));      it('should not be invalid if no require', function() {        compile('<select name="select" ng:model="selection">' + @@ -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('<select name="select" ng:model="selection" multiple required>' +            '<option>A</option>' +            '<option>B</option>' + @@ -112,7 +111,7 @@ describe('select', function() {        browserTrigger(element, 'change');        expect(element).toBeValid();        expect(element).toBeDirty(); -    }); +    }));    }); @@ -157,12 +156,12 @@ describe('select', function() {        dealoc(scope);      }); -    it('should throw when not formated "? for ? in ?"', function() { +    it('should throw when not formated "? for ? in ?"', inject(function($rootScope, $exceptionHandler) {        expect(function() {          compile('<select ng:model="selected" ng:options="i dont parse"></select>');        }).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(); | 
