aboutsummaryrefslogtreecommitdiffstats
path: root/test/moveToAngularCom/EntityDeclarationTest.js
diff options
context:
space:
mode:
authorRob Spies2010-06-22 17:09:55 -0700
committerRob Spies2010-06-22 17:09:55 -0700
commit1500e91defa4020bfe9608749b25e585cd1d8e3d (patch)
tree8c2872252b62567dc4eb00f7d7547661d5674c55 /test/moveToAngularCom/EntityDeclarationTest.js
parenteaa397c76b7d28343cde9f3a0338b9b0e79197c8 (diff)
parentb129a1094e6b42ed82c3ccecc2f40daaa0a6cb6a (diff)
downloadangular.js-1500e91defa4020bfe9608749b25e585cd1d8e3d.tar.bz2
Merge http://github.com/angular/angular.js into angular
Conflicts: .gitignore
Diffstat (limited to 'test/moveToAngularCom/EntityDeclarationTest.js')
-rw-r--r--test/moveToAngularCom/EntityDeclarationTest.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/moveToAngularCom/EntityDeclarationTest.js b/test/moveToAngularCom/EntityDeclarationTest.js
new file mode 100644
index 00000000..28986ea8
--- /dev/null
+++ b/test/moveToAngularCom/EntityDeclarationTest.js
@@ -0,0 +1,50 @@
+EntityDeclarationTest = TestCase('EntityDeclarationTest');
+
+EntityDeclarationTest.prototype.testEntityTypeOnly = function(){
+ expectAsserts(2);
+ var datastore = {entity:function(name){
+ assertEquals("Person", name);
+ }};
+ var scope = new Scope();
+ var init = scope.entity("Person", datastore);
+ assertEquals("", init);
+};
+
+EntityDeclarationTest.prototype.testWithDefaults = function(){
+ expectAsserts(4);
+ var datastore = {entity:function(name, init){
+ assertEquals("Person", name);
+ assertEquals("=a:", init.a);
+ assertEquals(0, init.b.length);
+ }};
+ var scope = new Scope();
+ var init = scope.entity('Person:{a:"=a:", b:[]}', datastore);
+ assertEquals("", init);
+};
+
+EntityDeclarationTest.prototype.testWithName = function(){
+ expectAsserts(2);
+ var datastore = {entity:function(name, init){
+ assertEquals("Person", name);
+ return function (){ return {}; };
+ }};
+ var scope = new Scope();
+ var init = scope.entity('friend=Person', datastore);
+ assertEquals("$anchor.friend:{friend=Person.load($anchor.friend);friend.$$anchor=\"friend\";};", init);
+};
+
+EntityDeclarationTest.prototype.testMultipleEntities = function(){
+ expectAsserts(3);
+ var expect = ['Person', 'Book'];
+ var i=0;
+ var datastore = {entity:function(name, init){
+ assertEquals(expect[i], name);
+ i++;
+ return function (){ return {}; };
+ }};
+ var scope = new Scope();
+ var init = scope.entity('friend=Person;book=Book;', datastore);
+ assertEquals("$anchor.friend:{friend=Person.load($anchor.friend);friend.$$anchor=\"friend\";};" +
+ "$anchor.book:{book=Book.load($anchor.book);book.$$anchor=\"book\";};",
+ init);
+};