Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mertalev committed Jan 14, 2025
1 parent a93bb2f commit 27b4de4
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions server/src/services/album.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,16 @@ describe(AlbumService.name, () => {
albumMock.update.mockResolvedValue(albumStub.sharedWithAdmin);
userMock.get.mockResolvedValue(userStub.user2);
albumUserMock.create.mockResolvedValue({
userId: userStub.user2.id,
user: userStub.user2,
albumId: albumStub.sharedWithAdmin.id,
album: albumStub.sharedWithAdmin,
usersId: userStub.user2.id,
albumsId: albumStub.sharedWithAdmin.id,
role: AlbumUserRole.EDITOR,
});
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, {
albumUsers: [{ userId: authStub.user2.user.id }],
});
expect(albumUserMock.create).toHaveBeenCalledWith({
userId: authStub.user2.user.id,
albumId: albumStub.sharedWithAdmin.id,
usersId: authStub.user2.user.id,
albumsId: albumStub.sharedWithAdmin.id,
});
expect(eventMock.emit).toHaveBeenCalledWith('album.invite', {
id: albumStub.sharedWithAdmin.id,
Expand All @@ -361,8 +359,8 @@ describe(AlbumService.name, () => {

expect(albumUserMock.delete).toHaveBeenCalledTimes(1);
expect(albumUserMock.delete).toHaveBeenCalledWith({
albumId: albumStub.sharedWithUser.id,
userId: userStub.user1.id,
albumsId: albumStub.sharedWithUser.id,
usersId: userStub.user1.id,
});
expect(albumMock.getById).toHaveBeenCalledWith(albumStub.sharedWithUser.id, { withAssets: false });
});
Expand All @@ -388,8 +386,8 @@ describe(AlbumService.name, () => {

expect(albumUserMock.delete).toHaveBeenCalledTimes(1);
expect(albumUserMock.delete).toHaveBeenCalledWith({
albumId: albumStub.sharedWithUser.id,
userId: authStub.user1.user.id,
albumsId: albumStub.sharedWithUser.id,
usersId: authStub.user1.user.id,
});
});

Expand All @@ -400,8 +398,8 @@ describe(AlbumService.name, () => {

expect(albumUserMock.delete).toHaveBeenCalledTimes(1);
expect(albumUserMock.delete).toHaveBeenCalledWith({
albumId: albumStub.sharedWithUser.id,
userId: authStub.user1.user.id,
albumsId: albumStub.sharedWithUser.id,
usersId: authStub.user1.user.id,
});
});

Expand Down Expand Up @@ -433,7 +431,7 @@ describe(AlbumService.name, () => {
role: AlbumUserRole.EDITOR,
});
expect(albumUserMock.update).toHaveBeenCalledWith(
{ albumId: albumStub.sharedWithAdmin.id, userId: userStub.admin.id },
{ albumsId: albumStub.sharedWithAdmin.id, usersId: userStub.admin.id },
{ role: AlbumUserRole.EDITOR },
);
});
Expand Down

0 comments on commit 27b4de4

Please sign in to comment.