diff --git a/spec/integration.spec.js b/spec/integration.spec.js index c88ef2f..10f40a5 100644 --- a/spec/integration.spec.js +++ b/spec/integration.spec.js @@ -1,53 +1,37 @@ const { httpRequest } = require('./support/request'); -const fileData = 'hello world'; - describe('S3Adapter integration tests', () => { it('should create a file in Parse Server', async () => { - const fileName = 'test-1.txt'; + const base64 = Buffer.from('1').toString('base64'); + const file = new Parse.File('file.txt', { base64 }); + await file.save(); - const base64 = Buffer.from(fileData).toString('base64'); - const file = new Parse.File(fileName, { base64 }); + expect(file).toBeDefined(); + expect(file.url()).toMatch(/file.txt$/); + }); + it('should read the contents of the file', async () => { + const base64 = Buffer.from('1').toString('base64'); + const file = new Parse.File('file.txt', { base64 }); await file.save(); + const fileLink = file.url(); - expect(file).toBeDefined(); - expect(file.url()).toContain(fileName); + const response = await httpRequest(fileLink); + const text = response.toString(); + + expect(text).toBe('1'); }); - it( - 'should read the contents of the file', - async () => { - const fileName = 'test-2.txt'; - const base64 = Buffer.from(fileData).toString('base64'); - const file = new Parse.File(fileName, { base64 }); - await file.save(); - const fileLink = file.url(); - - const response = await httpRequest(fileLink); - const text = response.toString(); - - expect(text).toBe(fileData); // Check if the contents match the original data - }, - 60 * 1000 - ); - - it( - 'should delete the file', - async () => { - const fileName = 'test-3.txt'; - - const base64 = Buffer.from(fileData).toString('base64'); - const file = new Parse.File(fileName, { base64 }); - await file.save(); - - const fileLink = file.url(); - await file.destroy(); - - return expectAsync(httpRequest(fileLink)).toBeRejectedWithError( - 'Request failed with status code 404' - ); - }, - 60 * 1000 - ); + it('should delete the file', async () => { + const base64 = Buffer.from('1').toString('base64'); + const file = new Parse.File('file.txt', { base64 }); + await file.save(); + + const fileLink = file.url(); + await file.destroy(); + + await expectAsync(httpRequest(fileLink)).toBeRejectedWithError( + 'Request failed with status code 404' + ); + }); });