Skip to content

Commit

Permalink
Fix Personenkontext Repo Integration Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
casparneumann-cap committed Jan 10, 2025
1 parent ed84a5d commit 65a4bf4
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import { OrganisationRepository } from '../../organisation/persistence/organisat
import { EventModule } from '../../../core/eventbus/event.module.js';
import { mapAggregateToData } from '../../person/persistence/person.repository.js';
import { DomainError } from '../../../shared/error/domain.error.js';
import { Organisation } from '../../organisation/domain/organisation.js';

describe('PersonenkontextRepo', () => {
let module: TestingModule;
let sut: PersonenkontextRepo;
let orm: MikroORM;
let em: EntityManager;
let rolleRepo: RolleRepo;
let organisationRepo: OrganisationRepository;

const createPersonEntity = (): PersonEntity => {
const person: PersonEntity = new PersonEntity().assign(mapAggregateToData(DoFactory.createPerson(false)));
Expand Down Expand Up @@ -57,6 +59,7 @@ describe('PersonenkontextRepo', () => {
orm = module.get(MikroORM);
em = module.get(EntityManager);
rolleRepo = module.get(RolleRepo);
organisationRepo = module.get(OrganisationRepository);

await DatabaseTestModule.setupDatabase(orm);
}, DEFAULT_TIMEOUT_FOR_TESTCONTAINERS);
Expand Down Expand Up @@ -87,12 +90,17 @@ describe('PersonenkontextRepo', () => {

await em.persistAndFlush(newPerson);

const organisation1: Organisation<true> = await organisationRepo.save(
DoFactory.createOrganisation(false),
);

const personEntity: PersonEntity = await em.findOneOrFail(PersonEntity, {
vorname: newPerson.vorname,
});
const newPersonenkontext: PersonenkontextDo<false> = DoFactory.createPersonenkontextDo(false, {
personId: personEntity.id,
rolleId: rolle.id,
organisationId: organisation1.id,
});

const savedPersonenkontext: Option<PersonenkontextDo<true>> = await sut.save(newPersonenkontext);
Expand All @@ -109,12 +117,17 @@ describe('PersonenkontextRepo', () => {

await em.persistAndFlush(newPerson);

const organisation1: Organisation<true> = await organisationRepo.save(
DoFactory.createOrganisation(false),
);

const personEntity: PersonEntity = await em.findOneOrFail(PersonEntity, {
vorname: newPerson.vorname,
});
const newPersonenkontext: PersonenkontextDo<false> = DoFactory.createPersonenkontextDo(false, {
personId: personEntity.id,
rolleId: rolle.id,
organisationId: organisation1.id,
});

const savedPersonenkontext: Option<PersonenkontextDo<true>> = await sut.save(newPersonenkontext);
Expand All @@ -133,12 +146,17 @@ describe('PersonenkontextRepo', () => {

await em.persistAndFlush(newPerson);

const organisation1: Organisation<true> = await organisationRepo.save(
DoFactory.createOrganisation(false),
);

const personEntity: PersonEntity = await em.findOneOrFail(PersonEntity, {
vorname: newPerson.vorname,
});
const newPersonenkontext: PersonenkontextDo<true> = DoFactory.createPersonenkontextDo(true, {
personId: personEntity.id,
rolleId: rolle.id,
organisationId: organisation1.id,
});

const savedPersonenkontext: Option<PersonenkontextDo<true>> = await sut.save(newPersonenkontext);
Expand Down

0 comments on commit 65a4bf4

Please sign in to comment.