Skip to content
Snippets Groups Projects
Commit 79399215 authored by Martin's avatar Martin
Browse files

OZG-7872 adjust tests

parent 97506967
Branches
Tags
1 merge request!115OZG-7872 use order and uri for command key in state; add pendingCommands to...
......@@ -21,24 +21,25 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';
import {
COMMAND_ERROR_MESSAGES,
CommandErrorMessage,
CommandOrder,
CommandResource,
CreateCommandProps,
} from '@alfa-client/command-shared';
import { NavigationService } from '@alfa-client/navigation-shared';
import { ApiError } from '@alfa-client/tech-shared';
import { Mock, mock } from '@alfa-client/test-utils';
import { SnackBarService } from '@alfa-client/ui';
import { VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';
import { provideMockActions } from '@ngrx/effects/testing';
import { Action } from '@ngrx/store';
import { provideMockStore } from '@ngrx/store/testing';
import { cold, hot } from 'jest-marbles';
import { createCommandResource } from 'libs/command-shared/test/command';
import { createCommandResource, createCreateCommandProps } from 'libs/command-shared/test/command';
import { createApiError, createHttpErrorResponse } from 'libs/tech-shared/test/error';
import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang';
import { Observable, of } from 'rxjs';
......@@ -131,7 +132,8 @@ describe('LoeschAnforderungEffects', () => {
...createCommandResource(),
order: CommandOrder.VORGANG_LOESCHEN,
};
const action = CommandActions.createCommandSuccess({ command });
const createCommandProps: CreateCommandProps = createCreateCommandProps();
const action = CommandActions.createCommandSuccess({ command, createCommandProps });
it('should call sncakbarService on vorgangLoeschen command', () => {
actions = of(action);
......@@ -143,17 +145,14 @@ describe('LoeschAnforderungEffects', () => {
});
describe('loeschAnforderungZuruecknehmenFailedAndReloadVorgangSuccess', () => {
const action =
LoeschAnforderungActions.loeschAnforderungZuruecknehmenFailedAndReloadVorgangSuccess();
const action = LoeschAnforderungActions.loeschAnforderungZuruecknehmenFailedAndReloadVorgangSuccess();
it('should show snackbar', () => {
actions = of(action);
effects.loeschAnforderungZuruecknehmenFailedAndReloadVorgangSuccess$.subscribe();
expect(snackbarService.showError).toHaveBeenCalledWith(
COMMAND_ERROR_MESSAGES[CommandErrorMessage.CONCURRENT_MODIFICATION],
);
expect(snackbarService.showError).toHaveBeenCalledWith(COMMAND_ERROR_MESSAGES[CommandErrorMessage.CONCURRENT_MODIFICATION]);
});
});
......@@ -164,8 +163,7 @@ describe('LoeschAnforderungEffects', () => {
};
const actionError = <HttpErrorResponse>{ error };
const overviewUrl: string = faker.internet.url();
const action =
LoeschAnforderungActions.loeschAnforderungZuruecknehmenFailedAndReloadVorgangFailure({
const action = LoeschAnforderungActions.loeschAnforderungZuruecknehmenFailedAndReloadVorgangFailure({
error: actionError,
overviewUrl,
});
......@@ -175,9 +173,7 @@ describe('LoeschAnforderungEffects', () => {
effects.loeschAnforderungZuruecknehmenFailedAndReloadVorgangFailure$.subscribe();
expect(snackbarService.showInfo).toHaveBeenCalledWith(
'Der Vorgang wurde zwischenzeitlich gelöscht.',
);
expect(snackbarService.showInfo).toHaveBeenCalledWith('Der Vorgang wurde zwischenzeitlich gelöscht.');
});
it('should navigate to overview', () => {
......
......@@ -21,16 +21,11 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { CommandOrder, CommandResource } from '@alfa-client/command-shared';
import {
ApiError,
createEmptyStateResource,
createErrorStateResource,
createStateResource,
} from '@alfa-client/tech-shared';
import { CommandOrder, CommandResource, CreateCommandProps } from '@alfa-client/command-shared';
import { ApiError, createEmptyStateResource, createErrorStateResource, createStateResource } from '@alfa-client/tech-shared';
import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { Action } from '@ngrx/store';
import { createCommand, createCommandResource } from 'libs/command-shared/test/command';
import { createCommand, createCommandResource, createCreateCommandProps } from 'libs/command-shared/test/command';
import { createLoeschAnforderungResource } from 'libs/loesch-anforderung-shared/test/loesch-anforderung';
import { createApiError } from 'libs/tech-shared/test/error';
import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang';
......@@ -100,7 +95,8 @@ describe('LoeschAnforderung Reducer', () => {
...createCommandResource(),
order: CommandOrder.VORGANG_ZUM_LOESCHEN_MARKIEREN,
};
const action = CommandActions.createCommandSuccess({ command });
const createCommandProps: CreateCommandProps = createCreateCommandProps();
const action = CommandActions.createCommandSuccess({ command, createCommandProps });
const state: LoeschAnforderungState = reducer(initialState, action);
......@@ -150,7 +146,8 @@ describe('LoeschAnforderung Reducer', () => {
...createCommandResource(),
order: CommandOrder.VORGANG_LOESCHEN,
};
const action = CommandActions.createCommandSuccess({ command });
const createCommandProps: CreateCommandProps = createCreateCommandProps();
const action = CommandActions.createCommandSuccess({ command, createCommandProps });
const state: LoeschAnforderungState = reducer(initialState, action);
......@@ -180,7 +177,8 @@ describe('LoeschAnforderung Reducer', () => {
...createCommandResource(),
order: CommandOrder.LOESCH_ANFORDERUNG_ZURUECKNEHMEN,
};
const action = CommandActions.createCommandSuccess({ command });
const createCommandProps: CreateCommandProps = createCreateCommandProps();
const action = CommandActions.createCommandSuccess({ command, createCommandProps });
const state: LoeschAnforderungState = reducer(initialState, action);
......@@ -192,7 +190,8 @@ describe('LoeschAnforderung Reducer', () => {
...createCommandResource(),
order: CommandOrder.LOESCH_ANFORDERUNG_ZURUECKNEHMEN,
};
const action = CommandActions.createCommandSuccess({ command });
const createCommandProps: CreateCommandProps = createCreateCommandProps();
const action = CommandActions.createCommandSuccess({ command, createCommandProps });
const state: LoeschAnforderungState = reducer(
{
......@@ -213,13 +212,12 @@ describe('LoeschAnforderung Reducer', () => {
order: CommandOrder.LOESCH_ANFORDERUNG_ZURUECKNEHMEN,
};
const error: ApiError = createApiError();
const action = CommandActions.createCommandFailure({ command, error });
const createCommandProps: CreateCommandProps = createCreateCommandProps();
const action = CommandActions.createCommandFailure({ command, createCommandProps, error });
const state: LoeschAnforderungState = reducer(initialState, action);
expect(state.loeschAnforderungZuruecknehmenCommand).toEqual(
createErrorStateResource(error),
);
expect(state.loeschAnforderungZuruecknehmenCommand).toEqual(createErrorStateResource(error));
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment