|
3 | 3 |
|
4 | 4 | 'use strict';
|
5 | 5 |
|
| 6 | +const { FilesController } = require('../lib/Controllers/FilesController'); |
6 | 7 | const request = require('../lib/request');
|
7 | 8 |
|
8 | 9 | const str = 'Hello World!';
|
@@ -205,6 +206,34 @@ describe('Parse.File testing', () => {
|
205 | 206 | notEqual(file.name(), 'hello.txt');
|
206 | 207 | });
|
207 | 208 |
|
| 209 | + it('saves the file with tags', async () => { |
| 210 | + spyOn(FilesController.prototype, 'createFile').and.callThrough(); |
| 211 | + const file = new Parse.File('hello.txt', data, 'text/plain'); |
| 212 | + const tags = { hello: 'world' }; |
| 213 | + file.setTags(tags); |
| 214 | + expect(file.url()).toBeUndefined(); |
| 215 | + const result = await file.save(); |
| 216 | + expect(file.name()).toBeDefined(); |
| 217 | + expect(file.url()).toBeDefined(); |
| 218 | + expect(result.tags()).toEqual(tags); |
| 219 | + expect(FilesController.prototype.createFile.calls.argsFor(0)[4]).toEqual({ |
| 220 | + tags: tags, |
| 221 | + metadata: {}, |
| 222 | + }); |
| 223 | + }); |
| 224 | + |
| 225 | + it('does not pass empty file tags while saving', async () => { |
| 226 | + spyOn(FilesController.prototype, 'createFile').and.callThrough(); |
| 227 | + const file = new Parse.File('hello.txt', data, 'text/plain'); |
| 228 | + expect(file.url()).toBeUndefined(); |
| 229 | + expect(file.name()).toBeDefined(); |
| 230 | + await file.save(); |
| 231 | + expect(file.url()).toBeDefined(); |
| 232 | + expect(FilesController.prototype.createFile.calls.argsFor(0)[4]).toEqual({ |
| 233 | + metadata: {}, |
| 234 | + }); |
| 235 | + }); |
| 236 | + |
208 | 237 | it('save file in object', async done => {
|
209 | 238 | const file = new Parse.File('hello.txt', data, 'text/plain');
|
210 | 239 | ok(!file.url());
|
|
0 commit comments