Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
LihongWu21 committed Dec 14, 2023
1 parent 09f88c7 commit 420477b
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions upload_update_download_rate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,65 @@ describe('GET /package/{id}/rate', () => {
*/


describe('PUT /package/{id}', () => {
it('fail to update a file with an invalid field', async () => {
const req = httpMocks.createRequest({
method: 'PUT',
url: '/package/{id}',
body: {
metadata: {
name: 'javascript-client-generated',
version: '1.0.0',
ID: '',
},
data: {
Content:'',
URL:'',
},
},
});
const res = httpMocks.createResponse();
await app(req, res);
// now you can make assertions about the response
expect(res.statusCode).toBe(400);
});
/*
it('fail to update when file does not exist', async () => {
const response = await axios({
method: 'put',
url: 'http://phase2-ece461.s3-website-us-east-1.amazonaws.com', // replace with your actual URL
data: {
metadata: {
Name: 'randomn file donr exist',
Version: '1.0.0',
ID: '1',
},
data: {
Content:'something',
URL:'something',
},
},
});
// now you can make assertions about the response
expect(response.status).toBe(404);
});
*/
});

describe('GET /package/{id}/rate', () => {
it('rate a file with an invalid id', async () => {
const req = httpMocks.createRequest({
method: 'GET',
url: '/package/{id}/rate',
params: {
id: 1,
},
});
const res = httpMocks.createResponse();
await app(req, res);
// now you can make assertions about the response
expect(res.statusCode).toBe(400);
});
});


0 comments on commit 420477b

Please sign in to comment.