Skip to content

Commit

Permalink
fix: find my video will throw error when there is no video (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirily11 authored May 22, 2023
1 parent 3f1dc5b commit cfac1ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/video/video.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ describe('VideoService', () => {
expect(videos.metadata.total).toBe(1);
});

it('Should be able to find my videos when there is no video', async () => {
const videos = await service.findMyVideos(userId, 1, 2);
expect(videos.items).toHaveLength(0);
expect(videos.metadata.total).toBe(0);
expect(videos.metadata.page).toBe(1);
expect(videos.metadata.totalPages).toBe(0);
});

it('Should be able to find my videos', async () => {
const video: CreateVideoDto = {
title: 'Test Video',
Expand Down
2 changes: 1 addition & 1 deletion src/video/video.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export class VideoService {
metadata: getPaginationMetaData(
page,
per,
(totalResult[0] as any)?.total,
(totalResult[0] as any)?.total ?? 0,
),
};
}
Expand Down

1 comment on commit cfac1ee

@vercel
Copy link

@vercel vercel bot commented on cfac1ee May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.