Skip to content

Commit 0616e7f

Browse files
committed
BoardService#getBoards(): Unit test codes done
1 parent d92ac53 commit 0616e7f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/board/board.service.spec.ts

+35
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,39 @@ describe('BoardService Logic test', () => {
410410
expect(exception).toBeInstanceOf(NotFoundException);
411411
}
412412
});
413+
414+
it('getBoards(): Should return array of 5 objects when page is 0 and size is 5 since 7 boards are saved', async () => {
415+
const savedUser = await saveBoards(7);
416+
const result = await boardService.getBoards(0, 5);
417+
expect(result.length).toBe(5);
418+
for (const board of result) {
419+
expect(typeof board.boardId).toBe('number');
420+
expect(board.content).toContain(CONTENT);
421+
expect(board.createdAt).toBeDefined();
422+
expect(board.lastModifiedAt).toBeDefined();
423+
expect(board.name).toBe(NAME);
424+
expect(board.title).toContain(TITLE);
425+
expect(board.userId).toBe(savedUser.getUser_id);
426+
}
427+
});
428+
429+
it('getBoards(): Should return array of 2 objects when page is 1 and size is 5 since 7 boards are saved', async () => {
430+
const savedUser = await saveBoards(7);
431+
const result = await boardService.getBoards(1, 5);
432+
expect(result.length).toBe(2);
433+
for (const board of result) {
434+
expect(typeof board.boardId).toBe('number');
435+
expect(board.content).toContain(CONTENT);
436+
expect(board.createdAt).toBeDefined();
437+
expect(board.lastModifiedAt).toBeDefined();
438+
expect(board.name).toBe(NAME);
439+
expect(board.title).toContain(TITLE);
440+
expect(board.userId).toBe(savedUser.getUser_id);
441+
}
442+
});
443+
444+
it('getBoards(): Should return an empty array since no boards are saved', async () => {
445+
const result = await boardService.getBoards(0, 5);
446+
expect(result.length).toBe(0);
447+
});
413448
});

0 commit comments

Comments
 (0)