diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result.component.spec.ts index 09b86fb5cca6a3e276234985d4c980d39cae2ab9..63d46924cd75604ec3975f452e36034aecd854c0 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result.component.spec.ts @@ -21,7 +21,10 @@ import { createBescheidStateResource, } from 'libs/bescheid-shared/src/test/bescheid'; import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel'; -import { createCommandResource } from 'libs/command-shared/test/command'; +import { + createCommandResource, + createCommandStateResource, +} from 'libs/command-shared/test/command'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { BehaviorSubject, EMPTY, first, of } from 'rxjs'; @@ -376,19 +379,40 @@ describe('VorgangDetailBescheidenResultComponent', () => { const bescheidDraft: BescheidResource = createBescheidResource(); const bescheidStateResource: StateResource<BescheidResource> = createStateResource(bescheidDraft); + let doUpdateAndSendMock: jest.Mock; beforeEach(() => { component.bescheidDraftStateResource$ = of(bescheidStateResource); component.sendByManual$ = of(true); component.activeStep$ = of(3); + doUpdateAndSendMock = component.doUpdateAndSend = jest.fn(); }); it('should call do update and send', () => { - component.doUpdateAndSend = jest.fn(); + component.saveAndSendWithNachricht(bescheidDraft); + expect(doUpdateAndSendMock).toHaveBeenCalledWith(bescheidDraft, expect.any(Function)); + }); + + it('should send bescheid to antragsteller', () => { + bescheidService.sendBescheidToAntragsteller.mockReturnValue(of(createCommandStateResource())); component.saveAndSendWithNachricht(bescheidDraft); + const sendCallback = doUpdateAndSendMock.mock.calls[0][1]; - expect(component.doUpdateAndSend).toHaveBeenCalled(); + sendCallback(bescheidDraft); + + expect(bescheidService.sendBescheidToAntragsteller).toHaveBeenCalledWith(bescheidDraft); + }); + + it('should emit send nachricht', () => { + const sendCommandStateResource: StateResource<CommandResource> = createCommandStateResource(); + bescheidService.sendBescheidToAntragsteller.mockReturnValue(of(sendCommandStateResource)); + component.saveAndSendWithNachricht(bescheidDraft); + const sendCallback = doUpdateAndSendMock.mock.calls[0][1]; + + sendCallback(bescheidDraft).subscribe(); + + expect(component.sendWithNachricht$.value).toEqual(sendCommandStateResource); }); });