Skip to content

Commit f09d3fc

Browse files
test: 프로젝트 생성 API e2e 테스트 작성
Co-Authored-By: 조영우 <[email protected]>
1 parent 0d1aaf7 commit f09d3fc

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as request from 'supertest';
2+
import { app, createMember, memberFixture } from 'test/setup';
3+
4+
describe('POST /api/project', () => {
5+
const createProjectPayload = {
6+
title: 'Lesser',
7+
subject: '애자일한 프로젝트 관리 툴',
8+
};
9+
10+
it('should return 201', async () => {
11+
const { accessToken } = await createMember(memberFixture, app);
12+
13+
const response = await request(app.getHttpServer())
14+
.post('/api/project')
15+
.set('Authorization', `Bearer ${accessToken}`)
16+
.send(createProjectPayload);
17+
18+
expect(response.status).toBe(201);
19+
});
20+
21+
it('should return 400', async () => {
22+
const response = await request(app.getHttpServer())
23+
.post('/api/project')
24+
.send({
25+
invalidProperty: 'invalidProperty',
26+
});
27+
28+
expect(response.status).toBe(400);
29+
});
30+
31+
it('should return 401 (Bearer Token is missing)', async () => {
32+
const response = await request(app.getHttpServer())
33+
.post('/api/project')
34+
.send(createProjectPayload);
35+
36+
expect(response.status).toBe(401);
37+
expect(response.body.message).toBe('Bearer Token is missing');
38+
});
39+
40+
it('should return 401 (Expired:accessToken) when given invalid access token', async () => {
41+
const response = await request(app.getHttpServer())
42+
.post('/api/project')
43+
.set('Authorization', `Bearer invalidToken`)
44+
.send(createProjectPayload);
45+
46+
expect(response.status).toBe(401);
47+
expect(response.body.message).toBe('Expired:accessToken');
48+
});
49+
});

0 commit comments

Comments
 (0)