-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add function to retrieve date of last password update * missing import + smoke test * fix test * fix stale data in test * fix test * add tests * add tolerance for time difference * refactor test * refactor timestamps to date/iso-format * fix types in tests * fix tests * lower tolerance
- Loading branch information
Showing
7 changed files
with
253 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import 'reflect-metadata'; | ||
import { UserinfoExtension, UserinfoResponse } from './userinfo.response.js'; | ||
import { PersonPermissions } from '../domain/person-permissions.js'; | ||
import { DoFactory } from '../../../../test/utils/do-factory.js'; | ||
import { DBiamPersonenkontextRepo } from '../../personenkontext/persistence/dbiam-personenkontext.repo.js'; | ||
import { OrganisationRepository } from '../../organisation/persistence/organisation.repository.js'; | ||
import { RolleRepo } from '../../rolle/repo/rolle.repo.js'; | ||
import { PersonenkontextRolleFieldsResponse } from './personen-kontext-rolle-fields.response.js'; | ||
import { createMock } from '@golevelup/ts-jest'; | ||
|
||
describe('UserinfoResponse', () => { | ||
const permissions: PersonPermissions = new PersonPermissions( | ||
createMock<DBiamPersonenkontextRepo>(), | ||
createMock<OrganisationRepository>(), | ||
createMock<RolleRepo>(), | ||
DoFactory.createPerson(true), | ||
); | ||
const pk: PersonenkontextRolleFieldsResponse = { | ||
organisationsId: faker.string.uuid(), | ||
rolle: { systemrechte: [faker.string.alpha()], serviceProviderIds: [faker.string.uuid()] }, | ||
}; | ||
|
||
it('constructs the object without optional extension', () => { | ||
const userinfoResponse: UserinfoResponse = new UserinfoResponse(permissions, [pk]); | ||
expect(userinfoResponse).toBeDefined(); | ||
expect(userinfoResponse.password_updated_at).toBeUndefined(); | ||
}); | ||
|
||
it('constructs the object with optional extension', () => { | ||
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?.toISOString()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.