diff --git a/npm/ng-packs/packages/core/src/lib/tests/config.state.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/config.state.spec.ts index 1ff9ad817e..ae98855913 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/config.state.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/config.state.spec.ts @@ -7,6 +7,7 @@ import { ABP } from '../models'; import { Config } from '../models/config'; import { ApplicationConfigurationService, ConfigStateService } from '../services'; import { ConfigState } from '../states'; +import { HttpClient } from '@angular/common/http'; export const CONFIG_STATE_DATA = { environment: { @@ -136,19 +137,17 @@ describe('ConfigState', () => { let store: SpyObject; let service: ConfigStateService; let state: ConfigState; - let appConfigService: SpyObject; const createService = createServiceFactory({ service: ConfigStateService, - mocks: [ApplicationConfigurationService, Store], + mocks: [ApplicationConfigurationService, Store, HttpClient], }); beforeEach(() => { spectator = createService(); store = spectator.get(Store); service = spectator.service; - appConfigService = spectator.get(ApplicationConfigurationService); - state = new ConfigState(spectator.get(ApplicationConfigurationService), store); + state = new ConfigState(spectator.get(HttpClient), store); }); describe('#getAll', () => { @@ -283,7 +282,7 @@ describe('ConfigState', () => { }); describe('#GetAppConfiguration', () => { - it('should call the getConfiguration of ApplicationConfigurationService and patch the state', done => { + it('should call the app-configuration API and patch the state', done => { let patchStateArg; let dispatchArg; @@ -299,7 +298,8 @@ describe('ConfigState', () => { dispatchArg = a; return of(a); }); - appConfigService.getConfiguration.andReturn(res$); + const httpClient = spectator.get(HttpClient); + httpClient.get.andReturn(res$); state.addData({ patchState, dispatch } as any).subscribe(); diff --git a/npm/ng-packs/packages/core/src/lib/tests/dynamic-layout.component.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/dynamic-layout.component.spec.ts index 0a123b6a4f..e1a678a19f 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/dynamic-layout.component.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/dynamic-layout.component.spec.ts @@ -7,6 +7,7 @@ import { eLayoutType } from '../enums'; import { ABP } from '../models'; import { ConfigState, ReplaceableComponentsState } from '../states'; import { ApplicationConfigurationService } from '../services'; +import { HttpClient } from '@angular/common/http'; @Component({ selector: 'abp-layout-application', @@ -92,7 +93,7 @@ describe('DynamicLayoutComponent', () => { component: RouterOutletComponent, stubsEnabled: false, declarations: [DummyComponent, DynamicLayoutComponent], - mocks: [ApplicationConfigurationService], + mocks: [ApplicationConfigurationService, HttpClient], imports: [ RouterModule, DummyLayoutModule, diff --git a/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts index bfd8948318..5600e3aa39 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts @@ -1,7 +1,7 @@ import { Router } from '@angular/router'; import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest'; -import { Store } from '@ngxs/store'; -import { Observable, of } from 'rxjs'; +import { Store, Actions } from '@ngxs/store'; +import { Observable, of, Subject } from 'rxjs'; import { LocalizationService } from '../services/localization.service'; describe('LocalizationService', () => { @@ -13,6 +13,7 @@ describe('LocalizationService', () => { service: LocalizationService, entryComponents: [], mocks: [Store, Router], + providers: [{ provide: Actions, useValue: new Subject() }], }); beforeEach(() => { @@ -74,7 +75,7 @@ describe('LocalizationService', () => { it('should throw an error message when service have an otherInstance', async () => { try { - const instance = new LocalizationService(null, null, null, {} as any); + const instance = new LocalizationService(new Subject(), null, null, null, {} as any); } catch (error) { expect((error as Error).message).toBe('LocalizationService should have only one instance.'); } diff --git a/npm/ng-packs/packages/core/src/lib/tests/session.state.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/session.state.spec.ts index cdf616e5d2..8a7953dd16 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/session.state.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/session.state.spec.ts @@ -25,7 +25,7 @@ describe('SessionState', () => { beforeEach(() => { spectator = createService(); - state = new SessionState(spectator.get(LocalizationService), null, null, new Subject()); + state = new SessionState(null, null, new Subject()); }); describe('#getLanguage', () => { @@ -49,13 +49,11 @@ describe('SessionState', () => { dispatchedData = action; return of({}); }); - const spy = jest.spyOn(spectator.get(LocalizationService), 'registerLocale'); state.setLanguage({ patchState, dispatch } as any, { payload: 'en' }).subscribe(); expect(patchedData).toEqual({ language: 'en' }); expect(dispatchedData instanceof GetAppConfiguration).toBeTruthy(); - expect(spy).toHaveBeenCalledWith('en'); }); });