diff options
| author | Rob Spies | 2010-06-22 17:09:55 -0700 |
|---|---|---|
| committer | Rob Spies | 2010-06-22 17:09:55 -0700 |
| commit | 1500e91defa4020bfe9608749b25e585cd1d8e3d (patch) | |
| tree | 8c2872252b62567dc4eb00f7d7547661d5674c55 /test/ScenarioSpec.js | |
| parent | eaa397c76b7d28343cde9f3a0338b9b0e79197c8 (diff) | |
| parent | b129a1094e6b42ed82c3ccecc2f40daaa0a6cb6a (diff) | |
| download | angular.js-1500e91defa4020bfe9608749b25e585cd1d8e3d.tar.bz2 | |
Merge http://github.com/angular/angular.js into angular
Conflicts:
.gitignore
Diffstat (limited to 'test/ScenarioSpec.js')
| -rw-r--r-- | test/ScenarioSpec.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js new file mode 100644 index 00000000..9afe8e95 --- /dev/null +++ b/test/ScenarioSpec.js @@ -0,0 +1,51 @@ +describe("ScenarioSpec: Compilation", function(){ + it("should compile dom node and return scope", function(){ + var node = jqLite('<div ng-init="a=1">{{b=a+1}}</div>')[0]; + var scope = compile(node); + scope.$init(); + expect(scope.a).toEqual(1); + expect(scope.b).toEqual(2); + }); + + it("should compile jQuery node and return scope", function(){ + var scope = compile(jqLite('<div>{{a=123}}</div>')).$init(); + expect(jqLite(scope.$element).text()).toEqual('123'); + }); + + it("should compile text node and return scope", function(){ + var scope = compile('<div>{{a=123}}</div>').$init(); + expect(jqLite(scope.$element).text()).toEqual('123'); + }); +}); + +describe("ScenarioSpec: Scope", function(){ + it("should have set, get, eval, $init, updateView methods", function(){ + var scope = compile('<div>{{a}}</div>').$init(); + scope.$eval("$invalidWidgets.push({})"); + expect(scope.$set("a", 2)).toEqual(2); + expect(scope.$get("a")).toEqual(2); + expect(scope.$eval("a=3")).toEqual(3); + scope.$eval(); + expect(jqLite(scope.$element).text()).toEqual('3'); + }); + + it("should have $ objects", function(){ + var scope = compile('<div></div>', {$config: {a:"b"}}); + expect(scope.$get('$location')).toBeDefined(); + expect(scope.$get('$eval')).toBeDefined(); + expect(scope.$get('$config')).toBeDefined(); + expect(scope.$get('$config.a')).toEqual("b"); + }); +}); + +describe("ScenarioSpec: configuration", function(){ + it("should take location object", function(){ + var url = "http://server/#?book=moby"; + var scope = compile("<div>{{$location}}</div>"); + var $location = scope.$get('$location'); + expect($location.hashSearch.book).toBeUndefined(); + scope.$browser.setUrl(url); + scope.$browser.fireUrlWatchers(); + expect($location.hashSearch.book).toEqual('moby'); + }); +}); |
