From ff16b5764633437084cf8d94ddeb5c783dd1456e Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Sat, 1 Jun 2024 18:01:23 +0200 Subject: [PATCH] OZG-5167: add utitlty function --- .../src/lib/bescheid.service.ts | 4 +-- .../src/lib/command.util.spec.ts | 30 ++++++++++--------- .../command-shared/src/lib/command.util.ts | 6 +++- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts index 192498752d..e674d62969 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts @@ -9,7 +9,7 @@ import { CommandResourceService, CommandService, getEffectedResourceUrl, - hasCommandError, + notHasCommandError, tapOnCommandSuccessfullyDone, } from '@alfa-client/command-shared'; import { @@ -430,7 +430,7 @@ export class BescheidService { commandStateResource: StateResource<CommandResource>, ): void { this.createBescheidDocumentInProgress$.next(commandStateResource); - if (!hasCommandError(commandStateResource.resource)) { + if (notHasCommandError(commandStateResource.resource)) { const documentUri: ResourceUri = getEffectedResourceUrl(commandStateResource.resource); this.bescheidDocumentUri$.next(documentUri); this.loadBescheidDocumentByUri(documentUri); diff --git a/alfa-client/libs/command-shared/src/lib/command.util.spec.ts b/alfa-client/libs/command-shared/src/lib/command.util.spec.ts index 7567dbc61f..4928d0b23d 100644 --- a/alfa-client/libs/command-shared/src/lib/command.util.spec.ts +++ b/alfa-client/libs/command-shared/src/lib/command.util.spec.ts @@ -21,23 +21,11 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { - createCommandErrorResource, - createCommandListResource, - createCommandResource, -} from 'libs/command-shared/test/command'; +import { createCommandErrorResource, createCommandListResource, createCommandResource, } from 'libs/command-shared/test/command'; import { CommandLinkRel } from './command.linkrel'; import { CommandErrorMessage } from './command.message'; import { CommandListResource, CommandResource } from './command.model'; -import { - getPendingCommandByOrder, - hasCommandError, - isConcurrentModification, - isDone, - isPending, - isRevokeable, - isSuccessfulDone, -} from './command.util'; +import { getPendingCommandByOrder, hasCommandError, isConcurrentModification, isDone, isPending, isRevokeable, isSuccessfulDone, notHasCommandError, } from './command.util'; describe('CommandUtil', () => { describe('isRevokeable', () => { @@ -172,4 +160,18 @@ describe('CommandUtil', () => { expect(isDoneSuccessfuly).toBeFalsy(); }); }); + + describe('notHasCommandError', () => { + it('should return true', () => { + const hasError: boolean = notHasCommandError(createCommandResource()); + + expect(hasError).toBeTruthy(); + }); + + it('should return false', () => { + const hasError: boolean = notHasCommandError(createCommandErrorResource()); + + expect(hasError).toBeFalsy(); + }); + }); }); diff --git a/alfa-client/libs/command-shared/src/lib/command.util.ts b/alfa-client/libs/command-shared/src/lib/command.util.ts index 2dc64f425d..fca9f95c03 100644 --- a/alfa-client/libs/command-shared/src/lib/command.util.ts +++ b/alfa-client/libs/command-shared/src/lib/command.util.ts @@ -21,7 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ResourceUri, getEmbeddedResource, getUrl, hasLink } from '@ngxp/rest'; +import { getEmbeddedResource, getUrl, hasLink, ResourceUri } from '@ngxp/rest'; import { isEmpty, isNil, isObject } from 'lodash-es'; import { CommandLinkRel, CommandListLinkRel } from './command.linkrel'; import { CommandErrorMessage } from './command.message'; @@ -47,6 +47,10 @@ export function hasCommandError(commandResource: CommandResource): boolean { return hasErrorMessage(commandResource) && !isPending(commandResource); } +export function notHasCommandError(commandResource: CommandResource): boolean { + return !hasCommandError(commandResource); +} + export function getPendingCommandByOrder( pendingCommands: CommandListResource, commandOrder: any[], -- GitLab