aboutsummaryrefslogtreecommitdiffstats
path: root/test/ScenarioSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-10-17 16:56:56 -0700
committerMisko Hevery2011-11-14 16:39:31 -0800
commit48697a2b86dbb12ea8de64cc5fece7caf68b321e (patch)
tree1fa50659f0bb5de2640dea2a2e5bb5628f2bb14a /test/ScenarioSpec.js
parent93b777c916ccff243c5a6080bf5f39860ac7bf39 (diff)
downloadangular.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/ScenarioSpec.js')
-rw-r--r--test/ScenarioSpec.js42
1 files changed, 16 insertions, 26 deletions
diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js
index 5f83ab93..d33e880d 100644
--- a/test/ScenarioSpec.js
+++ b/test/ScenarioSpec.js
@@ -1,35 +1,25 @@
'use strict';
describe("ScenarioSpec: Compilation", function() {
- var scope;
-
- beforeEach(function() {
- scope = null;
- });
-
- afterEach(function() {
- dealoc(scope);
- });
-
describe('compilation', function() {
- it("should compile dom node and return scope", function() {
+ it("should compile dom node and return scope", inject(function($rootScope) {
var node = jqLite('<div ng:init="a=1">{{b=a+1}}</div>')[0];
- scope = angular.compile(node)();
- scope.$digest();
- expect(scope.a).toEqual(1);
- expect(scope.b).toEqual(2);
- });
+ angular.compile(node)($rootScope);
+ $rootScope.$digest();
+ expect($rootScope.a).toEqual(1);
+ expect($rootScope.b).toEqual(2);
+ }));
- it("should compile jQuery node and return scope", function() {
- scope = compile(jqLite('<div>{{a=123}}</div>'))();
- scope.$digest();
- expect(jqLite(scope.$element).text()).toEqual('123');
- });
+ it("should compile jQuery node and return scope", inject(function($rootScope) {
+ var element = compile(jqLite('<div>{{a=123}}</div>'))($rootScope);
+ $rootScope.$digest();
+ expect(jqLite(element).text()).toEqual('123');
+ }));
- it("should compile text node and return scope", function() {
- scope = angular.compile('<div>{{a=123}}</div>')();
- scope.$digest();
- expect(jqLite(scope.$element).text()).toEqual('123');
- });
+ it("should compile text node and return scope", inject(function($rootScope) {
+ var element = angular.compile('<div>{{a=123}}</div>')($rootScope);
+ $rootScope.$digest();
+ expect(jqLite(element).text()).toEqual('123');
+ }));
});
});