Skip to content

Commit dc74073

Browse files
committed
improve coverage
1 parent 6adbeba commit dc74073

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/__tests__/ParseFile-test.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,31 @@ describe('FileController', () => {
821821
}
822822
});
823823

824+
it('should delete file with masterKey', async () => {
825+
const file = new ParseFile('filename', [1, 2, 3]);
826+
const ajax = jest.fn().mockResolvedValueOnce({ foo: 'bar' });
827+
CoreManager.setRESTController({ ajax, request: () => {} });
828+
CoreManager.set('MASTER_KEY', 'masterKey');
829+
const result = await file.destroy({ useMasterKey: true });
830+
expect(result).toEqual(file);
831+
expect(ajax).toHaveBeenCalledWith('DELETE', 'https://api.parse.com/1/files/filename', '', {
832+
'X-Parse-Application-ID': null,
833+
'X-Parse-Master-Key': 'masterKey',
834+
});
835+
CoreManager.set('MASTER_KEY', null);
836+
});
837+
824838
it('should delete file', async () => {
825839
const file = new ParseFile('filename', [1, 2, 3]);
826840
const ajax = jest.fn().mockResolvedValueOnce({ foo: 'bar' });
827841
CoreManager.setRESTController({ ajax, request: () => {} });
828-
const result = await file.destroy();
842+
CoreManager.set('MASTER_KEY', 'masterKey');
843+
const result = await file.destroy({ useMasterKey: false });
829844
expect(result).toEqual(file);
830845
expect(ajax).toHaveBeenCalledWith('DELETE', 'https://api.parse.com/1/files/filename', '', {
831846
'X-Parse-Application-ID': null,
832-
'X-Parse-Master-Key': null,
833847
});
848+
CoreManager.set('MASTER_KEY', null);
834849
});
835850

836851
it('should handle delete file error', async () => {

0 commit comments

Comments
 (0)