Skip to content

Commit

Permalink
refactor integr test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza committed Oct 22, 2024
1 parent 70e55db commit aa5d07e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions spec/integration.spec.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
const { httpRequest } = require('./support/request');

describe('S3Adapter integration tests', () => {
const fileName = 'file.txt';
const fileData = 'hello world';

describe('Parse Server 7 integration test', () => {
it('stores a file', async () => {
const base64 = Buffer.from('1').toString('base64');
const file = new Parse.File('file.txt', { base64 });
const base64 = Buffer.from(fileData).toString('base64');
const file = new Parse.File(fileName, { base64 });
await file.save();

expect(file).toBeDefined();
expect(file.url()).toMatch(/file.txt$/);
});

it('reads the contents of a file', async () => {
const base64 = Buffer.from('1').toString('base64');
const file = new Parse.File('file.txt', { base64 });
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('1');
expect(text).toBe(fileData);
});

it('deletes a file', async () => {
const base64 = Buffer.from('1').toString('base64');
const file = new Parse.File('file.txt', { base64 });
const base64 = Buffer.from(fileData).toString('base64');
const file = new Parse.File(fileName, { base64 });
await file.save();

const fileLink = file.url();
Expand Down

0 comments on commit aa5d07e

Please sign in to comment.