aboutsummaryrefslogtreecommitdiffstats
path: root/test/ScenarioSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2010-12-01 20:29:54 -0800
committerMisko Hevery2010-12-02 22:45:57 -0800
commit5a8ad8fe329fc09898ff43a060710265d38393be (patch)
tree95058036d40b1dd993e2a9c4094ebd34b2751707 /test/ScenarioSpec.js
parent41d5938883a3d06ffe8a88a51efd8d1896f7d747 (diff)
downloadangular.js-5a8ad8fe329fc09898ff43a060710265d38393be.tar.bz2
Closes #170. Corrected the behavior of select when options are ng:repeated
- Delete $postEval method, as it was a hack
Diffstat (limited to 'test/ScenarioSpec.js')
-rw-r--r--test/ScenarioSpec.js104
1 files changed, 58 insertions, 46 deletions
diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js
index 730019a2..4a8b5e69 100644
--- a/test/ScenarioSpec.js
+++ b/test/ScenarioSpec.js
@@ -1,52 +1,64 @@
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);
+ var scope;
+
+ beforeEach(function(){
+ scope = null;
});
-
- 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');
+
+ afterEach(function(){
+ dealoc(scope);
});
-
- 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('compilation', function(){
+ it("should compile dom node and return scope", function(){
+ var node = jqLite('<div ng:init="a=1">{{b=a+1}}</div>')[0];
+ scope = compile(node);
+ scope.$init();
+ expect(scope.a).toEqual(1);
+ expect(scope.b).toEqual(2);
+ });
+
+ it("should compile jQuery node and return scope", function(){
+ scope = compile(jqLite('<div>{{a=123}}</div>')).$init();
+ expect(jqLite(scope.$element).text()).toEqual('123');
+ });
+
+ it("should compile text node and return scope", function(){
+ 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');
+
+ describe('scope', function(){
+ it("should have set, get, eval, $init, updateView methods", function(){
+ 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(){
+ 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");
+ });
});
-
- 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("configuration", function(){
+ it("should take location object", function(){
+ var url = "http://server/#?book=moby";
+ scope = compile("<div>{{$location}}</div>");
+ var $location = scope.$location;
+ var $browser = scope.$inject('$browser');
+ expect($location.hashSearch.book).toBeUndefined();
+ $browser.setUrl(url);
+ $browser.poll();
+ expect($location.hashSearch.book).toEqual('moby');
+ });
});
-});
-
-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.$location;
- var $browser = scope.$inject('$browser');
- expect($location.hashSearch.book).toBeUndefined();
- $browser.setUrl(url);
- $browser.poll();
- expect($location.hashSearch.book).toEqual('moby');
- });
-});
+}); \ No newline at end of file