From 4460328bc1173f5d97fb4ff54edc041968486fce Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 23 Jan 2010 15:54:58 -0800 Subject: lots of cleanup to get it ready for OS --- test/ScenarioSpec.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/ScenarioSpec.js (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js new file mode 100644 index 00000000..c3c29f02 --- /dev/null +++ b/test/ScenarioSpec.js @@ -0,0 +1,66 @@ +describe("ScenarioSpec: Compilation", function(){ + it("should compile dom node and return scope", function(){ + var node = $('
{{b=a+1}}
')[0]; + var scope = angular.compile(node); + scope.init(); + expect(scope.get('a')).toEqual(1); + expect(scope.get('b')).toEqual(2); + }); + + it("should compile jQuery node and return scope", function(){ + var scope = angular.compile($('
{{a=123}}
')).init(); + expect($(scope.element).text()).toEqual('123'); + }); + + it("should compile text node and return scope", function(){ + var scope = angular.compile('
{{a=123}}
').init(); + expect($(scope.element).text()).toEqual('123'); + }); +}); + +describe("ScenarioSpec: Scope", function(){ + it("should have set, get, eval, init, updateView methods", function(){ + var scope = angular.compile('
{{a}}
').init(); + expect(scope.set("a", 2)).toEqual(2); + expect(scope.get("a")).toEqual(2); + expect(scope.eval("a=3")).toEqual(3); + scope.updateView(); + expect($(scope.element).text()).toEqual('3'); + }); + + it("should have config", function(){ + expect(angular.compile('', {a:'b'}).config.a).toEqual('b'); + }); + + it("should have $ objects", function(){ + var scope = angular.compile('
', {a:"b"}); + expect(scope.get('$anchor')).toBeDefined(); + expect(scope.get('$updateView')).toBeDefined(); + expect(scope.get('$config')).toBeDefined(); + expect(scope.get('$config.a')).toEqual("b"); + expect(scope.get('$datastore')).toBeDefined(); + }); +}); + +describe("ScenarioSpec: configuration", function(){ + it("should take location object", function(){ + var url = "http://server/#book=moby"; + var onUrlChange; + var location = { + listen:function(fn){onUrlChange=fn;}, + set:function(u){url = u;}, + get:function(){return url;} + }; + var scope = angular.compile("
{{$anchor}}
", {location:location}); + var $anchor = scope.get('$anchor'); + expect($anchor.book).toBeUndefined(); + expect(onUrlChange).toBeUndefined(); + scope.init(); + expect($anchor.book).toEqual('moby'); + expect(onUrlChange).toBeDefined(); + + url = "http://server/#book=none"; + onUrlChange(); + expect($anchor.book).toEqual('none'); + }); +}); -- cgit v1.2.3 From efad9ec5be8da442af5fb3dffc08510f7a71e10f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sun, 24 Jan 2010 17:10:58 -0800 Subject: changes to make it closure compiler compatible --- test/ScenarioSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index c3c29f02..2ca1de2f 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -29,7 +29,7 @@ describe("ScenarioSpec: Scope", function(){ }); it("should have config", function(){ - expect(angular.compile('', {a:'b'}).config.a).toEqual('b'); + expect(angular.compile('
', {a:'b'}).config.a).toEqual('b'); }); it("should have $ objects", function(){ -- cgit v1.2.3 From 251fab40291183c8e50ea0fabd23c30341cc72d3 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 4 Feb 2010 15:04:28 -0800 Subject: updateView is now called on binder instead of scope --- test/ScenarioSpec.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index 2ca1de2f..690ce464 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -21,10 +21,12 @@ describe("ScenarioSpec: Compilation", function(){ describe("ScenarioSpec: Scope", function(){ it("should have set, get, eval, init, updateView methods", function(){ var scope = angular.compile('
{{a}}
').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.updateView(); + expect(scope.eval("$invalidWidgets")).toEqual([]); expect($(scope.element).text()).toEqual('3'); }); -- cgit v1.2.3 From e55c97debaa0ef8487ece219b6eadbc147ece1f9 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 29 Mar 2010 20:25:42 -0700 Subject: dissabled a lot of tests, and made the core test set pass. --- test/ScenarioSpec.js | 62 ++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index 690ce464..9603a28e 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -1,50 +1,46 @@ describe("ScenarioSpec: Compilation", function(){ it("should compile dom node and return scope", function(){ - var node = $('
{{b=a+1}}
')[0]; + var node = jqLite('
{{b=a+1}}
')[0]; var scope = angular.compile(node); - scope.init(); - expect(scope.get('a')).toEqual(1); - expect(scope.get('b')).toEqual(2); + scope.$init(); + expect(scope.$get('a')).toEqual(1); + expect(scope.$get('b')).toEqual(2); }); - + it("should compile jQuery node and return scope", function(){ - var scope = angular.compile($('
{{a=123}}
')).init(); - expect($(scope.element).text()).toEqual('123'); + var scope = angular.compile(jqLite('
{{a=123}}
')).$init(); + expect(jqLite(scope.$element).text()).toEqual('123'); }); it("should compile text node and return scope", function(){ - var scope = angular.compile('
{{a=123}}
').init(); - expect($(scope.element).text()).toEqual('123'); + var scope = angular.compile('
{{a=123}}
').$init(); + expect(jqLite(scope.$element).text()).toEqual('123'); }); }); describe("ScenarioSpec: Scope", function(){ - it("should have set, get, eval, init, updateView methods", function(){ - var scope = angular.compile('
{{a}}
').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.updateView(); - expect(scope.eval("$invalidWidgets")).toEqual([]); - expect($(scope.element).text()).toEqual('3'); - }); - - it("should have config", function(){ - expect(angular.compile('
', {a:'b'}).config.a).toEqual('b'); + xit("should have set, get, eval, $init, updateView methods", function(){ + var scope = angular.compile('
{{a}}
').$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(scope.$eval("$invalidWidgets")).toEqual([]); + expect(jqLite(scope.$element).text()).toEqual('3'); }); - - it("should have $ objects", function(){ + + xit("should have $ objects", function(){ var scope = angular.compile('
', {a:"b"}); - expect(scope.get('$anchor')).toBeDefined(); - expect(scope.get('$updateView')).toBeDefined(); - expect(scope.get('$config')).toBeDefined(); - expect(scope.get('$config.a')).toEqual("b"); - expect(scope.get('$datastore')).toBeDefined(); + expect(scope.$get('$anchor')).toBeDefined(); + expect(scope.$get('$eval')).toBeDefined(); + expect(scope.$get('$config')).toBeDefined(); + expect(scope.$get('$config.a')).toEqual("b"); + expect(scope.$get('$datastore')).toBeDefined(); }); }); -describe("ScenarioSpec: configuration", function(){ +xdescribe("ScenarioSpec: configuration", function(){ it("should take location object", function(){ var url = "http://server/#book=moby"; var onUrlChange; @@ -54,15 +50,15 @@ describe("ScenarioSpec: configuration", function(){ get:function(){return url;} }; var scope = angular.compile("
{{$anchor}}
", {location:location}); - var $anchor = scope.get('$anchor'); + var $anchor = scope.$get('$anchor'); expect($anchor.book).toBeUndefined(); expect(onUrlChange).toBeUndefined(); - scope.init(); + scope.$init(); expect($anchor.book).toEqual('moby'); expect(onUrlChange).toBeDefined(); url = "http://server/#book=none"; - onUrlChange(); + onUrlChange(); expect($anchor.book).toEqual('none'); }); }); -- cgit v1.2.3 From a7d62dcb5533ceb9a7ae47ee27e2054400a0196b Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 30 Mar 2010 14:55:04 -0700 Subject: more tests fixed --- test/ScenarioSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index 9603a28e..5b88a175 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -3,8 +3,8 @@ describe("ScenarioSpec: Compilation", function(){ var node = jqLite('
{{b=a+1}}
')[0]; var scope = angular.compile(node); scope.$init(); - expect(scope.$get('a')).toEqual(1); - expect(scope.$get('b')).toEqual(2); + expect(scope.a).toEqual(1); + expect(scope.b).toEqual(2); }); it("should compile jQuery node and return scope", function(){ -- cgit v1.2.3 From 7a4b48020688060debe9cb0f9c17615d7585cbe7 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 5 Apr 2010 11:46:53 -0700 Subject: added ng:switch widget --- test/ScenarioSpec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index 5b88a175..ff3a55b5 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -1,26 +1,26 @@ describe("ScenarioSpec: Compilation", function(){ it("should compile dom node and return scope", function(){ var node = jqLite('
{{b=a+1}}
')[0]; - var scope = angular.compile(node); + 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 = angular.compile(jqLite('
{{a=123}}
')).$init(); + var scope = compile(jqLite('
{{a=123}}
')).$init(); expect(jqLite(scope.$element).text()).toEqual('123'); }); it("should compile text node and return scope", function(){ - var scope = angular.compile('
{{a=123}}
').$init(); + var scope = compile('
{{a=123}}
').$init(); expect(jqLite(scope.$element).text()).toEqual('123'); }); }); describe("ScenarioSpec: Scope", function(){ xit("should have set, get, eval, $init, updateView methods", function(){ - var scope = angular.compile('
{{a}}
').$init(); + var scope = compile('
{{a}}
').$init(); scope.$eval("$invalidWidgets.push({})"); expect(scope.$set("a", 2)).toEqual(2); expect(scope.$get("a")).toEqual(2); @@ -31,7 +31,7 @@ describe("ScenarioSpec: Scope", function(){ }); xit("should have $ objects", function(){ - var scope = angular.compile('
', {a:"b"}); + var scope = compile('
', {a:"b"}); expect(scope.$get('$anchor')).toBeDefined(); expect(scope.$get('$eval')).toBeDefined(); expect(scope.$get('$config')).toBeDefined(); @@ -49,7 +49,7 @@ xdescribe("ScenarioSpec: configuration", function(){ set:function(u){url = u;}, get:function(){return url;} }; - var scope = angular.compile("
{{$anchor}}
", {location:location}); + var scope = compile("
{{$anchor}}
", {location:location}); var $anchor = scope.$get('$anchor'); expect($anchor.book).toBeUndefined(); expect(onUrlChange).toBeUndefined(); -- cgit v1.2.3 From c4ef1f2fdd73bdaeda879e596d3d96e4e68cb6fd Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 8 Apr 2010 13:43:40 -0700 Subject: tests failing jstd to show cory --- test/ScenarioSpec.js | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'test/ScenarioSpec.js') diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index ff3a55b5..9afe8e95 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -19,46 +19,33 @@ describe("ScenarioSpec: Compilation", function(){ }); describe("ScenarioSpec: Scope", function(){ - xit("should have set, get, eval, $init, updateView methods", function(){ + it("should have set, get, eval, $init, updateView methods", function(){ var scope = compile('
{{a}}
').$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(scope.$eval("$invalidWidgets")).toEqual([]); expect(jqLite(scope.$element).text()).toEqual('3'); }); - xit("should have $ objects", function(){ - var scope = compile('
', {a:"b"}); - expect(scope.$get('$anchor')).toBeDefined(); + it("should have $ objects", function(){ + var scope = compile('
', {$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"); - expect(scope.$get('$datastore')).toBeDefined(); }); }); -xdescribe("ScenarioSpec: configuration", function(){ +describe("ScenarioSpec: configuration", function(){ it("should take location object", function(){ - var url = "http://server/#book=moby"; - var onUrlChange; - var location = { - listen:function(fn){onUrlChange=fn;}, - set:function(u){url = u;}, - get:function(){return url;} - }; - var scope = compile("
{{$anchor}}
", {location:location}); - var $anchor = scope.$get('$anchor'); - expect($anchor.book).toBeUndefined(); - expect(onUrlChange).toBeUndefined(); - scope.$init(); - expect($anchor.book).toEqual('moby'); - expect(onUrlChange).toBeDefined(); - - url = "http://server/#book=none"; - onUrlChange(); - expect($anchor.book).toEqual('none'); + var url = "http://server/#?book=moby"; + var scope = compile("
{{$location}}
"); + var $location = scope.$get('$location'); + expect($location.hashSearch.book).toBeUndefined(); + scope.$browser.setUrl(url); + scope.$browser.fireUrlWatchers(); + expect($location.hashSearch.book).toEqual('moby'); }); }); -- cgit v1.2.3