Skip to content

Commit

Permalink
fix types in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clauyan committed Sep 9, 2024
1 parent 0ddc16e commit 40ade2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('AuthenticationController', () => {
});
keycloakUserServiceMock.getLastPasswordChange.mockResolvedValueOnce({
ok: true,
value: person.updatedAt.valueOf(),
value: person.updatedAt,
});
const result: UserinfoResponse = await authController.info(permissions);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/authentication/api/userinfo.response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('UserinfoResponse', () => {
});

it('constructs the object with optional extension', () => {
const extension: UserinfoExtension = { password_updated_at: faker.date.past().valueOf() };
const extension: UserinfoExtension = { password_updated_at: faker.date.past() };
const userinfoResponse: UserinfoResponse = new UserinfoResponse(permissions, [pk], extension);
expect(userinfoResponse).toBeDefined();
expect(userinfoResponse.password_updated_at).toEqual(extension.password_updated_at);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ describe('KeycloakUserService', () => {
it('should return the timestamp', async () => {
kcUsersMock.findOne.mockResolvedValueOnce(mockUser);
kcUsersMock.getCredentials.mockResolvedValueOnce(mockCredentials);
const result: Result<number, DomainError> = await service.getLastPasswordChange(mockUser.id!);
const result: Result<Date, DomainError> = await service.getLastPasswordChange(mockUser.id!);
expect(result).toStrictEqual({
ok: true,
value: updatedAt,
Expand All @@ -666,7 +666,7 @@ describe('KeycloakUserService', () => {
it('should return an error', async () => {
kcUsersMock.findOne.mockResolvedValueOnce(mockUser);
kcUsersMock.getCredentials.mockRejectedValueOnce({});
const result: Result<number, DomainError> = await service.getLastPasswordChange(mockUser.id!);
const result: Result<Date, DomainError> = await service.getLastPasswordChange(mockUser.id!);
expect(result).toStrictEqual({
ok: false,
error: new KeycloakClientError('Keycloak request failed'),
Expand All @@ -683,7 +683,7 @@ describe('KeycloakUserService', () => {
];
kcUsersMock.findOne.mockResolvedValueOnce(mockUser);
kcUsersMock.getCredentials.mockResolvedValueOnce(mockCredentials);
const result: Result<number, DomainError> = await service.getLastPasswordChange(mockUser.id!);
const result: Result<Date, DomainError> = await service.getLastPasswordChange(mockUser.id!);
expect(result).toStrictEqual({
ok: false,
error: new KeycloakClientError('Keycloak user password has never been updated'),
Expand All @@ -699,7 +699,7 @@ describe('KeycloakUserService', () => {
it('should return an error', async () => {
kcUsersMock.findOne.mockRejectedValueOnce(null);
kcUsersMock.getCredentials.mockResolvedValueOnce(mockCredentials);
const result: Result<number, DomainError> = await service.getLastPasswordChange(mockUser.id!);
const result: Result<Date, DomainError> = await service.getLastPasswordChange(mockUser.id!);
expect(result).toStrictEqual({
ok: false,
error: new KeycloakClientError('Keycloak request failed'),
Expand All @@ -716,7 +716,7 @@ describe('KeycloakUserService', () => {
it('should return an error', async () => {
kcUsersMock.findOne.mockResolvedValueOnce(brokenUser);
kcUsersMock.getCredentials.mockResolvedValueOnce(mockCredentials);
const result: Result<number, DomainError> = await service.getLastPasswordChange(mockUser.id!);
const result: Result<Date, DomainError> = await service.getLastPasswordChange(mockUser.id!);
expect(result).toStrictEqual({
ok: false,
error: new KeycloakClientError('Keycloak user has no createdTimestamp'),
Expand All @@ -742,7 +742,7 @@ describe('KeycloakUserService', () => {
async ({ credentials, error }: { credentials: Array<CredentialRepresentation>; error: string }) => {
kcUsersMock.findOne.mockResolvedValueOnce(mockUser);
kcUsersMock.getCredentials.mockResolvedValueOnce(credentials);
const result: Result<number, DomainError> = await service.getLastPasswordChange(mockUser.id!);
const result: Result<Date, DomainError> = await service.getLastPasswordChange(mockUser.id!);
expect(result).toStrictEqual({
ok: false,
error: new KeycloakClientError(error),
Expand All @@ -759,7 +759,7 @@ describe('KeycloakUserService', () => {
};

adminService.getAuthedKcAdminClient.mockResolvedValueOnce(error);
const res: Result<number, DomainError> = await service.getLastPasswordChange(faker.string.uuid());
const res: Result<Date, DomainError> = await service.getLastPasswordChange(faker.string.uuid());

expect(res).toBe(error);
});
Expand Down

0 comments on commit 40ade2c

Please sign in to comment.