Skip to content
Snippets Groups Projects
Commit 63aeed07 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-5843 add missing tests' (#660) from OZG-5843-add-missing-test into master

parents a1fec9bf e28ab339
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,10 @@ import { ...@@ -21,7 +21,10 @@ import {
createBescheidStateResource, createBescheidStateResource,
} from 'libs/bescheid-shared/src/test/bescheid'; } from 'libs/bescheid-shared/src/test/bescheid';
import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel'; 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 { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { BehaviorSubject, EMPTY, first, of } from 'rxjs'; import { BehaviorSubject, EMPTY, first, of } from 'rxjs';
...@@ -376,19 +379,40 @@ describe('VorgangDetailBescheidenResultComponent', () => { ...@@ -376,19 +379,40 @@ describe('VorgangDetailBescheidenResultComponent', () => {
const bescheidDraft: BescheidResource = createBescheidResource(); const bescheidDraft: BescheidResource = createBescheidResource();
const bescheidStateResource: StateResource<BescheidResource> = const bescheidStateResource: StateResource<BescheidResource> =
createStateResource(bescheidDraft); createStateResource(bescheidDraft);
let doUpdateAndSendMock: jest.Mock;
beforeEach(() => { beforeEach(() => {
component.bescheidDraftStateResource$ = of(bescheidStateResource); component.bescheidDraftStateResource$ = of(bescheidStateResource);
component.sendByManual$ = of(true); component.sendByManual$ = of(true);
component.activeStep$ = of(3); component.activeStep$ = of(3);
doUpdateAndSendMock = component.doUpdateAndSend = jest.fn();
}); });
it('should call do update and send', () => { 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); 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);
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment