Skip to content

Commit 76150a8

Browse files
committed
[GET] /boards?page=number&size=number: E2E test codes done
1 parent 9038cce commit 76150a8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/board.e2e-spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,51 @@ describe('BoardController (e2e)', () => {
9696
.get('/board/-1')
9797
.expect(HttpStatus.NOT_FOUND);
9898
});
99+
100+
it('[GET] /board : Should return array of 5 objects since 7 boards are saved', async () => {
101+
const savedUser = await saveBoards(7);
102+
const result = await request(app.getHttpServer()).get(
103+
'/board?page=0&size=5',
104+
);
105+
expect(result.status).toBe(HttpStatus.OK);
106+
const response = result.body as BoardInfoResponseDto[];
107+
expect(response.length).toBe(5);
108+
for (const board of response) {
109+
expect(typeof board.boardId).toBe('number');
110+
expect(board.content).toContain(CONTENT);
111+
expect(board.createdAt).toBeDefined();
112+
expect(board.lastModifiedAt).toBeDefined();
113+
expect(board.name).toBe(NAME);
114+
expect(board.title).toContain(TITLE);
115+
expect(board.userId).toBe(savedUser.getUser_id);
116+
}
117+
});
118+
119+
it('[GET] /board: Should return array of 2 objects since 7 boards are saved', async () => {
120+
const savedUser = await saveBoards(7);
121+
const result = await request(app.getHttpServer()).get(
122+
'/board?page=1&size=5',
123+
);
124+
expect(result.status).toBe(HttpStatus.OK);
125+
const response = result.body as BoardInfoResponseDto[];
126+
expect(response.length).toBe(2);
127+
for (const board of response) {
128+
expect(typeof board.boardId).toBe('number');
129+
expect(board.content).toContain(CONTENT);
130+
expect(board.createdAt).toBeDefined();
131+
expect(board.lastModifiedAt).toBeDefined();
132+
expect(board.name).toBe(NAME);
133+
expect(board.title).toContain(TITLE);
134+
expect(board.userId).toBe(savedUser.getUser_id);
135+
}
136+
});
137+
138+
it('[GET] /board: Should return array of 0 objects since 0 boards are saved', async () => {
139+
const result = await request(app.getHttpServer()).get(
140+
'/board?page=0&size=5',
141+
);
142+
expect(result.status).toBe(HttpStatus.OK);
143+
const response = result.body as BoardInfoResponseDto[];
144+
expect(response.length).toBe(0);
145+
});
99146
});

0 commit comments

Comments
 (0)