@@ -124,7 +124,7 @@ describe('files', function() {
124124 } ) ;
125125 } ) ;
126126
127- describe ( 'Fetch ' , function ( ) {
127+ describe ( '#fetch ' , function ( ) {
128128 var fileId = '52f9dd5ae4b019816c865985' ;
129129 it ( 'createWithoutData() should return a File' , function ( ) {
130130 var file = AV . File . createWithoutData ( fileId ) ;
@@ -137,20 +137,35 @@ describe('files', function() {
137137 file . save ( ) ;
138138 } ) . to . throwError ( / F i l e a l r e a d y s a v e d \. / ) ;
139139 } ) ;
140- it ( 'fetch() should retrieve all data' , function ( done ) {
141- var file = AV . File . createWithoutData ( fileId ) ;
142- file . fetch ( ) . then ( function ( file ) {
140+ describe ( 'fetch' , ( ) => {
141+ before ( function ( ) {
142+ return AV . File . createWithoutData ( fileId )
143+ . fetch ( )
144+ . then ( file => this . file = file ) ;
145+ } )
146+ it ( 'should retrieve all data' , function ( ) {
147+ var file = this . file ;
148+ return file . fetch ( ) . then ( function ( file ) {
149+ expect ( file ) . to . be . a ( AV . File ) ;
150+ expect ( file . id ) . to . be ( fileId ) ;
151+ expect ( file . name ( ) ) . to . be ( 'myfile.txt' ) ;
152+ expect ( typeof file . url ( ) ) . to . be ( 'string' ) ;
153+ } ) ;
154+ } ) ;
155+ it ( 'decode and encode' , function ( ) {
156+ const json = this . file . toJSON ( ) ;
157+ // backward compatible check
158+ expect ( json ) . to . have . keys ( [ '__type' , 'id' , 'name' , 'url' ] ) ;
159+ const file = AV . _decode ( '' , json ) ;
143160 expect ( file ) . to . be . a ( AV . File ) ;
144161 expect ( file . id ) . to . be ( fileId ) ;
145162 expect ( file . name ( ) ) . to . be ( 'myfile.txt' ) ;
146163 expect ( typeof file . url ( ) ) . to . be ( 'string' ) ;
147- done ( ) ;
148- } ) . catch ( function ( err ) {
149- console . log ( err ) ;
150164 } ) ;
151165 } ) ;
152166 } ) ;
153167
168+
154169 describe ( 'File get and set' , function ( ) {
155170 it ( 'should be equal' , function ( done ) {
156171 var base64 = 'd29ya2luZyBhdCBhdm9zY2xvdWQgaXMgZ3JlYXQh' ;
0 commit comments