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:
parent
614743c8f4
commit
fb3b36a569
@ -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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user