-
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 test cases for get-info and get routes, used markdown-it instea…
…d of marked
- Loading branch information
Bregwin Jogi
committed
Jul 8, 2024
1 parent
0306d14
commit c1696de
Showing
7 changed files
with
216 additions
and
77 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const request = require('supertest'); | ||
const { createSuccessResponse } = require('../../src/response'); | ||
const app = require('../../src/app'); | ||
|
||
describe('GET /v1/fragments/:id/info', () => { | ||
|
||
test('GET /fragments/:id/info should return fragment info when found', async () => { | ||
const postRequest = await request(app) | ||
.post('/v1/fragments') | ||
.auth('[email protected]', 'password1') | ||
.set('Content-Type', 'text/plain') | ||
.send(Buffer.from('hello world')); | ||
|
||
const res = await request(app) | ||
.get(`/v1/fragments/${postRequest.body.fragment.id}/info`) | ||
.auth('[email protected]', 'password1'); | ||
|
||
expect(res.statusCode).toBe(200); | ||
expect(res.text).toBe( | ||
JSON.stringify( | ||
createSuccessResponse({ | ||
fragment: { | ||
id: postRequest.body.fragment.id, | ||
ownerId: postRequest.body.fragment.ownerId, | ||
created: postRequest.body.fragment.created, | ||
updated: postRequest.body.fragment.updated, | ||
type: 'text/plain', | ||
size: 11, | ||
}, | ||
}) | ||
) | ||
); | ||
|
||
}); | ||
|
||
|
||
|
||
test('GET /fragments/:id should return 404 when fragment not found', async () => { | ||
|
||
const res = await request(app) | ||
.get(`/v1/fragments/123123/info`) | ||
.auth('[email protected]', 'password1'); | ||
|
||
expect(res.statusCode).toBe(404); | ||
expect(res.body.status).toBe('error'); | ||
expect(res.body.error.message).toBe('Fragment not found'); | ||
|
||
}); | ||
|
||
|
||
}); |
Oops, something went wrong.