1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

Added test for user.service

This commit is contained in:
Alex Tran 2022-11-26 15:09:06 -06:00
parent 614743c8f4
commit fb3b36a569
No known key found for this signature in database
GPG Key ID: E4954BC787B85C8A

View File

@ -1,5 +1,5 @@
import { UserEntity } from '@app/database/entities/user.entity'; import { UserEntity } from '@app/database/entities/user.entity';
import { BadRequestException, NotFoundException } from '@nestjs/common'; import { BadRequestException, NotFoundException, UnauthorizedException } from '@nestjs/common';
import { newUserRepositoryMock } from '../../../test/test-utils'; import { newUserRepositoryMock } from '../../../test/test-utils';
import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { IUserRepository } from './user-repository'; import { IUserRepository } from './user-repository';
@ -127,5 +127,16 @@ describe('UserService', () => {
}); });
expect(result).rejects.toBeInstanceOf(NotFoundException); expect(result).rejects.toBeInstanceOf(NotFoundException);
}); });
it('cannot delete admin user', () => {
const requestor = adminAuthUser;
userRepositoryMock.get.mockImplementationOnce(() => Promise.resolve(adminUser));
userRepositoryMock.get.mockImplementationOnce(() => Promise.resolve(adminUser));
const result = sui.deleteUser(requestor, adminAuthUser.id);
expect(result).rejects.toBeInstanceOf(BadRequestException);
});
}); });
}); });