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

OZG-6720 CR Kommentare

parent ca657885
Branches
Tags 1.2.0
No related merge requests found
<h1 class="heading-1" data-test-id="organisations-form-container-headline">
{{ (organisationsEinheitStateResource$ | async)?.resource?.name }}
</h1>
<ng-container *ngIf="organisationsEinheitStateResource$ | async as organisationsEinheitStateResource">
<h1 class="heading-1" data-test-id="organisations-form-container-headline">{{ organisationsEinheitStateResource.resource?.name }}</h1>
<admin-organisationseinheit-form
[organisationsEinheitStateResource]="organisationsEinheitStateResource$ | async"
[organisationsEinheitStateResource]="organisationsEinheitStateResource"
data-test-id="organisations-form"
/>
\ No newline at end of file
></admin-organisationseinheit-form>
</ng-container>
\ No newline at end of file
import { AdminOrganisationsEinheitResource, OrganisationsEinheitFormContainerComponent } from '@admin-client/admin-settings';
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 { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
......@@ -12,12 +12,16 @@ import { OrganisationsEinheitFormComponent } from './organisationseinheit-form/o
describe('OrganisationsEinheitFormContainerComponent', () => {
let component: OrganisationsEinheitFormContainerComponent;
let fixture: ComponentFixture<OrganisationsEinheitFormContainerComponent>;
let organisationsEinheitService: Mock<OrganisationsEinheitService>;
const organisationsEinheitService: Mock<OrganisationsEinheitService> = mock(OrganisationsEinheitService);
const organisationsEinheitStateResource = createStateResource(createAdminOrganisationsEinheitResource());
const organisationsEinheitResource: AdminOrganisationsEinheitResource = createAdminOrganisationsEinheitResource();
const organisationsEinheitStateResource: StateResource<AdminOrganisationsEinheitResource> =
createStateResource(organisationsEinheitResource);
beforeEach(async () => {
organisationsEinheitService = mock(OrganisationsEinheitService);
organisationsEinheitService.get = jest.fn().mockReturnValue(of(organisationsEinheitStateResource));
await TestBed.configureTestingModule({
declarations: [OrganisationsEinheitFormContainerComponent, MockComponent(OrganisationsEinheitFormComponent)],
providers: [{ provide: OrganisationsEinheitService, useValue: organisationsEinheitService }],
......@@ -25,9 +29,6 @@ describe('OrganisationsEinheitFormContainerComponent', () => {
fixture = TestBed.createComponent(OrganisationsEinheitFormContainerComponent);
component = fixture.componentInstance;
organisationsEinheitService.get = jest.fn().mockReturnValue(of(organisationsEinheitStateResource));
fixture.detectChanges();
});
......@@ -37,20 +38,22 @@ describe('OrganisationsEinheitFormContainerComponent', () => {
describe('component', () => {
describe('ngOnInit', () => {
it('should call organisationsEinheitService get', () => {
it('should call organisationsEinheitService get', (done) => {
component.ngOnInit();
component.organisationsEinheitStateResource$.subscribe(() => {
expect(organisationsEinheitService.get).toHaveBeenCalled();
done();
});
});
it('should set organisationsEinheitStateResource', () => {
it('should set organisationsEinheitStateResource', (done) => {
component.ngOnInit();
component.organisationsEinheitStateResource$.subscribe(
(organisationsEinheitStateResource: StateResource<AdminOrganisationsEinheitResource>) => {
expect(organisationsEinheitStateResource).toEqual(organisationsEinheitStateResource);
done();
},
);
});
......@@ -59,14 +62,29 @@ describe('OrganisationsEinheitFormContainerComponent', () => {
describe('template', () => {
describe('headline', () => {
const headline: string = getDataTestIdOf('organisations-form-container-headline');
it('should show headline', () => {
existsAsHtmlElement(fixture, headline);
});
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', () => {
it('should show organisationsEinheit form', () => {
existsAsHtmlElement(fixture, getDataTestIdOf('organisations-form'));
const form: string = 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