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/ParserSpec.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/ParserSpec.js')
| -rw-r--r-- | test/ParserSpec.js | 24 | 
1 files changed, 10 insertions, 14 deletions
| diff --git a/test/ParserSpec.js b/test/ParserSpec.js index 975cacc4..ce3b22ca 100644 --- a/test/ParserSpec.js +++ b/test/ParserSpec.js @@ -115,22 +115,22 @@ describe('parser', function() {        expect(tokens[0].text).toEqual(0.5);      }); -    it('should tokenize negative number', function() { -      var value = createScope().$eval("-0.5"); +    it('should tokenize negative number', inject(function($rootScope) { +      var value = $rootScope.$eval("-0.5");        expect(value).toEqual(-0.5); -      value = createScope().$eval("{a:-0.5}"); +      value = $rootScope.$eval("{a:-0.5}");        expect(value).toEqual({a:-0.5}); -    }); +    })); -    it('should tokenize number with exponent', function() { +    it('should tokenize number with exponent', inject(function($rootScope) {        var tokens = lex("0.5E-10");        expect(tokens[0].text).toEqual(0.5E-10); -      expect(createScope().$eval("0.5E-10")).toEqual(0.5E-10); +      expect($rootScope.$eval("0.5E-10")).toEqual(0.5E-10);        tokens = lex("0.5E+10");        expect(tokens[0].text).toEqual(0.5E+10); -    }); +    }));      it('should throws exception for invalid exponent', function() {        expect(function() { @@ -155,9 +155,9 @@ describe('parser', function() {    });    var scope; -  beforeEach(function () { -    scope = createScope(); -  }); +  beforeEach(inject(function ($rootScope) { +    scope = $rootScope; +  }));    it('should parse expressions', function() {      expect(scope.$eval("-1")).toEqual(-1); @@ -226,7 +226,6 @@ describe('parser', function() {      expect(scope.$eval("a=12")).toEqual(12);      expect(scope.a).toEqual(12); -    scope = createScope();      expect(scope.$eval("x.y.z=123;")).toEqual(123);      expect(scope.x.y.z).toEqual(123); @@ -392,7 +391,6 @@ describe('parser', function() {    });    it('should allow assignment after array dereference', function() { -    scope = angular.scope();      scope.obj = [{}];      scope.$eval('obj[0].name=1');      expect(scope.obj.name).toBeUndefined(); @@ -400,7 +398,6 @@ describe('parser', function() {    });    it('should short-circuit AND operator', function() { -    var scope = angular.scope();      scope.run = function() {        throw "IT SHOULD NOT HAVE RUN";      }; @@ -408,7 +405,6 @@ describe('parser', function() {    });    it('should short-circuit OR operator', function() { -    var scope = angular.scope();      scope.run = function() {        throw "IT SHOULD NOT HAVE RUN";      }; | 
