Skip to content

Commit

Permalink
test: add controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter committed Aug 15, 2024
1 parent d0e66cc commit 5cbd030
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/account/account.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ describe('AccountController', () => {
});
});

it('should delete a user account', (done) => {
mockHttp.delete.mockReturnValue(of(""));
const id = 'my-id';

controller
.deleteAccount({ user }, id )
.subscribe(() => {
// delete user
expect(mockHttp.delete).toHaveBeenCalledWith(
expect.stringContaining("/ndb-dev/users/my-id"),
);
done();
});
});

it('should return a user with the assigned roles', async () => {
const requestedUser: KeycloakUser = { username: 'my-user', id: 'user-id' };
const roles = ['user-role-1', 'user-role-2'];
Expand Down
1 change: 0 additions & 1 deletion src/account/keycloak.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class KeycloakService {
return this.perform(
this.http.delete,
`${realm}/users/${id}`,
{}
).pipe(
catchError(() => {
return of("")
Expand Down

0 comments on commit 5cbd030

Please sign in to comment.