Skip to content

Commit

Permalink
added unit test for getting GIF fragment with .gif extension
Browse files Browse the repository at this point in the history
  • Loading branch information
hpatel292-seneca committed Aug 1, 2024
1 parent fc8dc44 commit 278c573
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,5 +662,29 @@ describe('GET /v1/fragments/:id.ext', () => {
expect(receivedMetadata).toEqual(originalMetadata);
expect(Buffer.compare(receivedFileContent, fileContent)).toBe(0);
});

test('GIF fragments data is returned in if GIF fragment ID is passed with .gif extension', async () => {
// post a fragment
const filePath = path.join(__dirname, '..', 'files', 'file.gif');
const fileContent = fs.readFileSync(filePath);
const ownerId = hash('[email protected]');
const id = 'rdmId';
const type = 'image/gif';
const fragMetadata1 = new Fragment({ id: id, ownerId: ownerId, type: type });
fragMetadata1.setData(fileContent);
fragMetadata1.save();

const res = await request(app)
.get(`/v1/fragments/${id}.gif`)
.auth('[email protected]', 'password1');
expect(res.statusCode).toBe(200);
const receivedFileContent = res.body;

const receivedMetadata = await sharp(receivedFileContent).metadata();
const originalMetadata = await sharp(fileContent).metadata();

expect(receivedMetadata).toEqual(originalMetadata);
expect(Buffer.compare(receivedFileContent, fileContent)).toBe(0);
});
});
});

0 comments on commit 278c573

Please sign in to comment.