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

OZG-6720 CR Kommentare

parent ca657885
No related branches found
No related tags found
No related merge requests found
<h1 class="heading-1" data-test-id="organisations-form-container-headline"> <ng-container *ngIf="organisationsEinheitStateResource$ | async as organisationsEinheitStateResource">
{{ (organisationsEinheitStateResource$ | async)?.resource?.name }} <h1 class="heading-1" data-test-id="organisations-form-container-headline">{{ organisationsEinheitStateResource.resource?.name }}</h1>
</h1>
<admin-organisationseinheit-form <admin-organisationseinheit-form
[organisationsEinheitStateResource]="organisationsEinheitStateResource$ | async" [organisationsEinheitStateResource]="organisationsEinheitStateResource"
data-test-id="organisations-form" data-test-id="organisations-form"
/> ></admin-organisationseinheit-form>
\ No newline at end of file </ng-container>
\ No newline at end of file
import { AdminOrganisationsEinheitResource, OrganisationsEinheitFormContainerComponent } from '@admin-client/admin-settings'; import { AdminOrganisationsEinheitResource, OrganisationsEinheitFormContainerComponent } from '@admin-client/admin-settings';
import { StateResource, createStateResource } from '@alfa-client/tech-shared'; import { StateResource, createStateResource } from '@alfa-client/tech-shared';
import { Mock, existsAsHtmlElement, mock } from '@alfa-client/test-utils'; import { Mock, existsAsHtmlElement, getElementFromFixture, getMockComponent, mock } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs'; import { of } from 'rxjs';
...@@ -12,12 +12,16 @@ import { OrganisationsEinheitFormComponent } from './organisationseinheit-form/o ...@@ -12,12 +12,16 @@ import { OrganisationsEinheitFormComponent } from './organisationseinheit-form/o
describe('OrganisationsEinheitFormContainerComponent', () => { describe('OrganisationsEinheitFormContainerComponent', () => {
let component: OrganisationsEinheitFormContainerComponent; let component: OrganisationsEinheitFormContainerComponent;
let fixture: ComponentFixture<OrganisationsEinheitFormContainerComponent>; let fixture: ComponentFixture<OrganisationsEinheitFormContainerComponent>;
let organisationsEinheitService: Mock<OrganisationsEinheitService>;
const organisationsEinheitService: Mock<OrganisationsEinheitService> = mock(OrganisationsEinheitService); const organisationsEinheitResource: AdminOrganisationsEinheitResource = createAdminOrganisationsEinheitResource();
const organisationsEinheitStateResource: StateResource<AdminOrganisationsEinheitResource> =
const organisationsEinheitStateResource = createStateResource(createAdminOrganisationsEinheitResource()); createStateResource(organisationsEinheitResource);
beforeEach(async () => { beforeEach(async () => {
organisationsEinheitService = mock(OrganisationsEinheitService);
organisationsEinheitService.get = jest.fn().mockReturnValue(of(organisationsEinheitStateResource));
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [OrganisationsEinheitFormContainerComponent, MockComponent(OrganisationsEinheitFormComponent)], declarations: [OrganisationsEinheitFormContainerComponent, MockComponent(OrganisationsEinheitFormComponent)],
providers: [{ provide: OrganisationsEinheitService, useValue: organisationsEinheitService }], providers: [{ provide: OrganisationsEinheitService, useValue: organisationsEinheitService }],
...@@ -25,9 +29,6 @@ describe('OrganisationsEinheitFormContainerComponent', () => { ...@@ -25,9 +29,6 @@ describe('OrganisationsEinheitFormContainerComponent', () => {
fixture = TestBed.createComponent(OrganisationsEinheitFormContainerComponent); fixture = TestBed.createComponent(OrganisationsEinheitFormContainerComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
organisationsEinheitService.get = jest.fn().mockReturnValue(of(organisationsEinheitStateResource));
fixture.detectChanges(); fixture.detectChanges();
}); });
...@@ -37,20 +38,22 @@ describe('OrganisationsEinheitFormContainerComponent', () => { ...@@ -37,20 +38,22 @@ describe('OrganisationsEinheitFormContainerComponent', () => {
describe('component', () => { describe('component', () => {
describe('ngOnInit', () => { describe('ngOnInit', () => {
it('should call organisationsEinheitService get', () => { it('should call organisationsEinheitService get', (done) => {
component.ngOnInit(); component.ngOnInit();
component.organisationsEinheitStateResource$.subscribe(() => { component.organisationsEinheitStateResource$.subscribe(() => {
expect(organisationsEinheitService.get).toHaveBeenCalled(); expect(organisationsEinheitService.get).toHaveBeenCalled();
done();
}); });
}); });
it('should set organisationsEinheitStateResource', () => { it('should set organisationsEinheitStateResource', (done) => {
component.ngOnInit(); component.ngOnInit();
component.organisationsEinheitStateResource$.subscribe( component.organisationsEinheitStateResource$.subscribe(
(organisationsEinheitStateResource: StateResource<AdminOrganisationsEinheitResource>) => { (organisationsEinheitStateResource: StateResource<AdminOrganisationsEinheitResource>) => {
expect(organisationsEinheitStateResource).toEqual(organisationsEinheitStateResource); expect(organisationsEinheitStateResource).toEqual(organisationsEinheitStateResource);
done();
}, },
); );
}); });
...@@ -59,14 +62,29 @@ describe('OrganisationsEinheitFormContainerComponent', () => { ...@@ -59,14 +62,29 @@ describe('OrganisationsEinheitFormContainerComponent', () => {
describe('template', () => { describe('template', () => {
describe('headline', () => { describe('headline', () => {
const headline: string = getDataTestIdOf('organisations-form-container-headline');
it('should show headline', () => {
existsAsHtmlElement(fixture, headline);
});
it('should show organisationsEinheit name', () => { it('should show organisationsEinheit name', () => {
existsAsHtmlElement(fixture, getDataTestIdOf('organisations-form-container-headline')); const headlineElement: HTMLElement = getElementFromFixture(fixture, headline);
expect(headlineElement.textContent).toBe(organisationsEinheitResource.name);
}); });
}); });
describe('organisationsEinheit form', () => { describe('organisationsEinheit form', () => {
it('should show organisationsEinheit form', () => { const form: string = getDataTestIdOf('organisations-form');
existsAsHtmlElement(fixture, getDataTestIdOf('organisations-form'));
it('should show form', () => {
existsAsHtmlElement(fixture, form);
});
it('should have organisationsEinheitStateResource', () => {
const formComponent: OrganisationsEinheitFormComponent = getMockComponent(fixture, OrganisationsEinheitFormComponent);
expect(formComponent.organisationsEinheitStateResource).toBe(organisationsEinheitStateResource);
}); });
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment