Skip to content

Commit

Permalink
unit test 'should return 415 if unsupported extension is requested' u…
Browse files Browse the repository at this point in the history
…nder GET /fragment/:id, removed post request with local Fragment save data
  • Loading branch information
hpatel292-seneca committed Jul 12, 2024
1 parent 24c6872 commit 2a54fe6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/unit/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe('GET /v1/fragments/:id.ext', () => {
fragMetadata1.save();
const md = markdownit();
const result = md.render(body);

const res = await request(app)
.get(`/v1/fragments/${id}.html`)
.auth('[email protected]', 'password1');
Expand All @@ -208,19 +209,18 @@ describe('GET /v1/fragments/:id.ext', () => {
// should return 415 if unsupported extension is requested
test('should return 415 if unsupported extension is requested', async () => {
// post a fragment
const ownerId = hash('[email protected]');
const id = 'rdmId';
const fragMetadata1 = new Fragment({ id: id, ownerId: ownerId, type: 'text/plain' });
const body = 'This is a fragment';
const res = await request(app)
.post('/v1/fragments')
.auth('[email protected]', 'password1')
.set('Content-Type', 'text/plain')
.send(body);
const id = res.body.fragment.id;
fragMetadata1.setData(body);
fragMetadata1.save();

const res_2 = await request(app)
const res = await request(app)
.get(`/v1/fragments/${id}.png`)
.auth('[email protected]', 'password1');
expect(res_2.statusCode).toBe(415);
expect(res_2.body).toEqual({
expect(res.statusCode).toBe(415);
expect(res.body).toEqual({
status: 'error',
error: {
code: 415,
Expand Down

0 comments on commit 2a54fe6

Please sign in to comment.