Skip to content

Commit ab306f4

Browse files
committed
chore: add tests for saving a file with/without tags
1 parent 8b115b0 commit ab306f4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/ParseFile.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
'use strict';
55

6+
const { FilesController } = require('../lib/Controllers/FilesController');
67
const request = require('../lib/request');
78

89
const str = 'Hello World!';
@@ -205,6 +206,29 @@ describe('Parse.File testing', () => {
205206
notEqual(file.name(), 'hello.txt');
206207
});
207208

209+
it('save file with tags', async () => {
210+
spyOn(FilesController.prototype, 'createFile').and.callThrough();
211+
const file = new Parse.File('hello.txt', data, 'text/plain');
212+
file.setTags({ hello: 'world' });
213+
ok(!file.url());
214+
const result = await file.save();
215+
equal(result.tags(), { hello: 'world' });
216+
expect(FilesController.prototype.createFile.calls.argsFor(0)[4]).toEqual({
217+
tags: { hello: 'world' },
218+
metadata: {},
219+
});
220+
});
221+
222+
it('empty file tags should not be passed while saving', async () => {
223+
spyOn(FilesController.prototype, 'createFile').and.callThrough();
224+
const file = new Parse.File('hello.txt', data, 'text/plain');
225+
ok(!file.url());
226+
await file.save();
227+
expect(FilesController.prototype.createFile.calls.argsFor(0)[4]).toEqual({
228+
metadata: {},
229+
});
230+
});
231+
208232
it('save file in object', async done => {
209233
const file = new Parse.File('hello.txt', data, 'text/plain');
210234
ok(!file.url());

0 commit comments

Comments
 (0)