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/FiltersSpec.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/FiltersSpec.js')
| -rw-r--r-- | test/FiltersSpec.js | 39 | 
1 files changed, 16 insertions, 23 deletions
| diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js index df47ccc3..4b69bf03 100644 --- a/test/FiltersSpec.js +++ b/test/FiltersSpec.js @@ -4,28 +4,26 @@ describe('filter', function() {    var filter = angular.filter; -  it('should called the filter when evaluating expression', function() { -    var scope = createScope(); +  it('should called the filter when evaluating expression', inject(function($rootScope) {      filter.fakeFilter = function() {};      spyOn(filter, 'fakeFilter'); -    scope.$eval('10|fakeFilter'); +    $rootScope.$eval('10|fakeFilter');      expect(filter.fakeFilter).toHaveBeenCalledWith(10);      delete filter['fakeFilter']; -  }); +  })); -  it('should call filter on scope context', function() { -    var scope = createScope(); -    scope.name = 'misko'; +  it('should call filter on scope context', inject(function($rootScope) { +    $rootScope.name = 'misko';      filter.fakeFilter = function() {        expect(this.name).toEqual('misko');      };      spyOn(filter, 'fakeFilter').andCallThrough(); -    scope.$eval('10|fakeFilter'); +    $rootScope.$eval('10|fakeFilter');      expect(filter.fakeFilter).toHaveBeenCalled();      delete filter['fakeFilter']; -  }); +  }));    describe('formatNumber', function() {      var pattern; @@ -85,17 +83,12 @@ describe('filter', function() {    describe('currency', function() {      var currency, html, context; -    beforeEach(function() { +    beforeEach(inject(function($rootScope) {        html = jqLite('<span></span>'); -      context = createScope(); +      context = $rootScope;        context.$element = html;        currency = bind(context, filter.currency); -    }); - -    afterEach(function() { -      dealoc(context); -    }); - +    }));      it('should do basic currency filtering', function() {        expect(currency(0)).toEqual('$0.00'); @@ -119,10 +112,10 @@ describe('filter', function() {    describe('number', function() {      var context, number; -    beforeEach(function() { -      context = createScope(); +    beforeEach(inject(function($rootScope) { +      context = $rootScope;        number = bind(context, filter.number); -    }); +    }));      it('should do basic filter', function() { @@ -214,10 +207,10 @@ describe('filter', function() {      var context, date; -    beforeEach(function() { -      context = createScope(); +    beforeEach(inject(function($rootScope) { +      context = $rootScope;        date = bind(context, filter.date); -    }); +    }));      it('should ignore falsy inputs', function() {        expect(date(null)).toBeNull(); | 
