Skip to content

Commit

Permalink
SPSH-1553: Fixed code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
phaelcg committed Dec 10, 2024
1 parent 7e0078a commit de3c00b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/modules/import/api/import.controller.integration-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,21 @@ describe('Import API', () => {

expect(executeResponse.status).toBe(404);
});

it('should return 500 if the import vorgang has no organisation ID', async () => {
const importVorgang: ImportVorgang<true> = await importVorgangRepository.save(
DoFactory.createImportVorgang(false, { organisationId: undefined, rolleId: faker.string.uuid() }),
);
const params: ImportvorgangByIdBodyParams = {
importvorgangId: importVorgang.id,
};

const executeResponse: Response = await request(app.getHttpServer() as App)
.post('/import/execute')
.send(params);

expect(executeResponse.status).toBe(500);
});
});

describe('/GET doownload', () => {
Expand Down Expand Up @@ -638,13 +653,9 @@ describe('Import API', () => {
});

it('should return 404 if the import transaction is not found', async () => {
const params: ImportvorgangByIdBodyParams = {
importvorgangId: faker.string.uuid(),
};

const executeResponse: Response = await request(app.getHttpServer() as App)
.post('/import/execute')
.send(params);
.get(`/import/${faker.string.uuid()}/download`)
.send();

expect(executeResponse.status).toBe(404);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('ImportDataRepository', () => {
});

describe('save', () => {
it('should save a new importDataItem', async () => {
it('should create a new importDataItem', async () => {
const importvorgangId: string = (await importVorgangRepository.save(DoFactory.createImportVorgang(false)))
.id;
const importDataItem: ImportDataItem<false> = DoFactory.createImportDataItem(false, { importvorgangId });
Expand All @@ -163,6 +163,29 @@ describe('ImportDataRepository', () => {

expect(savedImportDataItem.id).toBeDefined();
});

it('should update an existing importDataItem', async () => {
const importvorgangId: string = (await importVorgangRepository.save(DoFactory.createImportVorgang(false)))
.id;
const createdImportDataItem: ImportDataItem<false> = DoFactory.createImportDataItem(false, {
importvorgangId,
});
const savedImportDataItem: ImportDataItem<true> = await sut.save(createdImportDataItem);

savedImportDataItem.nachname = faker.name.lastName();
savedImportDataItem.vorname = faker.name.firstName();
savedImportDataItem.klasse = '1A';

const result: ImportDataItem<true> = await sut.save(savedImportDataItem);

expect(result.id).toBeDefined();
expect(result.nachname).toBe(savedImportDataItem.nachname);
expect(result.vorname).toBe(savedImportDataItem.vorname);
expect(result.klasse).toBe(savedImportDataItem.klasse);
expect(result.nachname).not.toBe(createdImportDataItem.nachname);
expect(result.vorname).not.toBe(createdImportDataItem.vorname);
expect(result.klasse).not.toBe(createdImportDataItem.klasse);
});
});

describe('deleteByImportVorgangId', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('ImportVorgangRepository', () => {
expect(result.id).toBeDefined();
});

it('should updated an existing ImportVorgang', async () => {
it('should update an existing ImportVorgang', async () => {
const importVorgang: ImportVorgang<false> = DoFactory.createImportVorgang(false);
const createdImportVorgang: ImportVorgang<true> = await sut.save(importVorgang);
createdImportVorgang.status = ImportStatus.VALID;
Expand Down
18 changes: 18 additions & 0 deletions src/shared/config/config.env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,22 @@ describe('Config Loader', () => {
});
});
});

describe('Import Config', () => {
it('should load import configuration with parsed integer values', () => {
process.env['IMPORT_FILE_MAXGROESSE_IN_MB'] = '10';

const config: Config = configEnv();
expect(config.IMPORT).toEqual({
IMPORT_FILE_MAXGROESSE_IN_MB: 10,
});
});

it('should set undefined for import values if not provided', () => {
const config: Config = configEnv();
expect(config.IMPORT).toEqual({
IMPORT_FILE_MAXGROESSE_IN_MB: undefined,
});
});
});
});

0 comments on commit de3c00b

Please sign in to comment.