-
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.
feat: add and test link user to project endpoints
- Loading branch information
Showing
1 changed file
with
117 additions
and
15 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 |
---|---|---|
|
@@ -57,46 +57,51 @@ describe('Project Creation Routes', () => { | |
name: 'testProject', | ||
}) | ||
.expect(201) | ||
.expect(""); | ||
.expect(''); | ||
}); | ||
|
||
it("Create a project with empty-string name", async () => { | ||
it('Create a project with empty-string name', async () => { | ||
await request(app.getHttpServer()) | ||
.post('/project') | ||
.send({ | ||
name: '', | ||
}) | ||
.expect(400) | ||
.expect('{"message":["name should not be empty"],"error":"Bad Request","statusCode":400}'); | ||
.expect( | ||
'{"message":["name should not be empty"],"error":"Bad Request","statusCode":400}', | ||
); | ||
}); | ||
|
||
it("Create a project with no name field", async () => { | ||
it('Create a project with no name field', async () => { | ||
await request(app.getHttpServer()) | ||
.post('/project') | ||
.send({ | ||
}) | ||
.send({}) | ||
.expect(400) | ||
.expect('{"message":["name should not be empty"],"error":"Bad Request","statusCode":400}'); | ||
.expect( | ||
'{"message":["name should not be empty"],"error":"Bad Request","statusCode":400}', | ||
); | ||
}); | ||
|
||
it("Create a project with null name", async () => { | ||
it('Create a project with null name', async () => { | ||
await request(app.getHttpServer()) | ||
.post('/project') | ||
.send({ | ||
name: null, | ||
}) | ||
.expect(400) | ||
.expect('{"message":["name should not be empty"],"error":"Bad Request","statusCode":400}'); | ||
.expect( | ||
'{"message":["name should not be empty"],"error":"Bad Request","statusCode":400}', | ||
); | ||
}); | ||
|
||
it("Create a project with non-string name", async () => { | ||
it('Create a project with non-string name', async () => { | ||
await request(app.getHttpServer()) | ||
.post('/project') | ||
.send({ | ||
name: 1, | ||
}) | ||
.expect(201) | ||
.expect(""); | ||
.expect(''); | ||
}); | ||
}); | ||
|
||
|
@@ -108,7 +113,7 @@ describe('Project Retrieval Routes', () => { | |
.then((response) => { | ||
expect(response.body.name).toEqual('testProject'); | ||
expect(response.body.id).toEqual(1); | ||
}) | ||
}); | ||
}); | ||
|
||
it('Get project with valid name', async () => { | ||
|
@@ -118,14 +123,14 @@ describe('Project Retrieval Routes', () => { | |
.then((response) => { | ||
expect(response.body.name).toEqual('testProject'); | ||
expect(response.body.id).toEqual(1); | ||
}) | ||
}); | ||
}); | ||
|
||
it('Get project with non-number id', async () => { | ||
await request(app.getHttpServer()) | ||
.get('/project/id/abc') | ||
.expect(400) | ||
.expect('{"statusCode":400,"message":"id must be a number"}') | ||
.expect('{"statusCode":400,"message":"id must be a number"}'); | ||
}); | ||
|
||
// it('Get project with non-existent id', async () => { | ||
|
@@ -141,4 +146,101 @@ describe('Project Retrieval Routes', () => { | |
// .expect(400) | ||
// .expect('{"statusCode":400,"message":"name does not exist"}') | ||
// }); | ||
}); | ||
}); | ||
|
||
describe('Project Update Routes', () => { | ||
beforeAll(async () => { | ||
await request(app.getHttpServer()).post('/user').send({ | ||
id: '1', | ||
password: '1234', | ||
name: 'Test User', | ||
email: '[email protected]', | ||
}); | ||
}); | ||
|
||
it('Link user with project id using valid user id input', async () => { | ||
await request(app.getHttpServer()) | ||
.put('/project/id/1/user') | ||
.send({ | ||
id: '1', | ||
}) | ||
.expect(200); | ||
}); | ||
|
||
it('Link user with project id using valid user email input', async () => { | ||
await request(app.getHttpServer()) | ||
.put('/project/id/1/user') | ||
.send({ | ||
email: '[email protected]', | ||
}) | ||
.expect(200); | ||
}); | ||
|
||
it('Link user with project id using non-number project id param', async () => { | ||
await request(app.getHttpServer()) | ||
.put('/project/id/abc/user') | ||
.send({ | ||
email: '[email protected]', | ||
}) | ||
.expect(400) | ||
.expect('{"statusCode":400,"message":"id must be a number"}'); | ||
}); | ||
|
||
// it('Link user with project id using non-number user id input', async () => { | ||
// await request(app.getHttpServer()) | ||
// .put('/project/id/1/user') | ||
// .send({ | ||
// id: 'abc', | ||
// }) | ||
// .expect(400) | ||
// .expect('{"statusCode":400,"message":"id must be a number"}'); | ||
// }); | ||
|
||
// it('Link user with project id using invalid user email input', async () => { | ||
// await request(app.getHttpServer()) | ||
// .put('/project/id/1/user') | ||
// .send({ | ||
// email: 'abc', | ||
// }) | ||
// .expect(400) | ||
// .expect(''); | ||
// }); | ||
|
||
it('Link user with project name using valid user id input', async () => { | ||
await request(app.getHttpServer()) | ||
.put('/project/name/testProject/user') | ||
.send({ | ||
id: '1', | ||
}) | ||
.expect(200); | ||
}); | ||
|
||
it('Link user with project name using valid user email input', async () => { | ||
await request(app.getHttpServer()) | ||
.put('/project/name/testProject/user') | ||
.send({ | ||
email: '[email protected]', | ||
}) | ||
.expect(200); | ||
}); | ||
|
||
// it('Link user with project name using non-number user id input', async () => { | ||
// await request(app.getHttpServer()) | ||
// .put('/project/name/testProject/user') | ||
// .send({ | ||
// id: 'abc', | ||
// }) | ||
// .expect(400) | ||
// .expect('{"statusCode":400,"message":"id must be a number"}'); | ||
// }); | ||
|
||
// it('Link user with project name using invalid user email input', async () => { | ||
// await request(app.getHttpServer()) | ||
// .put('/project/name/testProject/user') | ||
// .send({ | ||
// email: 'abc', | ||
// }) | ||
// .expect(400) | ||
// .expect(''); | ||
// }); | ||
}); |