@@ -28,71 +28,58 @@ describe("AV.Cloud", function() {
2828 } ) ;
2929
3030 describe ( '#rpc' , function ( ) {
31- it ( 'receive complex object' , function ( done ) {
32- AV . Cloud . rpc ( 'complexObject' , null , {
33- success : function ( result ) {
34- expect ( result . foo ) . to . be ( 'bar' ) ;
35- expect ( result . t ) . to . be . a ( Date ) ;
36- expect ( result . t . toISOString ( ) ) . to . be ( '2015-05-14T09:21:18.273Z' ) ;
37-
38- expect ( result . avObject ) . to . be . a ( AV . Object ) ;
39- expect ( result . avObject . className ) . to . be ( 'ComplexObject' ) ;
40- expect ( result . avObject . get ( 'numberColumn' ) ) . to . be ( 1.23 ) ;
41- expect ( result . avObject . get ( 'arrayColumn' ) ) . to . eql ( [ 1 , 2 , 3 ] ) ;
42- expect ( result . avObject . get ( 'objectColumn' ) ) . to . eql ( { foo : 'bar' } ) ;
43- expect ( result . avObject . get ( 'stringColumn' ) ) . to . be ( 'testString' ) ;
44- expect ( result . avObject . get ( 'anyColumn' ) ) . to . be ( '' ) ;
45- expect ( result . avObject . get ( 'booleanColumn' ) ) . to . be ( true ) ;
46- expect ( result . avObject . get ( 'pointerColumn' ) ) . to . be . a ( AV . Object ) ;
47- expect ( result . avObject . get ( 'pointerColumn' ) . id ) . to . be ( '55069e5be4b0c93838ed8e6c' ) ;
48- expect ( result . avObject . get ( 'relationColumn' ) ) . to . be . a ( AV . Relation ) ;
49- expect ( result . avObject . get ( 'relationColumn' ) . targetClassName ) . to . be ( 'TestObject' ) ;
50- expect ( result . avObject . get ( 'geopointColumn' ) ) . to . be . a ( AV . GeoPoint ) ;
51- expect ( result . avObject . get ( 'geopointColumn' ) . latitude ) . to . be ( 0 ) ;
52- expect ( result . avObject . get ( 'geopointColumn' ) . longitude ) . to . be ( 30 ) ;
53- expect ( result . avObject . get ( 'dateColumn' ) ) . to . be . a ( Date ) ;
54- expect ( result . avObject . get ( 'dateColumn' ) . toISOString ( ) ) . to . be ( '2015-05-14T06:24:47.000Z' ) ;
55- expect ( result . avObject . get ( 'fileColumn' ) ) . to . be . a ( AV . File ) ;
56- expect ( result . avObject . get ( 'fileColumn' ) . name ( ) ) . to . be ( 'ttt.jpg' ) ;
57- expect ( result . avObject . get ( 'fileColumn' ) . url ( ) ) . to . be ( 'http://ac-4h2h4okw.clouddn.com/4qSbLMO866Tf4YtT9QEwJwysTlHGC9sMl7bpTwhQ.jpg' ) ;
58-
59- result . avObjects . forEach ( function ( object ) {
60- expect ( object ) . to . be . a ( AV . Object ) ;
61- expect ( object . className ) . to . be ( 'ComplexObject' ) ;
62- } ) ;
63-
64- done ( ) ;
65- } ,
66- error : done
31+ it ( 'receive complex object' , function ( ) {
32+ return AV . Cloud . rpc ( 'complexObject' ) . then ( function ( result ) {
33+ expect ( result . foo ) . to . be ( 'bar' ) ;
34+ expect ( result . t ) . to . be . a ( Date ) ;
35+ expect ( result . t . toISOString ( ) ) . to . be ( '2015-05-14T09:21:18.273Z' ) ;
36+
37+ expect ( result . avObject ) . to . be . a ( AV . Object ) ;
38+ expect ( result . avObject . className ) . to . be ( 'ComplexObject' ) ;
39+ expect ( result . avObject . get ( 'numberColumn' ) ) . to . be ( 1.23 ) ;
40+ expect ( result . avObject . get ( 'arrayColumn' ) ) . to . eql ( [ 1 , 2 , 3 ] ) ;
41+ expect ( result . avObject . get ( 'objectColumn' ) ) . to . eql ( { foo : 'bar' } ) ;
42+ expect ( result . avObject . get ( 'stringColumn' ) ) . to . be ( 'testString' ) ;
43+ expect ( result . avObject . get ( 'anyColumn' ) ) . to . be ( '' ) ;
44+ expect ( result . avObject . get ( 'booleanColumn' ) ) . to . be ( true ) ;
45+ expect ( result . avObject . get ( 'pointerColumn' ) ) . to . be . a ( AV . Object ) ;
46+ expect ( result . avObject . get ( 'pointerColumn' ) . id ) . to . be ( '55069e5be4b0c93838ed8e6c' ) ;
47+ expect ( result . avObject . get ( 'relationColumn' ) ) . to . be . a ( AV . Relation ) ;
48+ expect ( result . avObject . get ( 'relationColumn' ) . targetClassName ) . to . be ( 'TestObject' ) ;
49+ expect ( result . avObject . get ( 'geopointColumn' ) ) . to . be . a ( AV . GeoPoint ) ;
50+ expect ( result . avObject . get ( 'geopointColumn' ) . latitude ) . to . be ( 0 ) ;
51+ expect ( result . avObject . get ( 'geopointColumn' ) . longitude ) . to . be ( 30 ) ;
52+ expect ( result . avObject . get ( 'dateColumn' ) ) . to . be . a ( Date ) ;
53+ expect ( result . avObject . get ( 'dateColumn' ) . toISOString ( ) ) . to . be ( '2015-05-14T06:24:47.000Z' ) ;
54+ expect ( result . avObject . get ( 'fileColumn' ) ) . to . be . a ( AV . File ) ;
55+ expect ( result . avObject . get ( 'fileColumn' ) . name ( ) ) . to . be ( 'ttt.jpg' ) ;
56+ expect ( result . avObject . get ( 'fileColumn' ) . url ( ) ) . to . be ( 'http://ac-4h2h4okw.clouddn.com/4qSbLMO866Tf4YtT9QEwJwysTlHGC9sMl7bpTwhQ.jpg' ) ;
57+
58+ result . avObjects . forEach ( function ( object ) {
59+ expect ( object ) . to . be . a ( AV . Object ) ;
60+ expect ( object . className ) . to . be ( 'ComplexObject' ) ;
61+ } ) ;
6762 } ) ;
6863 } ) ;
6964
70- it ( 'receive bare AVObject' , function ( done ) {
71- AV . Cloud . rpc ( 'bareAVObject' , null , {
72- success : function ( result ) {
73- expect ( result ) . to . be . a ( AV . Object ) ;
74- expect ( result . className ) . to . be ( 'ComplexObject' ) ;
75- expect ( result . get ( 'fileColumn' ) ) . to . be . a ( AV . File ) ;
76- done ( ) ;
77- } ,
78- error : done
65+ it ( 'receive bare AVObject' , function ( ) {
66+ return AV . Cloud . rpc ( 'bareAVObject' ) . then ( function ( result ) {
67+ expect ( result ) . to . be . a ( AV . Object ) ;
68+ expect ( result . className ) . to . be ( 'ComplexObject' ) ;
69+ expect ( result . get ( 'fileColumn' ) ) . to . be . a ( AV . File ) ;
7970 } ) ;
8071 } ) ;
8172
82- it ( 'receive array of AVObjects' , function ( done ) {
83- AV . Cloud . rpc ( 'AVObjects' , null , {
84- success : function ( result ) {
85- result . forEach ( function ( object ) {
86- expect ( object ) . to . be . a ( AV . Object ) ;
87- expect ( object . className ) . to . be ( 'ComplexObject' ) ;
88- } ) ;
89- done ( ) ;
90- } ,
91- error : done
92- } )
73+ it ( 'receive array of AVObjects' , function ( ) {
74+ return AV . Cloud . rpc ( 'AVObjects' ) . then ( function ( result ) {
75+ result . forEach ( function ( object ) {
76+ expect ( object ) . to . be . a ( AV . Object ) ;
77+ expect ( object . className ) . to . be ( 'ComplexObject' ) ;
78+ } ) ;
79+ } ) ;
9380 } ) ;
9481
95- it ( 'send AVObject' , function ( done ) {
82+ it ( 'send AVObject' , function ( ) {
9683 var avObject = new AV . Object ( 'ComplexObject' ) ;
9784 var avObjectItem = new AV . Object ( 'ComplexObject' ) ;
9885
@@ -105,37 +92,24 @@ describe("AV.Cloud", function() {
10592 name : 'avObjects'
10693 } ) ;
10794
108- AV . Object . saveAll ( [ avObject , avObjectItem ] , {
109- success : function ( ) {
110- AV . Cloud . rpc ( 'testAVObjectParams' , {
111- avObject : avObject ,
112- avFile : AV . File . withURL ( 'hello.txt' , 'http://ac-1qdney6b.qiniudn.com/3zLG4o0d27MsCQ0qHGRg4JUKbaXU2fiE35HdhC8j.txt' ) ,
113- avObjects : [ avObjectItem ]
114- } , {
115- success : function ( ) {
116- done ( )
117- } ,
118- error : done
119- } ) ;
120- } ,
121- error : done
95+ return AV . Object . saveAll ( [ avObject , avObjectItem ] ) . then ( function ( ) {
96+ return AV . Cloud . rpc ( 'testAVObjectParams' , {
97+ avObject : avObject ,
98+ avFile : AV . File . withURL ( 'hello.txt' , 'http://ac-1qdney6b.qiniudn.com/3zLG4o0d27MsCQ0qHGRg4JUKbaXU2fiE35HdhC8j.txt' ) ,
99+ avObjects : [ avObjectItem ]
100+ } ) ;
122101 } ) ;
123102 } ) ;
124103
125- it ( 'send bare AVObject' , function ( done ) {
104+ it ( 'send bare AVObject' , function ( ) {
126105 var avObject = new AV . Object ( 'ComplexObject' ) ;
127106
128107 avObject . set ( {
129108 name : 'avObject' ,
130109 avFile : AV . File . withURL ( 'hello.txt' , 'http://ac-1qdney6b.qiniudn.com/3zLG4o0d27MsCQ0qHGRg4JUKbaXU2fiE35HdhC8j.txt' )
131110 } ) ;
132111
133- AV . Cloud . rpc ( 'testBareAVObjectParams' , avObject , {
134- success : function ( ) {
135- done ( )
136- } ,
137- error : done
138- } ) ;
112+ return AV . Cloud . rpc ( 'testBareAVObjectParams' , avObject ) ;
139113 } ) ;
140114 } ) ;
141115
0 commit comments