@@ -4,6 +4,10 @@ var GameScore = AV.Object.extend("GameScore");
44
55var Post = AV . Object . extend ( "Post" ) ;
66
7+ // for #extend test
8+ class Person extends AV . Object { }
9+ var BackbonePerson = AV . Object . extend ( 'Person' ) ;
10+
711describe ( 'Objects' , function ( ) {
812 var objId ;
913 var gameScore = GameScore . new ( ) ;
@@ -23,6 +27,34 @@ describe('Objects', function(){
2327 } ) ;
2428 new Post ( ) . name ;
2529 } ) ;
30+
31+ describe ( '#extend' , ( ) => {
32+ it ( 'extend for multiple times should not throw' , ( ) => {
33+ let Test ;
34+ for ( var i = 100000 ; i > 0 ; i -- ) {
35+ Test = AV . Object . extend ( 'Test' ) ;
36+ }
37+ new Test ( ) ;
38+ } ) ;
39+
40+ it ( 'ES6 extend syntex' , ( ) => {
41+ var backbonePerson = new BackbonePerson ( ) ;
42+ backbonePerson . set ( 'name' , 'leeyeh' ) ;
43+ var es6Person = new Person ( ) ;
44+ es6Person . set ( 'name' , 'leeyeh' ) ;
45+ expect ( backbonePerson . toJSON ( ) ) . to . eql ( es6Person . toJSON ( ) ) ;
46+ expect ( backbonePerson . _toFullJSON ( ) ) . to . eql ( es6Person . _toFullJSON ( ) ) ;
47+ } ) ;
48+
49+ it ( '#resiger an ES6 class' , ( ) => {
50+ expect ( new AV . Object ( 'Person' ) ) . to . be . a ( BackbonePerson ) ;
51+ AV . Object . register ( Person ) ;
52+ expect ( new AV . Object ( 'Person' ) ) . to . be . a ( Person ) ;
53+ expect ( ( ) => AV . Object . register ( 1 ) ) . to . throwError ( ) ;
54+ expect ( ( ) => AV . Object . register ( function ( ) { } ) ) . to . throwError ( ) ;
55+ } )
56+ } ) ;
57+
2658 describe ( '#Saving Objects' , function ( ) {
2759 it ( 'should crate a Object' , function ( done ) {
2860 //gameScore.set("newcol","sss")
@@ -174,7 +206,7 @@ describe('Objects', function(){
174206 expect ( score2 . id ) . to . be . eql ( gameScore . id ) ;
175207 } )
176208 ) ;
177- it ( 'fetchAll with non-existed Class should fail' , ( done ) =>
209+ it ( 'fetchAll with non-existed Class should fail' , ( done ) => {
178210 AV . Object . fetchAll ( [
179211 AV . Object . createWithoutData ( 'GameScore' , gameScore . id ) ,
180212 AV . Object . createWithoutData ( 'FakeClass' , gameScore . id ) ,
@@ -184,8 +216,8 @@ describe('Objects', function(){
184216 expect ( err ) . to . be . an ( Error ) ;
185217 done ( ) ;
186218 } )
187- ) ;
188- it ( 'fetchAll with dirty objet should fail' , ( done ) =>
219+ } ) ;
220+ it ( 'fetchAll with dirty objet should fail' , ( done ) => {
189221 AV . Object . fetchAll ( [
190222 AV . Object . createWithoutData ( 'GameScore' , gameScore . id ) ,
191223 new GameScore ( ) ,
@@ -195,7 +227,7 @@ describe('Objects', function(){
195227 expect ( err ) . to . be . an ( Error ) ;
196228 done ( ) ;
197229 } )
198- ) ;
230+ } ) ;
199231 } ) ;
200232
201233 describe ( "Deleting Objects" , function ( ) {
@@ -469,50 +501,10 @@ describe('Objects', function(){
469501 } ) ;
470502 } ) ;
471503 } ) ;
504+
472505
473- /*
474-
475- it("it should fetch relation post",function(done){
476- var post=myComment.get("parent");
477- post.fetch({
478- success:function(post){
479- done();
480- }
481- })
482- })
483-
484- it("many to many relations create",function(done){
485- var user = AV.User.current();
486- relation = user.relation("likes");
487- relation.add(post);
488- user.save({
489- success:function(){
490- done();
491- },
492- error:function(err){
493- throw err;
494- }
495- });
496- })
497-
498- it("many to many relations query",function(done){
499-
500- relation.query().find({
501- success: function(list) {
502- done();
503- // list contains the posts that the current user likes.
504- },
505- error:function(err){
506- throw err;
507- }
508- });
509- })
510-
511- */
512-
513-
514- } ) ;
515506
507+ } ) ;
516508
517509
518510} ) ; //END RETRIEVING
0 commit comments