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

OZG-3574 adjust/add tests

parent 83cf7dd9
No related branches found
No related tags found
No related merge requests found
...@@ -32,8 +32,13 @@ export enum ApiRootLinkRel { ...@@ -32,8 +32,13 @@ export enum ApiRootLinkRel {
ALLE_VORGAENGE_NEU = 'vorgaenge_neu_all', ALLE_VORGAENGE_NEU = 'vorgaenge_neu_all',
MEINE_VORGAENGE_NEU = 'vorgaenge_neu_meine', MEINE_VORGAENGE_NEU = 'vorgaenge_neu_meine',
ALLE_VORGAENGE_ANGENOMMEN = 'vorgaenge_angenommen_all', ALLE_VORGAENGE_ANGENOMMEN = 'vorgaenge_angenommen_all',
MEINE_VORGAENGE_ANGENOMMEN = 'vorgaenge_angenommen_my',
ALLE_VORGAENGE_IN_BEARBEITUNG = 'vorgaenge_in_bearbeitung_all', ALLE_VORGAENGE_IN_BEARBEITUNG = 'vorgaenge_in_bearbeitung_all',
MEINE_VORGAENGE_IN_BEARBEITUNG = 'vorgaenge_in_bearbeitung_my',
ALLE_VORGAENGE_BESCHIEDEN = 'vorgaenge_beschieden_all', ALLE_VORGAENGE_BESCHIEDEN = 'vorgaenge_beschieden_all',
MEINE_VORGAENGE_BESCHIEDEN = 'vorgaenge_beschieden_my',
ALLE_VORGAENGE_ABGESCHLOSSEN = 'vorgaenge_abgeschlossen_all', ALLE_VORGAENGE_ABGESCHLOSSEN = 'vorgaenge_abgeschlossen_all',
MEINE_VORGAENGE_ABGESCHLOSSEN = 'vorgaenge_abgeschlossen_my',
ALLE_VORGAENGE_VERWORFEN = 'vorgaenge_verworfen_all', ALLE_VORGAENGE_VERWORFEN = 'vorgaenge_verworfen_all',
MEINE_VORGAENGE_VERWORFEN = 'vorgaenge_verworfen_my',
} }
\ No newline at end of file
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
export * from './lib/helper'; export * from './lib/helper';
export * from './lib/jest.helper';
export * from './lib/mocking'; export * from './lib/mocking';
export * from './lib/test-utils.module'; export * from './lib/test-utils.module';
import { ComponentFixture } from "@angular/core/testing";
import { expect } from '@jest/globals';
import { getElementFromFixture } from "./helper";
export function notExistsAsHtmlElement(fixture: ComponentFixture<any>, domElement: string): void {
expect(getElementFromFixture(fixture, domElement)).not.toBeInstanceOf(HTMLElement);
}
export function existsAsHtmlElement(fixture: ComponentFixture<any>, domElement: string): void {
expect(getElementFromFixture(fixture, domElement)).toBeInstanceOf(HTMLElement);
}
\ No newline at end of file
...@@ -26,19 +26,18 @@ ...@@ -26,19 +26,18 @@
<div class="views"> <div class="views">
<goofy-client-vorgang-neu-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_NEU: apiRootLinkRel.MEINE_VORGAENGE_NEU" data-test-id="vorgang-neu-view"> <goofy-client-vorgang-neu-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_NEU: apiRootLinkRel.MEINE_VORGAENGE_NEU" data-test-id="vorgang-neu-view">
</goofy-client-vorgang-neu-view-item-container> </goofy-client-vorgang-neu-view-item-container>
<!-- TODO Richtige Links abfragen + Tests --> <goofy-client-vorgang-angenommen-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_ANGENOMMEN: apiRootLinkRel.MEINE_VORGAENGE_ANGENOMMEN" data-test-id="vorgang-angenommen-view">
<goofy-client-vorgang-angenommen-view-item-container *ngIf="(apiRootResource | hasLink: apiRootLinkRel.ALLE_VORGAENGE_ANGENOMMEN) || (apiRootResource | hasLink: apiRootLinkRel.MEINE_VORGAENGE_NEU)" data-test-id="vorgang-angenommen-view">
</goofy-client-vorgang-angenommen-view-item-container> </goofy-client-vorgang-angenommen-view-item-container>
<goofy-client-vorgang-in-bearbeitung-view-item-container *ngIf="(apiRootResource | hasLink: apiRootLinkRel.ALLE_VORGAENGE_IN_BEARBEITUNG) || (apiRootResource | hasLink: apiRootLinkRel.MEINE_VORGAENGE_NEU)" data-test-id="vorgang-in-bearbeitung-view"> <goofy-client-vorgang-in-bearbeitung-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_IN_BEARBEITUNG: apiRootLinkRel.MEINE_VORGAENGE_IN_BEARBEITUNG" data-test-id="vorgang-in-bearbeitung-view">
</goofy-client-vorgang-in-bearbeitung-view-item-container> </goofy-client-vorgang-in-bearbeitung-view-item-container>
<goofy-client-vorgang-beschieden-view-item-container *ngIf="(apiRootResource | hasLink: apiRootLinkRel.ALLE_VORGAENGE_BESCHIEDEN) || (apiRootResource | hasLink: apiRootLinkRel.MEINE_VORGAENGE_NEU)" data-test-id="vorgang-beschieden-view"> <goofy-client-vorgang-beschieden-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_BESCHIEDEN: apiRootLinkRel.MEINE_VORGAENGE_BESCHIEDEN" data-test-id="vorgang-beschieden-view">
</goofy-client-vorgang-beschieden-view-item-container> </goofy-client-vorgang-beschieden-view-item-container>
<goofy-client-vorgang-abgeschlossen-view-item-container *ngIf="(apiRootResource | hasLink: apiRootLinkRel.ALLE_VORGAENGE_ABGESCHLOSSEN) || (apiRootResource | hasLink: apiRootLinkRel.MEINE_VORGAENGE_NEU)" data-test-id="vorgang-abgeschlossen-view"> <goofy-client-vorgang-abgeschlossen-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_ABGESCHLOSSEN: apiRootLinkRel.MEINE_VORGAENGE_ABGESCHLOSSEN" data-test-id="vorgang-abgeschlossen-view">
</goofy-client-vorgang-abgeschlossen-view-item-container> </goofy-client-vorgang-abgeschlossen-view-item-container>
<goofy-client-vorgang-verworfen-view-item-container *ngIf="(apiRootResource | hasLink: apiRootLinkRel.ALLE_VORGAENGE_VERWORFEN) || (apiRootResource | hasLink: apiRootLinkRel.MEINE_VORGAENGE_NEU)" data-test-id="vorgang-verworfen-view"> <goofy-client-vorgang-verworfen-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE_VERWORFEN: apiRootLinkRel.MEINE_VORGAENGE_VERWORFEN" data-test-id="vorgang-verworfen-view">
</goofy-client-vorgang-verworfen-view-item-container> </goofy-client-vorgang-verworfen-view-item-container>
<goofy-client-vorgang-list-view-item-container *ngIf="apiRootResource | hasLink: apiRootLinkRel.ALLE_VORGAENGE" data-test-id="vorgang-vorgang-list-view" class="top-border"> <goofy-client-vorgang-list-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.ALLE_VORGAENGE: apiRootLinkRel.MEINE_VORGAENGE" data-test-id="vorgang-vorgang-list-view" class="top-border">
</goofy-client-vorgang-list-view-item-container> </goofy-client-vorgang-list-view-item-container>
<goofy-client-vorgang-search-view-item-container *ngIf="(apiRootResource | hasLink: apiRootLinkRel.SEARCH_ALLE) || (apiRootResource | hasLink: apiRootLinkRel.SEARCH_MEINE)" data-test-id="vorgang-search-view" class="top-border"> <goofy-client-vorgang-search-view-item-container *ngIf="apiRootResource | hasAnyLink: apiRootLinkRel.SEARCH_ALLE: apiRootLinkRel.SEARCH_MEINE" data-test-id="vorgang-search-view" class="top-border">
</goofy-client-vorgang-search-view-item-container> </goofy-client-vorgang-search-view-item-container>
</div> </div>
\ No newline at end of file
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApiRootLinkRel } from '@goofy-client/api-root-shared'; import { ApiRootLinkRel } from '@goofy-client/api-root-shared';
import { HasLinkPipe } from '@goofy-client/tech-shared'; import { HasLinkPipe } from '@goofy-client/tech-shared';
import { getElementFromFixture } from '@goofy-client/test-utils'; import { existsAsHtmlElement, notExistsAsHtmlElement } from '@goofy-client/test-utils';
import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; import { createApiRootResource } from 'libs/api-root-shared/test/api-root';
import { HasAnyLinkPipe } from 'libs/tech-shared/src/lib/pipe/has-any-link.pipe'; import { HasAnyLinkPipe } from 'libs/tech-shared/src/lib/pipe/has-any-link.pipe';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
...@@ -43,9 +43,14 @@ describe('VorgangViewsMenuComponent', () => { ...@@ -43,9 +43,14 @@ describe('VorgangViewsMenuComponent', () => {
let component: VorgangViewsMenuComponent; let component: VorgangViewsMenuComponent;
let fixture: ComponentFixture<VorgangViewsMenuComponent>; let fixture: ComponentFixture<VorgangViewsMenuComponent>;
const neuView: string = getDataTestIdOf('vorgang-neu-view');
const angenommenView: string = getDataTestIdOf('vorgang-angenommen-view');
const inBearbeitungView: string = getDataTestIdOf('vorgang-in-bearbeitung-view');
const beschiedenView: string = getDataTestIdOf('vorgang-beschieden-view');
const abgeschlossenView: string = getDataTestIdOf('vorgang-abgeschlossen-view');
const verworfenView: string = getDataTestIdOf('vorgang-verworfen-view');
const vorgangListView: string = getDataTestIdOf('vorgang-vorgang-list-view'); const vorgangListView: string = getDataTestIdOf('vorgang-vorgang-list-view');
const searchView: string = getDataTestIdOf('vorgang-search-view'); const searchView: string = getDataTestIdOf('vorgang-search-view');
const neuView: string = getDataTestIdOf('vorgang-neu-view');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
...@@ -75,83 +80,137 @@ describe('VorgangViewsMenuComponent', () => { ...@@ -75,83 +80,137 @@ describe('VorgangViewsMenuComponent', () => {
describe('neu view', () => { describe('neu view', () => {
it('should show if ' + ApiRootLinkRel.ALLE_VORGAENGE_NEU + ' link exists', () => { it.each([ApiRootLinkRel.ALLE_VORGAENGE_NEU, ApiRootLinkRel.MEINE_VORGAENGE_NEU])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([ApiRootLinkRel.ALLE_VORGAENGE_NEU]); component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, neuView); existsAsHtmlElement(fixture, neuView);
expect(element).toBeInstanceOf(HTMLElement);
}) })
it('should show if ' + ApiRootLinkRel.ALLE_VORGAENGE_NEU + ' link exists', () => { it('should hide if both links not exists', () => {
component.apiRootResource = createApiRootResource([ApiRootLinkRel.MEINE_VORGAENGE_NEU]); component.apiRootResource = createApiRootResource();
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, neuView); notExistsAsHtmlElement(fixture, neuView);
})
})
describe('angenommen view', () => {
expect(element).toBeInstanceOf(HTMLElement); it.each([ApiRootLinkRel.ALLE_VORGAENGE_ANGENOMMEN, ApiRootLinkRel.MEINE_VORGAENGE_ANGENOMMEN])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges();
existsAsHtmlElement(fixture, angenommenView);
}) })
it('should hide if both links not exists', () => { it('should hide if both links not exists', () => {
component.apiRootResource = createApiRootResource(); component.apiRootResource = createApiRootResource();
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, neuView); notExistsAsHtmlElement(fixture, angenommenView);
expect(element).not.toBeInstanceOf(HTMLElement);
}) })
}) })
describe('in bearbeitung view', () => {
describe('vorgangList view', () => { it.each([ApiRootLinkRel.ALLE_VORGAENGE_IN_BEARBEITUNG, ApiRootLinkRel.MEINE_VORGAENGE_IN_BEARBEITUNG])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges();
existsAsHtmlElement(fixture, inBearbeitungView);
})
it('should show if link exists', () => { it('should hide if both links not exists', () => {
component.apiRootResource = createApiRootResource([ApiRootLinkRel.ALLE_VORGAENGE]); component.apiRootResource = createApiRootResource();
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, vorgangListView); notExistsAsHtmlElement(fixture, inBearbeitungView);
})
})
describe('beschieden view', () => {
it.each([ApiRootLinkRel.ALLE_VORGAENGE_BESCHIEDEN, ApiRootLinkRel.MEINE_VORGAENGE_BESCHIEDEN])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges();
expect(element).toBeInstanceOf(HTMLElement); existsAsHtmlElement(fixture, beschiedenView);
}) })
it('should hide if link not exists', () => { it('should hide if both links not exists', () => {
component.apiRootResource = createApiRootResource(); component.apiRootResource = createApiRootResource();
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, vorgangListView); notExistsAsHtmlElement(fixture, beschiedenView);
})
})
describe('abgeschlossen view', () => {
it.each([ApiRootLinkRel.ALLE_VORGAENGE_ABGESCHLOSSEN, ApiRootLinkRel.MEINE_VORGAENGE_ABGESCHLOSSEN])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges();
expect(element).not.toBeInstanceOf(HTMLElement); existsAsHtmlElement(fixture, abgeschlossenView);
})
it('should hide if both links not exists', () => {
component.apiRootResource = createApiRootResource();
fixture.detectChanges();
notExistsAsHtmlElement(fixture, beschiedenView);
}) })
}) })
describe('search view', () => { describe('verworfen view', () => {
it('should show if ' + ApiRootLinkRel.SEARCH_ALLE + ' link exists', () => { it.each([ApiRootLinkRel.ALLE_VORGAENGE_VERWORFEN, ApiRootLinkRel.MEINE_VORGAENGE_VERWORFEN])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([ApiRootLinkRel.SEARCH_ALLE]); component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, searchView); existsAsHtmlElement(fixture, verworfenView);
})
it('should hide if both links not exists', () => {
component.apiRootResource = createApiRootResource();
fixture.detectChanges();
notExistsAsHtmlElement(fixture, verworfenView);
})
})
describe('vorgangList view', () => {
expect(element).toBeInstanceOf(HTMLElement); it.each([ApiRootLinkRel.ALLE_VORGAENGE, ApiRootLinkRel.MEINE_VORGAENGE])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges();
existsAsHtmlElement(fixture, vorgangListView);
}) })
it('should show if ' + ApiRootLinkRel.SEARCH_MEINE + ' link exists', () => { it('should hide if link not exists', () => {
component.apiRootResource = createApiRootResource([ApiRootLinkRel.SEARCH_MEINE]); component.apiRootResource = createApiRootResource();
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, searchView); notExistsAsHtmlElement(fixture, vorgangListView);
})
})
describe('search view', () => {
expect(element).toBeInstanceOf(HTMLElement); it.each([ApiRootLinkRel.SEARCH_ALLE, ApiRootLinkRel.SEARCH_MEINE])('should show if %s link exists', (linkRel: string) => {
component.apiRootResource = createApiRootResource([linkRel]);
fixture.detectChanges();
existsAsHtmlElement(fixture, searchView);
}) })
it('should hide if no link not exists', () => { it('should hide if no link not exists', () => {
component.apiRootResource = createApiRootResource(); component.apiRootResource = createApiRootResource();
fixture.detectChanges(); fixture.detectChanges();
const element = getElementFromFixture(fixture, searchView); notExistsAsHtmlElement(fixture, searchView);
expect(element).not.toBeInstanceOf(HTMLElement);
}) })
}) })
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment