|
1 | 1 | import * as request from 'supertest';
|
2 | 2 | import { app, createMember, memberFixture } from 'test/setup';
|
3 |
| -import { projectFixtures } from 'fixtures/project-fixtures'; |
4 | 3 |
|
5 | 4 | describe('GET /api/project', () => {
|
6 |
| - it('should return 200', async () => { |
| 5 | + const projectPayloads = [ |
| 6 | + { |
| 7 | + title: 'Lesser1', |
| 8 | + subject: '애자일한 프로젝트 관리 툴', |
| 9 | + }, |
| 10 | + { |
| 11 | + title: 'Lesser2', |
| 12 | + subject: '애자일한 프로젝트 관리 툴', |
| 13 | + }, |
| 14 | + ]; |
| 15 | + |
| 16 | + it('should return 200, project list', async () => { |
7 | 17 | const { accessToken } = await createMember(memberFixture, app);
|
| 18 | + for (const payload of projectPayloads) { |
| 19 | + await request(app.getHttpServer()) |
| 20 | + .post('/api/project') |
| 21 | + .set('Authorization', `Bearer ${accessToken}`) |
| 22 | + .send(payload); |
| 23 | + } |
8 | 24 |
|
9 | 25 | const response = await request(app.getHttpServer())
|
10 | 26 | .get('/api/project')
|
11 | 27 | .set('Authorization', `Bearer ${accessToken}`);
|
12 | 28 |
|
13 | 29 | expect(response.status).toBe(200);
|
14 |
| - expect(response.body.projects).toEqual(projectFixtures); |
| 30 | + expect(response.body.projects).toBeDefined(); |
| 31 | + const projects = response.body.projects; |
| 32 | + expect(projects.length).toBe(2); |
| 33 | + expect(projects[0].title).toBe('Lesser1'); |
| 34 | + expect(projects[1].title).toBe('Lesser2'); |
15 | 35 | });
|
16 | 36 |
|
17 | 37 | it('should return 401 (Bearer Token is missing)', async () => {
|
|
0 commit comments