diff --git a/alfa-client/apps/admin/src/app/app.component.spec.ts b/alfa-client/apps/admin/src/app/app.component.spec.ts index e56f5f38cd34bdfe0118d5965d814da12dca0521..47e52ca32268a84cd26ea728858fad6b0265e96a 100644 --- a/alfa-client/apps/admin/src/app/app.component.spec.ts +++ b/alfa-client/apps/admin/src/app/app.component.spec.ts @@ -23,7 +23,7 @@ */ import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; import { BuildInfoComponent } from '@alfa-client/common'; -import { Environment } from '@alfa-client/environment-shared'; +import { getEnvironmentFactory } from '@alfa-client/environment-shared'; import { HasLinkPipe, createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; import { Mock, @@ -45,14 +45,16 @@ import { } from '@ods/system'; import { AuthenticationService } from 'authentication'; import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; +import { createEnvironment } from 'libs/environment-shared/test/environment'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent, MockDirective } from 'ng-mocks'; import { of } from 'rxjs'; -import { createEnvironment } from '../../../../libs/environment-shared/test/environment'; import { UserProfileButtonContainerComponent } from '../common/user-profile-button-container/user-profile.button-container.component'; import { UnavailablePageComponent } from '../pages/unavailable/unavailable-page/unavailable-page.component'; import { AppComponent } from './app.component'; +jest.mock('@alfa-client/environment-shared'); + describe('AppComponent', () => { let component: AppComponent; let fixture: ComponentFixture<AppComponent>; @@ -67,7 +69,8 @@ describe('AppComponent', () => { const logoLink: string = getDataTestIdOf('logo-link'); const routerOutletSelector: string = getDataTestIdOf('router-outlet'); - let environment: Environment; + const environment = createEnvironment(); + (getEnvironmentFactory as jest.Mock).mockReturnValue(environment); const authenticationService: Mock<AuthenticationService> = { ...mock(AuthenticationService), @@ -127,9 +130,6 @@ describe('AppComponent', () => { }); beforeEach(() => { - environment = createEnvironment(); - window['__env__'] = environment; - fixture = TestBed.createComponent(AppComponent); component = fixture.componentInstance; }); diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts index f7f989ad0ea0c6f858b33dd0a5a49f8098acbe9b..1ba6ecc20981d81a7e0f8c436ed6f0dc356e348a 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts @@ -28,6 +28,7 @@ import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement } from '@alfa-c import { ComponentFixture, TestBed } from '@angular/core/testing'; import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { singleColdCompleted } from 'libs/tech-shared/test/marbles'; import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; import { OrganisationsEinheitFormPageComponent } from './organisationseinheit-form-page.component'; @@ -63,7 +64,8 @@ describe('OrganisationsEinheitFormPageComponent', () => { describe('component', () => { describe('ngOnInit', () => { - const apiRootStateResource$ = of(createStateResource(createApiRootResource())); + const apiRootStateResource = createStateResource(createApiRootResource()); + const apiRootStateResource$ = of(apiRootStateResource); beforeEach(() => { apiRootService.getApiRoot.mockReturnValue(apiRootStateResource$); @@ -78,7 +80,7 @@ describe('OrganisationsEinheitFormPageComponent', () => { it('should get apiRootStateResource$', () => { component.ngOnInit(); - expect(component.apiRootStateResource$).toBe(apiRootStateResource$); + expect(component.apiRootStateResource$).toBeObservable(singleColdCompleted(apiRootStateResource)); }); }); }); diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts index cb179dc9727bd12366b5b9d4f574bdfad6b6200f..dadcef92d8689aedb0c8653b4fc773dcccc14aff 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts @@ -26,10 +26,11 @@ import { ApiRootLinkRel, ApiRootService } from '@alfa-client/api-root-shared'; import { createStateResource, TechSharedModule } from '@alfa-client/tech-shared'; import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { singleColdCompleted } from 'libs/tech-shared/test/marbles'; import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; -import { createApiRootResource } from '../../../../../../libs/api-root-shared/test/api-root'; -import { getDataTestIdOf } from '../../../../../../libs/tech-shared/test/data-test'; import { OrganisationsEinheitPageComponent } from './organisationseinheit-page.component'; describe('OrganisationsEinheitPageComponent', () => { @@ -63,7 +64,8 @@ describe('OrganisationsEinheitPageComponent', () => { describe('component', () => { describe('ngOnInit', () => { - const apiRootStateResource$ = of(createStateResource(createApiRootResource())); + const apiRootStateResource = createStateResource(createApiRootResource()); + const apiRootStateResource$ = of(apiRootStateResource); beforeEach(() => { apiRootService.getApiRoot.mockReturnValue(apiRootStateResource$); @@ -78,7 +80,7 @@ describe('OrganisationsEinheitPageComponent', () => { it('should get apiRootStateResource$', () => { component.ngOnInit(); - expect(component.apiRootStateResource$).toBe(apiRootStateResource$); + expect(component.apiRootStateResource$).toBeObservable(singleColdCompleted(apiRootStateResource)); }); }); });