2024-05-26 18:15:52 -04:00
|
|
|
import { BadRequestException, InternalServerErrorException, NotFoundException } from '@nestjs/common';
|
2025-04-10 15:53:21 +01:00
|
|
|
import { UserAdmin } from 'src/database';
|
2025-02-11 17:15:56 -05:00
|
|
|
import { CacheControl, JobName, UserMetadataKey } from 'src/enum';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { UserService } from 'src/services/user.service';
|
2024-09-27 10:28:42 -04:00
|
|
|
import { ImmichFileResponse } from 'src/utils/file';
|
2024-03-20 19:32:04 +01:00
|
|
|
import { authStub } from 'test/fixtures/auth.stub';
|
|
|
|
|
import { systemConfigStub } from 'test/fixtures/system-config.stub';
|
|
|
|
|
import { userStub } from 'test/fixtures/user.stub';
|
2025-03-17 15:32:12 -04:00
|
|
|
import { factory } from 'test/small.factory';
|
2025-02-10 18:47:42 -05:00
|
|
|
import { newTestService, ServiceMocks } from 'test/utils';
|
2022-09-18 09:27:06 -05:00
|
|
|
|
2023-02-25 09:12:03 -05:00
|
|
|
const makeDeletedAt = (daysAgo: number) => {
|
|
|
|
|
const deletedAt = new Date();
|
|
|
|
|
deletedAt.setDate(deletedAt.getDate() - daysAgo);
|
|
|
|
|
return deletedAt;
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-18 09:40:15 -05:00
|
|
|
describe(UserService.name, () => {
|
2023-01-12 17:07:57 -05:00
|
|
|
let sut: UserService;
|
2025-02-10 18:47:42 -05:00
|
|
|
let mocks: ServiceMocks;
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2024-03-05 23:23:06 +01:00
|
|
|
beforeEach(() => {
|
2025-02-10 18:47:42 -05:00
|
|
|
({ sut, mocks } = newTestService(UserService));
|
|
|
|
|
mocks.user.get.mockImplementation((userId) =>
|
2025-01-13 19:30:34 -06:00
|
|
|
Promise.resolve([userStub.admin, userStub.user1].find((user) => user.id === userId) ?? undefined),
|
2024-04-16 10:44:45 -04:00
|
|
|
);
|
2022-09-18 09:27:06 -05:00
|
|
|
});
|
|
|
|
|
|
2023-08-03 14:17:38 -04:00
|
|
|
describe('getAll', () => {
|
2024-11-26 10:51:01 -05:00
|
|
|
it('admin should get all users', async () => {
|
2025-03-17 15:32:12 -04:00
|
|
|
const user = factory.userAdmin();
|
|
|
|
|
const auth = factory.auth(user);
|
|
|
|
|
|
|
|
|
|
mocks.user.getList.mockResolvedValue([user]);
|
|
|
|
|
|
|
|
|
|
await expect(sut.search(auth)).resolves.toEqual([expect.objectContaining({ id: user.id, email: user.email })]);
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.getList).toHaveBeenCalledWith({ withDeleted: false });
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
2024-11-26 10:51:01 -05:00
|
|
|
|
|
|
|
|
it('non-admin should get all users when publicUsers enabled', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.getList.mockResolvedValue([userStub.user1]);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2024-11-26 10:51:01 -05:00
|
|
|
await expect(sut.search(authStub.user1)).resolves.toEqual([
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
id: authStub.user1.user.id,
|
|
|
|
|
email: authStub.user1.user.email,
|
|
|
|
|
}),
|
|
|
|
|
]);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.getList).toHaveBeenCalledWith({ withDeleted: false });
|
2024-11-26 10:51:01 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('non-admin user should only receive itself when publicUsers is disabled', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.getList.mockResolvedValue([userStub.user1]);
|
|
|
|
|
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.publicUsersDisabled);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2024-11-26 10:51:01 -05:00
|
|
|
await expect(sut.search(authStub.user1)).resolves.toEqual([
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
id: authStub.user1.user.id,
|
|
|
|
|
email: authStub.user1.user.email,
|
|
|
|
|
}),
|
|
|
|
|
]);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.getList).not.toHaveBeenCalledWith({ withDeleted: false });
|
2024-11-26 10:51:01 -05:00
|
|
|
});
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
|
|
|
|
|
2023-08-03 14:17:38 -04:00
|
|
|
describe('get', () => {
|
2023-01-12 17:07:57 -05:00
|
|
|
it('should get a user by id', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.admin);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await sut.get(authStub.admin.user.id);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.get).toHaveBeenCalledWith(authStub.admin.user.id, { withDeleted: false });
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should throw an error if a user is not found', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(void 0);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2024-05-26 18:15:52 -04:00
|
|
|
await expect(sut.get(authStub.admin.user.id)).rejects.toBeInstanceOf(BadRequestException);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.get).toHaveBeenCalledWith(authStub.admin.user.id, { withDeleted: false });
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2023-08-03 14:17:38 -04:00
|
|
|
describe('getMe', () => {
|
2025-02-12 15:23:08 -05:00
|
|
|
it("should get the auth user's info", async () => {
|
2024-05-26 18:15:52 -04:00
|
|
|
const user = authStub.admin.user;
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-12 15:23:08 -05:00
|
|
|
await expect(sut.getMe(authStub.admin)).resolves.toMatchObject({
|
2024-05-26 18:15:52 -04:00
|
|
|
id: user.id,
|
|
|
|
|
email: user.email,
|
2023-09-11 17:56:38 +02:00
|
|
|
});
|
|
|
|
|
});
|
2022-09-18 09:27:06 -05:00
|
|
|
});
|
2023-01-12 17:07:57 -05:00
|
|
|
|
|
|
|
|
describe('createProfileImage', () => {
|
|
|
|
|
it('should throw an error if the user does not exist', async () => {
|
|
|
|
|
const file = { path: '/profile/path' } as Express.Multer.File;
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(void 0);
|
|
|
|
|
mocks.user.update.mockResolvedValue({ ...userStub.admin, profileImagePath: file.path });
|
2023-01-12 17:07:57 -05:00
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await expect(sut.createProfileImage(authStub.admin, file)).rejects.toThrowError(BadRequestException);
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
2023-09-11 17:56:38 +02:00
|
|
|
|
|
|
|
|
it('should throw an error if the user profile could not be updated with the new image', async () => {
|
|
|
|
|
const file = { path: '/profile/path' } as Express.Multer.File;
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.profilePath);
|
|
|
|
|
mocks.user.update.mockRejectedValue(new InternalServerErrorException('mocked error'));
|
2023-09-11 17:56:38 +02:00
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await expect(sut.createProfileImage(authStub.admin, file)).rejects.toThrowError(InternalServerErrorException);
|
2023-09-11 17:56:38 +02:00
|
|
|
});
|
2023-11-14 04:10:35 +01:00
|
|
|
|
|
|
|
|
it('should delete the previous profile image', async () => {
|
|
|
|
|
const file = { path: '/profile/path' } as Express.Multer.File;
|
|
|
|
|
const files = [userStub.profilePath.profileImagePath];
|
2025-03-17 15:32:12 -04:00
|
|
|
|
|
|
|
|
mocks.user.get.mockResolvedValue(userStub.profilePath);
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.update.mockResolvedValue({ ...userStub.admin, profileImagePath: file.path });
|
2023-11-14 04:10:35 +01:00
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await sut.createProfileImage(authStub.admin, file);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.job.queue.mock.calls).toEqual([[{ name: JobName.DELETE_FILES, data: { files } }]]);
|
2023-11-14 04:10:35 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not delete the profile image if it has not been set', async () => {
|
|
|
|
|
const file = { path: '/profile/path' } as Express.Multer.File;
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.admin);
|
|
|
|
|
mocks.user.update.mockResolvedValue({ ...userStub.admin, profileImagePath: file.path });
|
2023-11-14 04:10:35 +01:00
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await sut.createProfileImage(authStub.admin, file);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.job.queue).not.toHaveBeenCalled();
|
|
|
|
|
expect(mocks.job.queueAll).not.toHaveBeenCalled();
|
2023-11-14 04:10:35 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('deleteProfileImage', () => {
|
|
|
|
|
it('should send an http error has no profile image', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.admin);
|
2023-11-14 04:10:35 +01:00
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await expect(sut.deleteProfileImage(authStub.admin)).rejects.toBeInstanceOf(BadRequestException);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.job.queue).not.toHaveBeenCalled();
|
|
|
|
|
expect(mocks.job.queueAll).not.toHaveBeenCalled();
|
2023-11-14 04:10:35 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should delete the profile image if user has one', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.profilePath);
|
2023-11-14 04:10:35 +01:00
|
|
|
const files = [userStub.profilePath.profileImagePath];
|
|
|
|
|
|
2023-12-09 23:34:12 -05:00
|
|
|
await sut.deleteProfileImage(authStub.admin);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.job.queue.mock.calls).toEqual([[{ name: JobName.DELETE_FILES, data: { files } }]]);
|
2023-11-14 04:10:35 +01:00
|
|
|
});
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('getUserProfileImage', () => {
|
|
|
|
|
it('should throw an error if the user does not exist', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(void 0);
|
2023-01-12 17:07:57 -05:00
|
|
|
|
2023-10-31 11:01:32 -04:00
|
|
|
await expect(sut.getProfileImage(userStub.admin.id)).rejects.toBeInstanceOf(BadRequestException);
|
2023-01-12 17:07:57 -05:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.get).toHaveBeenCalledWith(userStub.admin.id, {});
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should throw an error if the user does not have a picture', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.admin);
|
2023-01-12 17:07:57 -05:00
|
|
|
|
2023-10-31 11:01:32 -04:00
|
|
|
await expect(sut.getProfileImage(userStub.admin.id)).rejects.toBeInstanceOf(NotFoundException);
|
2023-01-12 17:07:57 -05:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.get).toHaveBeenCalledWith(userStub.admin.id, {});
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
2023-10-30 19:38:34 -04:00
|
|
|
|
|
|
|
|
it('should return the profile picture', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(userStub.profilePath);
|
2023-10-30 19:38:34 -04:00
|
|
|
|
2023-12-12 09:58:25 -05:00
|
|
|
await expect(sut.getProfileImage(userStub.profilePath.id)).resolves.toEqual(
|
|
|
|
|
new ImmichFileResponse({
|
|
|
|
|
path: '/path/to/profile.jpg',
|
|
|
|
|
contentType: 'image/jpeg',
|
2023-12-18 11:33:46 -05:00
|
|
|
cacheControl: CacheControl.NONE,
|
2023-12-12 09:58:25 -05:00
|
|
|
}),
|
|
|
|
|
);
|
2023-10-30 19:38:34 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.get).toHaveBeenCalledWith(userStub.profilePath.id, {});
|
2023-10-30 19:38:34 -04:00
|
|
|
});
|
2023-01-12 17:07:57 -05:00
|
|
|
});
|
2023-01-16 13:09:04 -05:00
|
|
|
|
2023-03-24 08:19:48 -04:00
|
|
|
describe('handleQueueUserDelete', () => {
|
2023-02-25 09:12:03 -05:00
|
|
|
it('should skip users not ready for deletion', async () => {
|
2025-03-17 15:32:12 -04:00
|
|
|
mocks.user.getDeletedAfter.mockResolvedValue([]);
|
2024-03-06 00:45:40 -05:00
|
|
|
|
|
|
|
|
await sut.handleUserDeleteCheck();
|
|
|
|
|
|
2025-03-17 15:32:12 -04:00
|
|
|
expect(mocks.user.getDeletedAfter).toHaveBeenCalled();
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.job.queue).not.toHaveBeenCalled();
|
|
|
|
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([]);
|
2024-03-06 00:45:40 -05:00
|
|
|
});
|
|
|
|
|
|
2023-02-25 09:12:03 -05:00
|
|
|
it('should queue user ready for deletion', async () => {
|
2025-03-17 15:32:12 -04:00
|
|
|
const user = factory.user();
|
|
|
|
|
mocks.user.getDeletedAfter.mockResolvedValue([{ id: user.id }]);
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2023-05-17 13:07:17 -04:00
|
|
|
await sut.handleUserDeleteCheck();
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2025-03-17 15:32:12 -04:00
|
|
|
expect(mocks.user.getDeletedAfter).toHaveBeenCalled();
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.USER_DELETION, data: { id: user.id } }]);
|
2024-03-06 00:45:40 -05:00
|
|
|
});
|
2023-02-25 09:12:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('handleUserDelete', () => {
|
|
|
|
|
it('should skip users not ready for deletion', async () => {
|
2025-04-10 15:53:21 +01:00
|
|
|
const user = { id: 'user-1', deletedAt: makeDeletedAt(5) } as UserAdmin;
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(user);
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2023-05-26 15:43:24 -04:00
|
|
|
await sut.handleUserDelete({ id: user.id });
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.storage.unlinkDir).not.toHaveBeenCalled();
|
|
|
|
|
expect(mocks.user.delete).not.toHaveBeenCalled();
|
2023-02-25 09:12:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should delete the user and associated assets', async () => {
|
2025-04-10 15:53:21 +01:00
|
|
|
const user = { id: 'deleted-user', deletedAt: makeDeletedAt(10) } as UserAdmin;
|
2025-03-17 15:32:12 -04:00
|
|
|
const options = { force: true, recursive: true };
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(user);
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2023-05-26 15:43:24 -04:00
|
|
|
await sut.handleUserDelete({ id: user.id });
|
2023-02-25 09:12:03 -05:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.storage.unlinkDir).toHaveBeenCalledWith('upload/library/deleted-user', options);
|
|
|
|
|
expect(mocks.storage.unlinkDir).toHaveBeenCalledWith('upload/upload/deleted-user', options);
|
|
|
|
|
expect(mocks.storage.unlinkDir).toHaveBeenCalledWith('upload/profile/deleted-user', options);
|
|
|
|
|
expect(mocks.storage.unlinkDir).toHaveBeenCalledWith('upload/thumbs/deleted-user', options);
|
|
|
|
|
expect(mocks.storage.unlinkDir).toHaveBeenCalledWith('upload/encoded-video/deleted-user', options);
|
|
|
|
|
expect(mocks.album.deleteAll).toHaveBeenCalledWith(user.id);
|
|
|
|
|
expect(mocks.user.delete).toHaveBeenCalledWith(user, true);
|
2023-02-25 09:12:03 -05:00
|
|
|
});
|
|
|
|
|
|
2023-05-21 23:18:10 -04:00
|
|
|
it('should delete the library path for a storage label', async () => {
|
2025-04-10 15:53:21 +01:00
|
|
|
const user = { id: 'deleted-user', deletedAt: makeDeletedAt(10), storageLabel: 'admin' } as UserAdmin;
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.get.mockResolvedValue(user);
|
2023-05-21 23:18:10 -04:00
|
|
|
|
2023-05-26 15:43:24 -04:00
|
|
|
await sut.handleUserDelete({ id: user.id });
|
2023-05-21 23:18:10 -04:00
|
|
|
|
|
|
|
|
const options = { force: true, recursive: true };
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.storage.unlinkDir).toHaveBeenCalledWith('upload/library/admin', options);
|
2023-05-21 23:18:10 -04:00
|
|
|
});
|
2023-02-25 09:12:03 -05:00
|
|
|
});
|
2024-01-12 18:43:36 -06:00
|
|
|
|
2024-07-01 18:43:16 +01:00
|
|
|
describe('setLicense', () => {
|
2024-07-26 00:27:44 -04:00
|
|
|
it('should save client license if valid', async () => {
|
2025-03-17 15:32:12 -04:00
|
|
|
const license = { licenseKey: 'IMCL-license-key', activationKey: 'activation-key' };
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.upsertMetadata.mockResolvedValue();
|
2024-07-01 18:43:16 +01:00
|
|
|
|
|
|
|
|
await sut.setLicense(authStub.user1, license);
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.upsertMetadata).toHaveBeenCalledWith(authStub.user1.user.id, {
|
2024-07-26 00:27:44 -04:00
|
|
|
key: UserMetadataKey.LICENSE,
|
|
|
|
|
value: expect.any(Object),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should save server license as client if valid', async () => {
|
2025-03-17 15:32:12 -04:00
|
|
|
const license = { licenseKey: 'IMSV-license-key', activationKey: 'activation-key' };
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.upsertMetadata.mockResolvedValue();
|
2024-07-26 00:27:44 -04:00
|
|
|
|
|
|
|
|
await sut.setLicense(authStub.user1, license);
|
|
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.upsertMetadata).toHaveBeenCalledWith(authStub.user1.user.id, {
|
2024-07-01 18:43:16 +01:00
|
|
|
key: UserMetadataKey.LICENSE,
|
|
|
|
|
value: expect.any(Object),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not save license if invalid', async () => {
|
|
|
|
|
const license = { licenseKey: 'license-key', activationKey: 'activation-key' };
|
|
|
|
|
const call = sut.setLicense(authStub.admin, license);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
|
|
|
|
mocks.user.upsertMetadata.mockResolvedValue();
|
|
|
|
|
|
2024-07-01 18:43:16 +01:00
|
|
|
await expect(call).rejects.toThrowError('Invalid license key');
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.upsertMetadata).not.toHaveBeenCalled();
|
2024-07-01 18:43:16 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('deleteLicense', () => {
|
|
|
|
|
it('should delete license', async () => {
|
2025-02-10 18:47:42 -05:00
|
|
|
mocks.user.upsertMetadata.mockResolvedValue();
|
2024-07-01 18:43:16 +01:00
|
|
|
|
|
|
|
|
await sut.deleteLicense(authStub.admin);
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.upsertMetadata).not.toHaveBeenCalled();
|
2024-07-01 18:43:16 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-01-12 18:43:36 -06:00
|
|
|
describe('handleUserSyncUsage', () => {
|
|
|
|
|
it('should sync usage', async () => {
|
|
|
|
|
await sut.handleUserSyncUsage();
|
2025-03-17 15:32:12 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.user.syncUsage).toHaveBeenCalledTimes(1);
|
2024-01-12 18:43:36 -06:00
|
|
|
});
|
|
|
|
|
});
|
2022-09-18 09:27:06 -05:00
|
|
|
});
|