|
9 | 9 |
|
10 | 10 | describe('File', function() { |
11 | 11 | describe('Saving base64', function() { |
| 12 | + var base64 = 'd29ya2luZyBhdCBhdm9zY2xvdWQgaXMgZ3JlYXQh'; |
| 13 | + var fileName = 'base64.txt'; |
| 14 | + |
12 | 15 | it('should be saved', function() { |
13 | | - var base64 = 'd29ya2luZyBhdCBhdm9zY2xvdWQgaXMgZ3JlYXQh'; |
14 | | - var file = new AV.File('base64.txt', { base64: base64 }); |
| 16 | + var file = new AV.File(fileName, { base64: base64 }); |
| 17 | + file.metaData('format', 'txt file'); |
| 18 | + file.setACL(new AV.ACL()); |
| 19 | + return file.save().then(function() { |
| 20 | + expect(file.id).to.be.ok(); |
| 21 | + expect(file.metaData('format')).to.be('txt file'); |
| 22 | + expect(file.get('mime_type')).to.be('text/plain'); |
| 23 | + return file.destroy({ useMasterKey: true }); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + it('with keepFileName', function() { |
| 28 | + var file = new AV.File(fileName, { base64: base64 }); |
15 | 29 | file.metaData('format', 'txt file'); |
16 | 30 | file.setACL(new AV.ACL()); |
17 | 31 | return file.save().then(function() { |
| 32 | + expect(file.url()).to.match(new RegExp(fileName + '$')); |
18 | 33 | expect(file.ownerId()).to.be.ok(); |
19 | 34 | expect(file.id).to.be.ok(); |
20 | 35 | expect(file.metaData('format')).to.be('txt file'); |
@@ -163,7 +178,7 @@ describe('File', function() { |
163 | 178 | var file = AV.File.createWithoutData(fileId); |
164 | 179 | expect(function saveFetchedFile() { |
165 | 180 | file.save(); |
166 | | - }).to.throwError(/File already saved\./); |
| 181 | + }).to.throwError(/File is already saved\./); |
167 | 182 | }); |
168 | 183 | describe('fetch', () => { |
169 | 184 | before(function() { |
|
0 commit comments