-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit test for getting GIF fragment with .gif extension
- Loading branch information
1 parent
fc8dc44
commit 278c573
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
}); | ||
}); | ||
}); |