Skip to content

Commit

Permalink
Improved Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-kiefer committed Nov 22, 2023
1 parent ef348d5 commit 0fdfdf1
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UsernameGeneratorService } from './username-generator.service.js';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { FindUserFilter, KeycloakUserService, UserDo } from '../keycloak-administration/index.js';
import { UserRepository } from './user.repository.js';
import { EntityNotFoundError } from '../../shared/error/index.js';
import { EntityNotFoundError, KeycloakClientError } from '../../shared/error/index.js';

describe('The UsernameGenerator Service', () => {
let module: TestingModule;
Expand Down Expand Up @@ -100,4 +100,11 @@ describe('The UsernameGenerator Service', () => {
const generatedUsername: string = await service.generateUsername('Renate', 'Bergmann');
expect(generatedUsername).toBe('rbergmann3');
});

it("Should pass along an error thrown if it's not Entity not found", async () => {
kcUserService.findOne.mockResolvedValue({ ok: false, error: new KeycloakClientError('Could not reach') });
await expect(service.generateUsername('Maximilian', 'Mustermann')).rejects.toStrictEqual(
new KeycloakClientError('Could not reach'),
);
});
});

0 comments on commit 0fdfdf1

Please sign in to comment.